fix: use closestPointOnPoly instead of getPolyHeight in dtNavMeshQuery::findRandomPoint (#560)
This commit is contained in:
parent
9df3e2e0a6
commit
0af470fe74
@ -301,11 +301,7 @@ dtStatus dtNavMeshQuery::findRandomPoint(const dtQueryFilter* filter, float (*fr
|
|||||||
float pt[3];
|
float pt[3];
|
||||||
dtRandomPointInConvexPoly(verts, poly->vertCount, areas, s, t, pt);
|
dtRandomPointInConvexPoly(verts, poly->vertCount, areas, s, t, pt);
|
||||||
|
|
||||||
float h = 0.0f;
|
closestPointOnPoly(polyRef, pt, pt, NULL);
|
||||||
dtStatus status = getPolyHeight(polyRef, pt, &h);
|
|
||||||
if (dtStatusFailed(status))
|
|
||||||
return status;
|
|
||||||
pt[1] = h;
|
|
||||||
|
|
||||||
dtVcopy(randomPt, pt);
|
dtVcopy(randomPt, pt);
|
||||||
*randomRef = polyRef;
|
*randomRef = polyRef;
|
||||||
@ -488,16 +484,12 @@ dtStatus dtNavMeshQuery::findRandomPointAroundCircle(dtPolyRef startRef, const f
|
|||||||
float pt[3];
|
float pt[3];
|
||||||
dtRandomPointInConvexPoly(verts, randomPoly->vertCount, areas, s, t, pt);
|
dtRandomPointInConvexPoly(verts, randomPoly->vertCount, areas, s, t, pt);
|
||||||
|
|
||||||
float h = 0.0f;
|
closestPointOnPoly(randomPolyRef, pt, pt, NULL);
|
||||||
dtStatus stat = getPolyHeight(randomPolyRef, pt, &h);
|
|
||||||
if (dtStatusFailed(status))
|
|
||||||
return stat;
|
|
||||||
pt[1] = h;
|
|
||||||
|
|
||||||
dtVcopy(randomPt, pt);
|
dtVcopy(randomPt, pt);
|
||||||
*randomRef = randomPolyRef;
|
*randomRef = randomPolyRef;
|
||||||
|
|
||||||
return DT_SUCCESS;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user