2020-03-30 21:05:54 +00:00
|
|
|
#ifndef OPENMW_MWPHYSICS_MOVEMENTSOLVER_H
|
|
|
|
#define OPENMW_MWPHYSICS_MOVEMENTSOLVER_H
|
|
|
|
|
|
|
|
#include <osg/Vec3f>
|
|
|
|
|
2021-07-03 02:09:55 +00:00
|
|
|
#include <components/misc/constants.hpp>
|
|
|
|
|
2020-03-30 21:05:54 +00:00
|
|
|
class btCollisionWorld;
|
|
|
|
|
2020-10-15 04:11:00 +00:00
|
|
|
namespace MWWorld
|
|
|
|
{
|
|
|
|
class Ptr;
|
|
|
|
}
|
|
|
|
|
2020-03-30 21:05:54 +00:00
|
|
|
namespace MWPhysics
|
|
|
|
{
|
2020-12-27 22:16:11 +00:00
|
|
|
/// Vector projection
|
|
|
|
static inline osg::Vec3f project(const osg::Vec3f& u, const osg::Vec3f& v)
|
|
|
|
{
|
|
|
|
return v * (u * v);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Vector rejection
|
|
|
|
static inline osg::Vec3f reject(const osg::Vec3f& direction, const osg::Vec3f& planeNormal)
|
|
|
|
{
|
|
|
|
return direction - project(direction, planeNormal);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Vec3>
|
|
|
|
static bool isWalkableSlope(const Vec3& normal)
|
|
|
|
{
|
2021-07-03 02:09:55 +00:00
|
|
|
static const float sMaxSlopeCos = std::cos(osg::DegreesToRadians(Constants::sMaxSlope));
|
2020-12-27 22:16:11 +00:00
|
|
|
return (normal.z() > sMaxSlopeCos);
|
|
|
|
}
|
|
|
|
|
2020-03-30 21:05:54 +00:00
|
|
|
class Actor;
|
2020-10-15 04:11:00 +00:00
|
|
|
struct ActorFrameData;
|
2021-10-09 16:16:29 +00:00
|
|
|
struct ProjectileFrameData;
|
2020-10-15 04:11:00 +00:00
|
|
|
struct WorldFrameData;
|
2020-03-30 21:05:54 +00:00
|
|
|
|
|
|
|
class MovementSolver
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static osg::Vec3f traceDown(const MWWorld::Ptr& ptr, const osg::Vec3f& position, Actor* actor,
|
|
|
|
btCollisionWorld* collisionWorld, float maxHeight);
|
2021-10-07 19:47:05 +00:00
|
|
|
static void move(
|
|
|
|
ActorFrameData& actor, float time, const btCollisionWorld* collisionWorld, const WorldFrameData& worldData);
|
2021-10-09 16:16:29 +00:00
|
|
|
static void move(ProjectileFrameData& projectile, float time, const btCollisionWorld* collisionWorld);
|
2020-12-27 22:16:11 +00:00
|
|
|
static void unstuck(ActorFrameData& actor, const btCollisionWorld* collisionWorld);
|
2020-03-30 21:05:54 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|