From 2e01ccff8818776f2b8804d068c4029306edf56a Mon Sep 17 00:00:00 2001 From: Cedric Guillemet Date: Tue, 20 Aug 2019 09:17:36 -0700 Subject: [PATCH] Fix axis flip in navmesh world coordinates --- recastjs/src/recastjs.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/recastjs/src/recastjs.cpp b/recastjs/src/recastjs.cpp index a2ec9a8ec..bb482e1bd 100644 --- a/recastjs/src/recastjs.cpp +++ b/recastjs/src/recastjs.cpp @@ -98,7 +98,7 @@ void NavMesh::build(const float* positions, const int positionCount, const int* for (unsigned int i = 0; idetailVerts[(pd->vertBase+t[j]-poly->vertCount)*3]; } - triangle.mPoint[j] = Vec3(pf[2], pf[1], pf[0]); + triangle.mPoint[2-j] = Vec3(pf[0], pf[1], pf[2]); } debugNavMesh.mTriangles.push_back(triangle); } @@ -495,7 +495,7 @@ Vec3 NavMesh::getClosestPoint(const Vec3& position) polyPickExt[1] = 4; polyPickExt[2] = 2; - Vec3 pos(position.z, position.y, position.x); + Vec3 pos(position.x, position.y, position.z); m_navQuery->findNearestPoly(&pos.x, polyPickExt, &filter, &polyRef, 0); @@ -507,7 +507,7 @@ Vec3 NavMesh::getClosestPoint(const Vec3& position) { return Vec3(0.f, 0.f, 0.f); } - return Vec3(resDetour.z, resDetour.y, resDetour.x); + return Vec3(resDetour.x, resDetour.y, resDetour.z); } Vec3 NavMesh::getRandomPointAround(const Vec3& position, float maxRadius) @@ -523,7 +523,7 @@ Vec3 NavMesh::getRandomPointAround(const Vec3& position, float maxRadius) polyPickExt[1] = 4; polyPickExt[2] = 2; - Vec3 pos(position.z, position.y, position.x); + Vec3 pos(position.x, position.y, position.z); m_navQuery->findNearestPoly(&pos.x, polyPickExt, &filter, &polyRef, 0); @@ -537,7 +537,7 @@ Vec3 NavMesh::getRandomPointAround(const Vec3& position, float maxRadius) return Vec3(0.f, 0.f, 0.f); } - return Vec3(resDetour.z, resDetour.y, resDetour.x); + return Vec3(resDetour.x, resDetour.y, resDetour.z); } NavPath NavMesh::computePath(const Vec3& start, const Vec3& end) const @@ -558,8 +558,8 @@ NavPath NavMesh::computePath(const Vec3& start, const Vec3& end) const filter.setIncludeFlags(0xffff); filter.setExcludeFlags(0); - Vec3 posStart(start.z, start.y, start.x); - Vec3 posEnd(end.z, end.y, end.x); + Vec3 posStart(start.x, start.y, start.z); + Vec3 posEnd(end.x, end.y, end.z); m_navQuery->findNearestPoly(&posStart.x, polyPickExt, &filter, &startRef, 0); m_navQuery->findNearestPoly(&posEnd.x, polyPickExt, &filter, &endRef, 0); @@ -589,7 +589,7 @@ NavPath NavMesh::computePath(const Vec3& start, const Vec3& end) const navpath.mPoints.resize(mNstraightPath); for (int i = 0;igetAgent(idx); - return Vec3(agent->npos[2], agent->npos[1], agent->npos[0]); + return Vec3(agent->npos[0], agent->npos[1], agent->npos[2]); } Vec3 Crowd::getAgentVelocity(int idx) { const dtCrowdAgent* agent = m_crowd->getAgent(idx); - return Vec3(agent->vel[2], agent->vel[1], agent->vel[0]); + return Vec3(agent->vel[0], agent->vel[1], agent->vel[2]); } void Crowd::agentGoto(int idx, const Vec3& destination) @@ -650,7 +650,7 @@ void Crowd::agentGoto(int idx, const Vec3& destination) polyPickExt[1] = 4; polyPickExt[2] = 2; - Vec3 pos(destination.z, destination.y, destination.x); + Vec3 pos(destination.x, destination.y, destination.z); m_crowd->getNavMeshQuery()->findNearestPoly(&pos.x, polyPickExt, &filter, &polyRef, 0); m_crowd->requestMoveTarget(idx, polyRef, &pos.x);