From 62f7b04f5a3c650e92ad6ecd9089d835ad8c7e00 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Wed, 13 Nov 2024 13:56:51 +0100 Subject: [PATCH] Recast: use actual hull width for walkableRadius The NavMesh must be build with the actual radius and not its scaled extents. Titanfall 2 single-player NavMesh tile headers confirmed this. Also added a getter for the hull's radius. --- src/naveditor/Editor.cpp | 10 +++++----- src/public/game/server/ai_hull.h | 5 ++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/naveditor/Editor.cpp b/src/naveditor/Editor.cpp index 03bf1e83..d1271ba8 100644 --- a/src/naveditor/Editor.cpp +++ b/src/naveditor/Editor.cpp @@ -1401,11 +1401,11 @@ 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 NavMeshDefaults_s g_navMeshDefaults[NAVMESH_COUNT] = { - { g_navMeshNames[NAVMESH_SMALL] , NAI_Hull::Width(HULL_HUMAN) * NAI_Hull::ExtentScale(HULL_HUMAN) , NAI_Hull::Height(HULL_HUMAN) , NAI_Hull::StepHeight(HULL_HUMAN) , 8.f, 4.f, 16 }, - { g_navMeshNames[NAVMESH_MED_SHORT] , NAI_Hull::Width(HULL_PROWLER) * NAI_Hull::ExtentScale(HULL_PROWLER), NAI_Hull::Height(HULL_PROWLER), NAI_Hull::StepHeight(HULL_PROWLER), 8.f, 4.f, 8 }, - { g_navMeshNames[NAVMESH_MEDIUM] , NAI_Hull::Width(HULL_MEDIUM) * NAI_Hull::ExtentScale(HULL_MEDIUM) , NAI_Hull::Height(HULL_MEDIUM) , NAI_Hull::StepHeight(HULL_MEDIUM) , 8.f, 4.f, 8 }, - { g_navMeshNames[NAVMESH_LARGE] , NAI_Hull::Width(HULL_TITAN) * NAI_Hull::ExtentScale(HULL_TITAN) , NAI_Hull::Height(HULL_TITAN) , NAI_Hull::StepHeight(HULL_TITAN) , 15.f, 7.5f, 4 }, - { g_navMeshNames[NAVMESH_EXTRA_LARGE], NAI_Hull::Width(HULL_GOLIATH) * NAI_Hull::ExtentScale(HULL_GOLIATH), NAI_Hull::Height(HULL_GOLIATH), NAI_Hull::StepHeight(HULL_GOLIATH), 15.f, 7.5f, 4 }, + { g_navMeshNames[NAVMESH_SMALL] , NAI_Hull::Radius(HULL_HUMAN) , NAI_Hull::Height(HULL_HUMAN) , NAI_Hull::StepHeight(HULL_HUMAN) , 8.f, 4.f, 16 }, + { g_navMeshNames[NAVMESH_MED_SHORT] , NAI_Hull::Radius(HULL_PROWLER), NAI_Hull::Height(HULL_PROWLER), NAI_Hull::StepHeight(HULL_PROWLER), 8.f, 4.f, 8 }, + { g_navMeshNames[NAVMESH_MEDIUM] , NAI_Hull::Radius(HULL_MEDIUM) , NAI_Hull::Height(HULL_MEDIUM) , NAI_Hull::StepHeight(HULL_MEDIUM) , 8.f, 4.f, 8 }, + { g_navMeshNames[NAVMESH_LARGE] , NAI_Hull::Radius(HULL_TITAN) , NAI_Hull::Height(HULL_TITAN) , NAI_Hull::StepHeight(HULL_TITAN) , 15.f, 7.5f, 4 }, + { g_navMeshNames[NAVMESH_EXTRA_LARGE], NAI_Hull::Radius(HULL_GOLIATH), NAI_Hull::Height(HULL_GOLIATH), NAI_Hull::StepHeight(HULL_GOLIATH), 15.f, 7.5f, 4 }, }; void Editor::selectNavMeshType(const NavMeshType_e navMeshType) diff --git a/src/public/game/server/ai_hull.h b/src/public/game/server/ai_hull.h index fa7858ca..3bca97a5 100644 --- a/src/public/game/server/ai_hull.h +++ b/src/public/game/server/ai_hull.h @@ -53,9 +53,7 @@ struct Hull_s // The scale to apply to the hull size // when using it as extents to query a - // point on the navmesh. This should - // also be used on the radius of the - // hull when building the navmesh. + // point on the navmesh. float extentScale; float unk10; @@ -107,6 +105,7 @@ namespace NAI_Hull inline float Length(const Hull_e id) { return (g_aiHullProperties[id].maxs.x - g_aiHullProperties[id].mins.x); } inline float Width(const Hull_e id) { return (g_aiHullProperties[id].maxs.y - g_aiHullProperties[id].mins.y); } inline float Height(const Hull_e id) { return (g_aiHullProperties[id].maxs.z - g_aiHullProperties[id].mins.z); } + inline float Radius(const Hull_e id) { return Width(id) * 0.5f; } inline float StepHeight(const Hull_e id) { return g_aiHullProperties[id].stepHeight; } inline float ExtentScale(const Hull_e id) { return g_aiHullProperties[id].extentScale; }