From 11a827d54805b605a2500b4f6f13b8237bfffffd Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Wed, 10 Jul 2024 11:12:13 +0200 Subject: [PATCH] Recast: fix missed XZY -> XYZ conversions in dtNavMeshQuery ZY needs to be flipped for YZ, previously the function would never find a poly as the reservoir sampler always failed (polyArea was always a large negative number). --- .../recast/Detour/Source/DetourNavMeshQuery.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/thirdparty/recast/Detour/Source/DetourNavMeshQuery.cpp b/src/thirdparty/recast/Detour/Source/DetourNavMeshQuery.cpp index e7da617e..c718dc48 100644 --- a/src/thirdparty/recast/Detour/Source/DetourNavMeshQuery.cpp +++ b/src/thirdparty/recast/Detour/Source/DetourNavMeshQuery.cpp @@ -235,7 +235,7 @@ dtStatus dtNavMeshQuery::findRandomPoint(const dtQueryFilter* filter, float (*fr const dtMeshTile* t = m_nav->getTile(i); if (!t || !t->header) continue; - // Choose random tile using reservoi sampling. + // Choose random tile using reservoir sampling. const float area = 1.0f; // Could be tile area too. tsum += area; const float u = frand(); @@ -267,12 +267,12 @@ dtStatus dtNavMeshQuery::findRandomPoint(const dtQueryFilter* filter, float (*fr for (int j = 2; j < p->vertCount; ++j) { const float* va = &tile->verts[p->verts[0]*3]; - const float* vb = &tile->verts[p->verts[j-1]*3]; - const float* vc = &tile->verts[p->verts[j]*3]; + const float* vb = &tile->verts[p->verts[j]*3]; + const float* vc = &tile->verts[p->verts[j-1]*3]; polyArea += dtTriArea2D(va,vb,vc); } - // Choose random polygon weighted by area, using reservoi sampling. + // Choose random polygon weighted by area, using reservoir sampling. areaSum += polyArea; const float u = frand(); if (u*areaSum <= polyArea) @@ -375,11 +375,11 @@ dtStatus dtNavMeshQuery::findRandomPointAroundCircle(dtPolyRef startRef, const f for (int j = 2; j < bestPoly->vertCount; ++j) { const float* va = &bestTile->verts[bestPoly->verts[0]*3]; - const float* vb = &bestTile->verts[bestPoly->verts[j-1]*3]; - const float* vc = &bestTile->verts[bestPoly->verts[j]*3]; + const float* vb = &bestTile->verts[bestPoly->verts[j]*3]; + const float* vc = &bestTile->verts[bestPoly->verts[j-1]*3]; polyArea += dtTriArea2D(va,vb,vc); } - // Choose random polygon weighted by area, using reservoi sampling. + // Choose random polygon weighted by area, using reservoir sampling. areaSum += polyArea; const float u = frand(); if (u*areaSum <= polyArea)