mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-05 15:55:45 +00:00
1a12c453d6
Actors may have different collision shapes. Currently there are axis-aligned bounding boxes and rotating bounding boxes. With AABB it's required to use bounding cylinder for navmesh agent to avoid providing paths where actor can't pass. But for rotating bounding boxes cylinder with diameter equal to the front face width should be used to not reduce of available paths. For example rats have rotating bounding box as collision shape because of the difference between front and side faces width. * Add agent bounds to navmesh tile db cache key. This is required to distinguish tiles for agents with different bounds. * Increase navmesh version because navmesh tile db cache key and data has changed. * Move navmesh version to the code to avoid misconfiguration by users. * Fix all places where wrong half extents were used for pathfinding.
34 lines
855 B
C++
34 lines
855 B
C++
#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_RECASTPARAMS_H
|
|
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_RECASTPARAMS_H
|
|
|
|
#include "agentbounds.hpp"
|
|
|
|
#include <osg/Vec3f>
|
|
|
|
#include <cassert>
|
|
#include <cmath>
|
|
#include <algorithm>
|
|
|
|
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();
|
|
}
|
|
assert(false && "Unsupported agent shape type");
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
#endif
|