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.
This commit is contained in:
Kawe Mazidjatari 2024-11-13 13:56:51 +01:00
parent a6958dcee7
commit 62f7b04f5a
2 changed files with 7 additions and 8 deletions

View File

@ -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)

View File

@ -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; }