From 1d36d4f40b32f5d56e7aeada44ac86adeb13695c Mon Sep 17 00:00:00 2001 From: Mikko Mononen Date: Thu, 8 Jul 2010 11:37:14 +0000 Subject: [PATCH] fix for Issue 91:findStraightPath error with multiple height levels. --- RecastDemo/Source/NavMeshTesterTool.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/RecastDemo/Source/NavMeshTesterTool.cpp b/RecastDemo/Source/NavMeshTesterTool.cpp index f81d92a..2890507 100644 --- a/RecastDemo/Source/NavMeshTesterTool.cpp +++ b/RecastDemo/Source/NavMeshTesterTool.cpp @@ -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); }