Recast: rename rdPerpDirEdge2D and cleanup variable names

Enforce naming consistency.
This commit is contained in:
Kawe Mazidjatari 2024-08-14 01:35:05 +02:00
parent d6ae135fd6
commit 16fe32d8e5
5 changed files with 29 additions and 29 deletions

View File

@ -550,11 +550,11 @@ static bool traverseLinkOffsetIntersectsGeom(const InputGeom* geom, const float*
static bool traverseLinkInLOS(const InputGeom* geom, const float* lowPos, const float* highPos, const float* lowDir, const float* highDir, const float offsetAmount)
{
float lowPerp[3];
rdPerpDirEdge2D(lowDir, false, lowPerp);
float lowNormal[3];
rdCalcEdgeNormal2D(lowDir, false, lowNormal);
float highPerp[3];
rdPerpDirEdge2D(highDir, false, highPerp);
float highNormal[3];
rdCalcEdgeNormal2D(highDir, false, highNormal);
// Detect overhangs to avoid links like these:
//
@ -579,7 +579,7 @@ static bool traverseLinkInLOS(const InputGeom* geom, const float* lowPos, const
// The AI would otherwise attempt to initiate
// the jump from the lower navmesh, causing it
// to clip through geometry.
if (!polyEdgeFaceAgainst(lowPos, highPos, lowPerp, highPerp))
if (!polyEdgeFaceAgainst(lowPos, highPos, lowNormal, highNormal))
return false;
const float* targetRayPos = highPos;
@ -616,8 +616,8 @@ static bool traverseLinkInLOS(const InputGeom* geom, const float* lowPos, const
if (hasOffset)
{
offsetRayPos[0] = highPos[0] + highPerp[0] * offsetAmount;
offsetRayPos[1] = highPos[1] + highPerp[1] * offsetAmount;
offsetRayPos[0] = highPos[0] + highNormal[0] * offsetAmount;
offsetRayPos[1] = highPos[1] + highNormal[1] * offsetAmount;
offsetRayPos[2] = highPos[2];
if (traverseLinkOffsetIntersectsGeom(geom, highPos, offsetRayPos))

View File

@ -98,20 +98,20 @@ static void drawPolyBoundaries(duDebugDraw* dd, const dtMeshTile* tile,
if (!inner && flags & DU_DRAWNAVMESH_LEDGE_SPANS)
{
float perp[3];
rdPerpDirPtEdge2D(v0, v1, false, perp);
float normal[3];
rdCalcEdgeNormalPt2D(v0, v1, false, normal);
float mid[3];
rdVsad(mid, v0, v1, 0.5f);
float perpEnd[3] = {
mid[0] + perp[0] * walkableRadius,
mid[1] + perp[1] * walkableRadius,
mid[2]
float ledgeEnd[3] = {
mid[0] + normal[0] * walkableRadius,
mid[1] + normal[1] * walkableRadius,
mid[2]
};
dd->vertex(mid, c);
dd->vertex(perpEnd, c);
dd->vertex(ledgeEnd, c);
}
// Draw detail mesh edges which align with the actual poly edge.

View File

@ -2348,7 +2348,7 @@ dtStatus dtNavMeshQuery::getEdgeNormal(dtPolyRef from, dtPolyRef to, float* norm
return DT_FAILURE | DT_INVALID_PARAM;
float dir[3];
rdVsub(dir, right,left);
rdPerpDirEdge2D(dir, false, norm);
rdCalcEdgeNormal2D(dir, false, norm);
return DT_SUCCESS;
}
@ -2361,7 +2361,7 @@ dtStatus dtNavMeshQuery::getEdgeNormal(dtPolyRef from, const dtPoly* fromPoly, c
return DT_FAILURE | DT_INVALID_PARAM;
float dir[3];
rdVsub(dir, right,left);
rdPerpDirEdge2D(dir, false, norm);
rdCalcEdgeNormal2D(dir, false, norm);
return DT_SUCCESS;
}

View File

@ -441,18 +441,18 @@ bool rdIntersectSegSeg2D(const float* ap, const float* aq,
float rdDistancePtLine2d(const float* pt, const float* p, const float* q);
/// Derives the perpendicular direction of an edge
/// Derives the normal of an edge
/// @param[in] dir The direction of the edge. [(x, y, z)]
/// @param[in] inner Whether to face towards the poly or away from it.
/// @param[out] out The resulting direction. [(x, y)]
void rdPerpDirEdge2D(const float* dir, const bool inner, float* out);
/// @param[in] invert Whether to invert the results.
/// @param[out] out The resulting normal. [(x, y)]
void rdCalcEdgeNormal2D(const float* dir, const bool inner, float* out);
/// Derives the perpendicular direction of an edge
/// Derives the normal of an edge
/// @param[in] v1 First vert of the polygon edge. [(x, y, z)]
/// @param[in] v2 Second vert of the polygon vert. [(x, y, z)]
/// @param[in] inner Whether to face towards the poly or away from it.
/// @param[out] out The resulting direction. [(x, y)]
void rdPerpDirPtEdge2D(const float* v1, const float* v2, const bool inner, float* out);
/// @param[in] v2 Second vert of the polygon edge. [(x, y, z)]
/// @param[in] invert Whether to invert the results.
/// @param[out] out The resulting normal. [(x, y)]
void rdCalcEdgeNormalPt2D(const float* v1, const float* v2, const bool inner, float* out);
/// Derives the maximum angle in which an object on an elevated surface can be seen from below.
/// @param[in] ledgeSpan The distance between the edge of the object and the edge of the ledge.

View File

@ -409,9 +409,9 @@ float rdDistancePtLine2d(const float* pt, const float* p, const float* q)
return dx * dx + dy * dy;
}
void rdPerpDirEdge2D(const float* dir, const bool inner, float* out)
void rdCalcEdgeNormal2D(const float* dir, const bool invert, float* out)
{
if (inner)
if (invert)
{
out[0] = -dir[1];
out[1] = dir[0];
@ -425,11 +425,11 @@ void rdPerpDirEdge2D(const float* dir, const bool inner, float* out)
rdVnormalize2D(out);
}
void rdPerpDirPtEdge2D(const float* v1, const float* v2, const bool inner, float* out)
void rdCalcEdgeNormalPt2D(const float* v1, const float* v2, const bool invert, float* out)
{
float dir[3];
rdVsub(dir, v2, v1);
rdPerpDirEdge2D(dir, inner, out);
rdCalcEdgeNormal2D(dir, invert, out);
}
float rdCalcMaxLOSAngle(const float ledgeSpan, const float objectHeight)