From e69e960c78a288918023aff547b1b51dcaafaf1c Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Thu, 31 Oct 2024 12:42:32 +0100 Subject: [PATCH] Recast: increase the cell size rather than the tile size for large navmeshes Use a cell size of 15 instead for navmeshes used for titans and goliaths (_large and _extra_large). This value results in identical values with Titanfall 2 regarding bounding volume quantization factors. --- src/naveditor/Editor.cpp | 20 ++++++++++---------- src/naveditor/Editor_TileMesh.cpp | 5 +++-- src/naveditor/include/Editor.h | 8 ++++---- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/naveditor/Editor.cpp b/src/naveditor/Editor.cpp index 35614cab..a9e6b0b6 100644 --- a/src/naveditor/Editor.cpp +++ b/src/naveditor/Editor.cpp @@ -270,7 +270,7 @@ void Editor::resetCommonSettings() m_minTileBits = 16; m_maxTileBits = 28; #endif - + m_tileSize = 64; m_cellSize = 8.0f; m_cellHeight = 9.0f; m_traverseLinkDrawParams.dynamicOffset = m_traverseRayDynamicOffset; @@ -1245,24 +1245,24 @@ void Editor::renderTraverseTableFineTuners() // NOTE: the climb height should never equal or exceed the agent's height, see https://groups.google.com/g/recastnavigation/c/L5rBamxcOBk/m/5xGLj6YP25kJ // Quote: "you will get into trouble in cases where there is an overhand which is low enough to step over and high enough for the agent to walk under." -const hulldef hulls[NAVMESH_COUNT] = { - { g_navMeshNames[NAVMESH_SMALL] , NAI_Hull::Width(HULL_HUMAN) * NAI_Hull::Scale(HULL_HUMAN) , NAI_Hull::Height(HULL_HUMAN) , NAI_Hull::StepHeight(HULL_HUMAN) , 64, 8 }, - { g_navMeshNames[NAVMESH_MED_SHORT] , NAI_Hull::Width(HULL_PROWLER) * NAI_Hull::Scale(HULL_PROWLER), NAI_Hull::Height(HULL_PROWLER), NAI_Hull::StepHeight(HULL_PROWLER), 64, 4 }, - { g_navMeshNames[NAVMESH_MEDIUM] , NAI_Hull::Width(HULL_MEDIUM) * NAI_Hull::Scale(HULL_MEDIUM) , NAI_Hull::Height(HULL_MEDIUM) , NAI_Hull::StepHeight(HULL_MEDIUM) , 64, 4 }, - { g_navMeshNames[NAVMESH_LARGE] , NAI_Hull::Width(HULL_TITAN) * NAI_Hull::Scale(HULL_TITAN) , NAI_Hull::Height(HULL_TITAN) , NAI_Hull::StepHeight(HULL_TITAN) , 120, 2 }, - { g_navMeshNames[NAVMESH_EXTRA_LARGE], NAI_Hull::Width(HULL_GOLIATH) * NAI_Hull::Scale(HULL_GOLIATH), NAI_Hull::Height(HULL_GOLIATH), NAI_Hull::StepHeight(HULL_GOLIATH), 120, 2 }, +const NavMeshDefaults_s g_navMeshDefaults[NAVMESH_COUNT] = { + { g_navMeshNames[NAVMESH_SMALL] , NAI_Hull::Width(HULL_HUMAN) * NAI_Hull::Scale(HULL_HUMAN) , NAI_Hull::Height(HULL_HUMAN) , NAI_Hull::StepHeight(HULL_HUMAN) , 8, 8 }, + { g_navMeshNames[NAVMESH_MED_SHORT] , NAI_Hull::Width(HULL_PROWLER) * NAI_Hull::Scale(HULL_PROWLER), NAI_Hull::Height(HULL_PROWLER), NAI_Hull::StepHeight(HULL_PROWLER), 8, 4 }, + { g_navMeshNames[NAVMESH_MEDIUM] , NAI_Hull::Width(HULL_MEDIUM) * NAI_Hull::Scale(HULL_MEDIUM) , NAI_Hull::Height(HULL_MEDIUM) , NAI_Hull::StepHeight(HULL_MEDIUM) , 8, 4 }, + { g_navMeshNames[NAVMESH_LARGE] , NAI_Hull::Width(HULL_TITAN) * NAI_Hull::Scale(HULL_TITAN) , NAI_Hull::Height(HULL_TITAN) , NAI_Hull::StepHeight(HULL_TITAN) , 15, 2 }, + { g_navMeshNames[NAVMESH_EXTRA_LARGE], NAI_Hull::Width(HULL_GOLIATH) * NAI_Hull::Scale(HULL_GOLIATH), NAI_Hull::Height(HULL_GOLIATH), NAI_Hull::StepHeight(HULL_GOLIATH), 15, 2 }, }; void Editor::selectNavMeshType(const NavMeshType_e navMeshType) { - const hulldef& h = hulls[navMeshType]; + const NavMeshDefaults_s& h = g_navMeshDefaults[navMeshType]; m_agentRadius = h.radius; m_agentMaxClimb = h.climbHeight; m_agentHeight = h.height; m_navmeshName = h.name; - m_tileSize = h.tileSize; - m_polyCellRes = h.cellResolution; + m_cellSize = h.cellSize; + m_polyCellRes = h.polyCellResolution; m_selectedNavMeshType = navMeshType; } diff --git a/src/naveditor/Editor_TileMesh.cpp b/src/naveditor/Editor_TileMesh.cpp index 265e5cd6..b5ae3c8d 100644 --- a/src/naveditor/Editor_TileMesh.cpp +++ b/src/naveditor/Editor_TileMesh.cpp @@ -911,13 +911,14 @@ void Editor_TileMesh::removeAllTiles() void Editor_TileMesh::buildAllHulls() { - for (const hulldef& h : hulls) + for (const NavMeshDefaults_s& h : g_navMeshDefaults) { m_agentRadius = h.radius; m_agentMaxClimb = h.climbHeight; m_agentHeight = h.height; m_navmeshName = h.name; - m_tileSize = h.tileSize; + m_cellSize = h.cellSize; + m_polyCellRes = h.polyCellResolution; m_ctx->resetLog(); diff --git a/src/naveditor/include/Editor.h b/src/naveditor/include/Editor.h index 65c1d5bc..cbd07e16 100644 --- a/src/naveditor/include/Editor.h +++ b/src/naveditor/include/Editor.h @@ -30,16 +30,16 @@ struct dtMeshTile; -struct hulldef +struct NavMeshDefaults_s { const char* name; float radius; float height; float climbHeight; - int tileSize; - int cellResolution; + float cellSize; + int polyCellResolution; }; -extern const hulldef hulls[5]; +extern const NavMeshDefaults_s g_navMeshDefaults[NAVMESH_COUNT]; struct TraverseType_s {