Problem with dtNavMeshQuery::findNearestPoly

205 views
Skip to first unread message

Silouane

unread,
Apr 7, 2022, 6:40:37 AM4/7/22
to recastnavigation
Hello,

I seem to have a problem with findNearestPoly which gives me a nearestPt (when displaying it, it looks correct).
But when I check it to see the closestPointOnPoly with the info provided by the findNearestPoly. The posOverPoly is set to false in some cases.

Code looks like this:
dtPolyRef startRef = 0;
float closestPos[3];
m_query->findNearestPoly(startPos, m_tolerance, m_filter, &startRef,  closestPos);

float newClosestPos[3];
bool isInsidePoly = false;
m_query-> closestPointOnPoly(startRef,  closestPos,  newClosestPos, &isInsidePoly);

closestPos and newClosestPos are the same and isInsidePoly is set to false.

The startPos is not on the navmesh.

I am looking at this problem for a while now, and I can not understand it. I was thinking it might be a precision problem? Because when I look at dtPointInPolygon which fails, it has something to do with comparing 2 float which are almost identical 10^-6. But

if any of you have another idea?
Reply all
Reply to author
Forward
0 new messages