calculate off-mesh-connection height correctly

This commit is contained in:
Qian Qian 2014-02-03 16:34:47 +08:00
parent e117234170
commit 90d5a85b85

View File

@ -682,8 +682,8 @@ dtStatus dtNavMeshQuery::getPolyHeight(dtPolyRef ref, const float* pos, float* h
{ {
const float* v0 = &tile->verts[poly->verts[0]*3]; const float* v0 = &tile->verts[poly->verts[0]*3];
const float* v1 = &tile->verts[poly->verts[1]*3]; const float* v1 = &tile->verts[poly->verts[1]*3];
const float d0 = dtVdist(pos, v0); const float d0 = dtVdist2D(pos, v0);
const float d1 = dtVdist(pos, v1); const float d1 = dtVdist2D(pos, v1);
const float u = d0 / (d0+d1); const float u = d0 / (d0+d1);
if (height) if (height)
*height = v0[1] + (v1[1] - v0[1]) * u; *height = v0[1] + (v1[1] - v0[1]) * u;