fix for Issue 91:findStraightPath error with multiple height levels.

This commit is contained in:
Mikko Mononen 2010-07-08 11:37:14 +00:00
parent 939050eb82
commit 1d36d4f40b

View File

@ -597,7 +597,13 @@ void NavMeshTesterTool::recalc()
m_nstraightPath = 0;
if (m_npolys)
{
m_nstraightPath = m_navMesh->findStraightPath(m_spos, m_epos, m_polys, m_npolys,
// In case of partial path, make sure the end point is clamped to the last polygon.
float epos[3];
rcVcopy(epos, m_epos);
if (m_polys[m_npolys-1] != m_endRef)
m_navMesh->closestPointOnPoly(m_polys[m_npolys-1], m_epos, epos);
m_nstraightPath = m_navMesh->findStraightPath(m_spos, epos, m_polys, m_npolys,
m_straightPath, m_straightPathFlags,
m_straightPathPolys, MAX_POLYS);
}