2022-06-14 23:09:33 +00:00
|
|
|
#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_RECASTPARAMS_H
|
|
|
|
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_RECASTPARAMS_H
|
|
|
|
|
2022-06-16 22:28:44 +00:00
|
|
|
#include "agentbounds.hpp"
|
|
|
|
|
2022-06-14 23:09:33 +00:00
|
|
|
#include <osg/Vec3f>
|
|
|
|
|
2022-06-16 22:28:44 +00:00
|
|
|
#include <algorithm>
|
|
|
|
#include <cassert>
|
2022-06-14 23:09:33 +00:00
|
|
|
#include <cmath>
|
|
|
|
|
|
|
|
namespace DetourNavigator
|
|
|
|
{
|
2022-06-16 22:28:44 +00:00
|
|
|
inline float getAgentHeight(const AgentBounds& agentBounds)
|
2022-06-14 23:09:33 +00:00
|
|
|
{
|
2022-06-16 22:28:44 +00:00
|
|
|
return 2.0f * agentBounds.mHalfExtents.z();
|
2022-06-14 23:09:33 +00:00
|
|
|
}
|
|
|
|
|
2022-06-16 22:28:44 +00:00
|
|
|
inline float getAgentRadius(const AgentBounds& agentBounds)
|
2022-06-14 23:09:33 +00:00
|
|
|
{
|
2022-06-16 22:28:44 +00:00
|
|
|
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();
|
2022-06-03 22:44:42 +00:00
|
|
|
case CollisionShapeType::Cylinder:
|
|
|
|
return std::max(agentBounds.mHalfExtents.x(), agentBounds.mHalfExtents.y());
|
2022-06-16 22:28:44 +00:00
|
|
|
}
|
|
|
|
assert(false && "Unsupported agent shape type");
|
|
|
|
return 0;
|
2022-06-14 23:09:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|