mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Recast: draw height point offset in traverse links
Show the actual kink from raycast point to actual link point.
This commit is contained in:
parent
1ae54c6b5b
commit
d6ae135fd6
@ -175,6 +175,7 @@ void Editor::resetCommonSettings()
|
|||||||
|
|
||||||
m_cellSize = 16.0f;
|
m_cellSize = 16.0f;
|
||||||
m_cellHeight = 5.85f;
|
m_cellHeight = 5.85f;
|
||||||
|
m_traverseLinkParams.cellHeight = m_cellHeight;
|
||||||
|
|
||||||
// todo(amos): check if this applies for all hulls, and check if this is the
|
// todo(amos): check if this applies for all hulls, and check if this is the
|
||||||
// actual value used by the game. This seems to generate slopes very close
|
// actual value used by the game. This seems to generate slopes very close
|
||||||
@ -213,7 +214,9 @@ void Editor::handleCommonSettings()
|
|||||||
ImGui::Text("Rasterization");
|
ImGui::Text("Rasterization");
|
||||||
|
|
||||||
ImGui::SliderFloat("Cell Size", &m_cellSize, 12.1f, 100.0f);
|
ImGui::SliderFloat("Cell Size", &m_cellSize, 12.1f, 100.0f);
|
||||||
ImGui::SliderFloat("Cell Height", &m_cellHeight, 0.4f, 100.0f);
|
|
||||||
|
if (ImGui::SliderFloat("Cell Height", &m_cellHeight, 0.4f, 100.0f))
|
||||||
|
m_traverseLinkParams.cellHeight = m_cellHeight;
|
||||||
|
|
||||||
if (m_geom)
|
if (m_geom)
|
||||||
{
|
{
|
||||||
|
@ -49,7 +49,8 @@ struct duDrawTraverseLinkParams
|
|||||||
duDrawTraverseLinkParams() :
|
duDrawTraverseLinkParams() :
|
||||||
traverseLinkType(-1),
|
traverseLinkType(-1),
|
||||||
traverseLinkDistance(-1),
|
traverseLinkDistance(-1),
|
||||||
traverseAnimType(-2)
|
traverseAnimType(-2),
|
||||||
|
cellHeight(0.0f)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
int traverseLinkType;
|
int traverseLinkType;
|
||||||
@ -58,6 +59,10 @@ struct duDrawTraverseLinkParams
|
|||||||
// -2 means all, -1 means disjoint poly groups only, anything above
|
// -2 means all, -1 means disjoint poly groups only, anything above
|
||||||
// refers to an actual anim type and indexes into the traverse tables.
|
// refers to an actual anim type and indexes into the traverse tables.
|
||||||
int traverseAnimType;
|
int traverseAnimType;
|
||||||
|
|
||||||
|
// Used to determine the max LOS angle, this information is lost after
|
||||||
|
// the mesh tile has been build so we have to cache it from the editor.
|
||||||
|
float cellHeight;
|
||||||
};
|
};
|
||||||
|
|
||||||
void duDebugDrawNavMesh(struct duDebugDraw* dd, const dtNavMesh& mesh, const float* offset, unsigned int flags, const duDrawTraverseLinkParams& traverseLinkParams);
|
void duDebugDrawNavMesh(struct duDebugDraw* dd, const dtNavMesh& mesh, const float* offset, unsigned int flags, const duDrawTraverseLinkParams& traverseLinkParams);
|
||||||
|
@ -212,13 +212,37 @@ static void drawTraverseLinks(duDebugDraw* dd, const dtNavMesh& mesh, const dtNa
|
|||||||
query->getEdgeMidPoint(basePolyRef, link->ref, startPos);
|
query->getEdgeMidPoint(basePolyRef, link->ref, startPos);
|
||||||
query->getEdgeMidPoint(link->ref, basePolyRef, endPos);
|
query->getEdgeMidPoint(link->ref, basePolyRef, endPos);
|
||||||
|
|
||||||
|
const float slopeAngle = rdMathFabsf(rdCalcSlopeAngle(startPos, endPos));
|
||||||
|
const float offsetAmount = rdCalcLedgeSpanOffsetAmount(tile->header->walkableRadius,
|
||||||
|
slopeAngle, rdCalcMaxLOSAngle(tile->header->walkableRadius, traverseLinkParams.cellHeight));
|
||||||
|
|
||||||
|
const bool startPointHighest = startPos[2] > endPos[2];
|
||||||
|
float* highestPos = startPointHighest ? startPos : endPos;
|
||||||
|
|
||||||
|
const dtPolyRef lowPolyRef = startPointHighest ? link->ref : basePolyRef;
|
||||||
|
const dtPolyRef highPolyRef = startPointHighest ? basePolyRef : link->ref;
|
||||||
|
|
||||||
|
float normal[3];
|
||||||
|
query->getEdgeNormal(highPolyRef, lowPolyRef, normal);
|
||||||
|
|
||||||
|
// The offset between the height point and the ray point
|
||||||
|
// used to account for the ledge span.
|
||||||
|
const float offsetEndPos[3] = {
|
||||||
|
highestPos[0] + normal[0] * offsetAmount,
|
||||||
|
highestPos[1] + normal[1] * offsetAmount,
|
||||||
|
highestPos[2]
|
||||||
|
};
|
||||||
|
|
||||||
// Unique color for each type.
|
// Unique color for each type.
|
||||||
const int col = duIntToCol(link->traverseType, 128);
|
const int col = duIntToCol(link->traverseType, 128);
|
||||||
|
|
||||||
dd->begin(DU_DRAW_LINES, 2.0f, offset);
|
dd->begin(DU_DRAW_LINES, 2.0f, offset);
|
||||||
|
|
||||||
dd->vertex(startPos, col);
|
const float* targetStartPos = startPointHighest ? offsetEndPos : startPos;
|
||||||
dd->vertex(endPos, col);
|
const float* targetEndPos = startPointHighest ? startPos : offsetEndPos;
|
||||||
|
|
||||||
|
dd->vertex(targetStartPos, col);
|
||||||
|
dd->vertex(targetEndPos, col);
|
||||||
|
|
||||||
const bool hasReverseLink = link->reverseLink != DT_NULL_TRAVERSE_REVERSE_LINK;
|
const bool hasReverseLink = link->reverseLink != DT_NULL_TRAVERSE_REVERSE_LINK;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user