mirror of
https://github.com/recastnavigation/recastnavigation.git
synced 2026-10-31 13:05:54 +00:00
findWallDistance uses bitangent to the poly edge itself, rather than vector to the agent, for returned normal
This commit is contained in:
committed by
Jakob Botsch Nielsen
parent
a07fbdca25
commit
a89774ae84
@@ -3473,6 +3473,8 @@ dtStatus dtNavMeshQuery::findDistanceToWall(dtPolyRef startRef, const float* cen
|
||||
float radiusSqr = dtSqr(maxRadius);
|
||||
|
||||
dtStatus status = DT_SUCCESS;
|
||||
|
||||
const float *bestvj = 0, *bestvi = 0;
|
||||
|
||||
while (!m_openList->empty())
|
||||
{
|
||||
@@ -3547,6 +3549,8 @@ dtStatus dtNavMeshQuery::findDistanceToWall(dtPolyRef startRef, const float* cen
|
||||
hitPos[0] = vj[0] + (vi[0] - vj[0])*tseg;
|
||||
hitPos[1] = vj[1] + (vi[1] - vj[1])*tseg;
|
||||
hitPos[2] = vj[2] + (vi[2] - vj[2])*tseg;
|
||||
bestvj = vj;
|
||||
bestvi = vi;
|
||||
}
|
||||
|
||||
for (unsigned int i = bestPoly->firstLink; i != DT_NULL_LINK; i = bestTile->links[i].next)
|
||||
@@ -3620,8 +3624,17 @@ dtStatus dtNavMeshQuery::findDistanceToWall(dtPolyRef startRef, const float* cen
|
||||
}
|
||||
|
||||
// Calc hit normal.
|
||||
dtVsub(hitNormal, centerPos, hitPos);
|
||||
dtVnormalize(hitNormal);
|
||||
if(bestvj && bestvi)
|
||||
{
|
||||
float tangent[3];
|
||||
dtVsub(tangent, bestvi, bestvj);
|
||||
|
||||
hitNormal[0] = tangent[2];
|
||||
hitNormal[1] = 0;
|
||||
hitNormal[2] = -tangent[0];
|
||||
|
||||
dtVnormalize(hitNormal);
|
||||
}
|
||||
|
||||
*hitDist = dtMathSqrtf(radiusSqr);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user