1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2024-12-31 18:15:01 +00:00
OpenMW/components/detournavigator/recastparams.hpp
2022-09-22 21:35:26 +03:00

36 lines
995 B
C++

#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_RECASTPARAMS_H
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_RECASTPARAMS_H
#include "agentbounds.hpp"
#include <osg/Vec3f>
#include <algorithm>
#include <cassert>
#include <cmath>
namespace DetourNavigator
{
inline float getAgentHeight(const AgentBounds& agentBounds)
{
return 2.0f * agentBounds.mHalfExtents.z();
}
inline float getAgentRadius(const AgentBounds& agentBounds)
{
switch (agentBounds.mShapeType)
{
case CollisionShapeType::Aabb:
return std::max(agentBounds.mHalfExtents.x(), agentBounds.mHalfExtents.y()) * std::sqrt(2);
case CollisionShapeType::RotatingBox:
return agentBounds.mHalfExtents.x();
case CollisionShapeType::Cylinder:
return std::max(agentBounds.mHalfExtents.x(), agentBounds.mHalfExtents.y());
}
assert(false && "Unsupported agent shape type");
return 0;
}
}
#endif