1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-04 02:41:19 +00:00
OpenMW/apps/openmw/mwphysics/movementsolver.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

54 lines
1.5 KiB
C++
Raw Normal View History

2020-03-30 21:05:54 +00:00
#ifndef OPENMW_MWPHYSICS_MOVEMENTSOLVER_H
#define OPENMW_MWPHYSICS_MOVEMENTSOLVER_H
#include <osg/Vec3f>
#include <components/misc/constants.hpp>
2020-03-30 21:05:54 +00:00
class btCollisionWorld;
namespace MWWorld
{
class Ptr;
}
2020-03-30 21:05:54 +00:00
namespace MWPhysics
{
/// 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)
{
static const float sMaxSlopeCos = std::cos(osg::DegreesToRadians(Constants::sMaxSlope));
return (normal.z() > sMaxSlopeCos);
}
2020-03-30 21:05:54 +00:00
class Actor;
struct ActorFrameData;
struct ProjectileFrameData;
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);
static void move(
ActorFrameData& actor, float time, const btCollisionWorld* collisionWorld, const WorldFrameData& worldData);
static void move(ProjectileFrameData& projectile, float time, const btCollisionWorld* collisionWorld);
static void unstuck(ActorFrameData& actor, const btCollisionWorld* collisionWorld);
2020-03-30 21:05:54 +00:00
};
}
#endif