- Improved unconnected off-mesh connection debug draw

- Fixed connecting off-mesh links which connect to the same tile x,y but different layer
- Fixed crash in navmehs query closestPointOnPolyInTile() when the poly is off-mesh connection
This commit is contained in:
Mikko Mononen
2012-06-12 03:28:43 +00:00
parent d2b4b09e16
commit 64802ecd0e
6 changed files with 124 additions and 81 deletions

View File

@@ -519,6 +519,18 @@ dtStatus dtNavMeshQuery::closestPointOnPoly(dtPolyRef ref, const float* pos, flo
void dtNavMeshQuery::closestPointOnPolyInTile(const dtMeshTile* tile, const dtPoly* poly,
const float* pos, float* closest) const
{
// Off-mesh connections don't have detail polygons.
if (poly->getType() == DT_POLYTYPE_OFFMESH_CONNECTION)
{
const float* v0 = &tile->verts[poly->verts[0]*3];
const float* v1 = &tile->verts[poly->verts[1]*3];
const float d0 = dtVdist(pos, v0);
const float d1 = dtVdist(pos, v1);
const float u = d0 / (d0+d1);
dtVlerp(closest, v0, v1, u);
return;
}
const unsigned int ip = (unsigned int)(poly - tile->polys);
const dtPolyDetail* pd = &tile->detailMeshes[ip];