From 4d2210d5e9cb9221fd2f87b2d96b50040e0c4742 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Mon, 12 Aug 2024 00:04:18 +0200 Subject: [PATCH] Recast: properly set tile and poly bits for MSET 5 MSET 5 uses the default Recast & Detour tile and poly bit configuration. MSET 7 or higher uses a different configuration to allow building navmeshes for the size's of Apex Legends maps. --- src/naveditor/Editor_Common.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/naveditor/Editor_Common.cpp b/src/naveditor/Editor_Common.cpp index 7c11cba2..c76e7303 100644 --- a/src/naveditor/Editor_Common.cpp +++ b/src/naveditor/Editor_Common.cpp @@ -70,6 +70,14 @@ static void EditorCommon_DrawTilingGrid(duDebugDraw* const dd, const InputGeom* duDebugDrawGridXY(dd, bmax[0], bmin[1], bmin[2], tw, th, s, duRGBA(0, 0, 0, 64), 1.0f, nullptr); } +#if DT_NAVMESH_SET_VERSION == 5 +#define MIN_TILE_BITS 14 +#define MAX_TILE_BITS 22 +#else +#define MIN_TILE_BITS 16 +#define MAX_TILE_BITS 28 +#endif + int EditorCommon_SetAndRenderTileProperties(const InputGeom* const geom, const int tileSize, const float cellSize, int& maxTiles, int& maxPolysPerTile) { @@ -89,9 +97,9 @@ int EditorCommon_SetAndRenderTileProperties(const InputGeom* const geom, const i ImGui::Text("Tile Sizes: %g x %g (%g)", tw* cellSize, th*cellSize, tileSize*cellSize); // Max tiles and max polys affect how the tile IDs are calculated. - // There are 28 bits available for identifying a tile and a polygon. - int tileBits = rdMin((int)rdIlog2(rdNextPow2(tw*th)), 16); - int polyBits = 28 - tileBits; + // There are MAX_TILE_BITS bits available for identifying a tile and a polygon. + const int tileBits = rdMin((int)rdIlog2(rdNextPow2(tw*th)), MIN_TILE_BITS); + const int polyBits = MAX_TILE_BITS - tileBits; maxTiles = 1 << tileBits; maxPolysPerTile = 1 << polyBits;