From 848fbabc790dc3e47e0dc99ac87f2771707bb60e Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Thu, 8 Aug 2024 01:33:27 +0200 Subject: [PATCH] Recast: simplify quantization --- src/thirdparty/recast/Detour/Include/DetourNavMesh.h | 4 ++-- src/thirdparty/recast/Detour/Source/DetourNavMesh.cpp | 2 +- src/thirdparty/recast/Detour/Source/DetourNavMeshBuilder.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/thirdparty/recast/Detour/Include/DetourNavMesh.h b/src/thirdparty/recast/Detour/Include/DetourNavMesh.h index b26e2ed9..30537110 100644 --- a/src/thirdparty/recast/Detour/Include/DetourNavMesh.h +++ b/src/thirdparty/recast/Detour/Include/DetourNavMesh.h @@ -86,7 +86,7 @@ static const unsigned short DT_FIRST_USABLE_POLY_GROUP = 2; static const int DT_MIN_POLY_GROUP_COUNT = 3; /// The cached poly surface area quantization factor. -static const float DT_POLY_AREA_QUANT_FACTOR = 100.f; +static const float DT_POLY_AREA_QUANT_FACTOR = 0.01f; /// The maximum number of traversal tables per navmesh that will be used for static pathing. static const int DT_MAX_TRAVERSAL_TABLES = 5; @@ -98,7 +98,7 @@ static const unsigned char DT_NULL_TRAVERSE_TYPE = 0xff; static const unsigned short DT_NULL_TRAVERSE_REVERSE_LINK = 0xffff; /// The cached traverse link distance quantization factor. -static const float DT_TRAVERSE_DIST_QUANT_FACTOR = 10.f; +static const float DT_TRAVERSE_DIST_QUANT_FACTOR = 0.1f; /// A value that indicates the link doesn't contain a hint index. static const unsigned short DT_NULL_HINT = 0xffff; diff --git a/src/thirdparty/recast/Detour/Source/DetourNavMesh.cpp b/src/thirdparty/recast/Detour/Source/DetourNavMesh.cpp index f071edfc..b86cdce1 100644 --- a/src/thirdparty/recast/Detour/Source/DetourNavMesh.cpp +++ b/src/thirdparty/recast/Detour/Source/DetourNavMesh.cpp @@ -1750,7 +1750,7 @@ dtStatus dtNavMesh::getPolyArea(dtPolyRef ref, unsigned char* resultArea) const unsigned char dtCalcLinkDistance(const float* spos, const float* epos) { - return (unsigned char)rdMathFloorf(rdVdist(spos, epos) / DT_TRAVERSE_DIST_QUANT_FACTOR); + return (unsigned char)rdMathFloorf(rdVdist(spos, epos) * DT_TRAVERSE_DIST_QUANT_FACTOR); } float dtCalcPolySurfaceArea(const dtPoly* poly, const float* verts) diff --git a/src/thirdparty/recast/Detour/Source/DetourNavMeshBuilder.cpp b/src/thirdparty/recast/Detour/Source/DetourNavMeshBuilder.cpp index 48ee6bdc..bc6dc0b0 100644 --- a/src/thirdparty/recast/Detour/Source/DetourNavMeshBuilder.cpp +++ b/src/thirdparty/recast/Detour/Source/DetourNavMeshBuilder.cpp @@ -927,7 +927,7 @@ bool dtCreateNavMeshData(dtNavMeshCreateParams* params, unsigned char** outData, p->vertCount++; } rdVscale(p->center, p->center, 1 / (float)(p->vertCount)); - p->surfaceArea = (unsigned short)rdMathFloorf(dtCalcPolySurfaceArea(p,navVerts) / DT_POLY_AREA_QUANT_FACTOR); + p->surfaceArea = (unsigned short)rdMathFloorf(dtCalcPolySurfaceArea(p,navVerts) * DT_POLY_AREA_QUANT_FACTOR); src += nvp*2; }