Recast: use step height for the climb height parameter

The Hull_s::height field is actually Hull_s::stepHeight. This results in much better navigation and prevents entities "popping" into air as they shouldn't be able to walk over some obstacles.
This commit is contained in:
Kawe Mazidjatari 2024-10-19 12:45:12 +02:00
parent b28b167467
commit b3946e924a
2 changed files with 10 additions and 8 deletions

View File

@ -1221,11 +1221,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 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::Height(HULL_HUMAN) * NAI_Hull::Scale(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::Height(HULL_PROWLER) * NAI_Hull::Scale(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::Height(HULL_MEDIUM) * NAI_Hull::Scale(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::Height(HULL_TITAN) * NAI_Hull::Scale(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::Height(HULL_GOLIATH) * NAI_Hull::Scale(HULL_GOLIATH), 120, 2 },
{ 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 },
};
void Editor::selectNavMeshType(const NavMeshType_e navMeshType)

View File

@ -31,12 +31,12 @@ enum Hull_e
struct Hull_s
{
Hull_s(const char* pName, int bit, const Vector3D& _mins, const Vector3D& _maxs,
const float _height, const float _scale, const float _unk10, const float _unk11,
const float _stepHeight, const float _scale, const float _unk10, const float _unk11,
const unsigned int _traceMask, NavMeshType_e _navMeshType)
: hullName(pName), hullBit(bit)
, mins(_mins), maxs(_maxs)
, height(_height), scale(_scale)
, stepHeight(_stepHeight), scale(_scale)
, unk10(_unk10), unk11(_unk11)
, traceMask(_traceMask), navMeshType(_navMeshType) {}
@ -46,7 +46,7 @@ struct Hull_s
Vector3D mins;
Vector3D maxs;
float height; // IK Height?
float stepHeight;
float scale; // Some scale?
float unk10;
@ -100,6 +100,8 @@ namespace NAI_Hull
inline float Height(const Hull_e id) { return (g_aiHullProperties[id].maxs.z - g_aiHullProperties[id].mins.z); }
inline float Scale(const Hull_e id) { return g_aiHullProperties[id].scale; }
inline float StepHeight(const Hull_e id) { return g_aiHullProperties[id].stepHeight; }
inline int Bits(const Hull_e id) { return g_aiHullProperties[id].hullBit; }
inline const char* Name(const Hull_e id) { return g_aiHullProperties[id].hullName; }