1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-08 09:37:53 +00:00
OpenMW/apps/openmw/mwphysics/movementsolver.hpp
fredzio 91b3926a49 We need to update the collision world after each step.
Change order of traversal simulation step to make it rare enough to be parallelizable

Before:
for actor in actors:
    repeat numstep:
        solve(actor)
After:
repeat numstep:
    for actor in actors:
        solve(actor)

Introduce struct ActorFrameData to pack all data that is necessary for
the solver
2020-10-15 06:41:22 +02:00

44 lines
1.1 KiB
C++

#ifndef OPENMW_MWPHYSICS_MOVEMENTSOLVER_H
#define OPENMW_MWPHYSICS_MOVEMENTSOLVER_H
#include <map>
#include <osg/Vec3f>
class btCollisionWorld;
namespace MWWorld
{
class Ptr;
}
namespace MWPhysics
{
class Actor;
struct ActorFrameData;
struct WorldFrameData;
class MovementSolver
{
private:
///Project a vector u on another vector v
static inline osg::Vec3f project(const osg::Vec3f& u, const osg::Vec3f &v)
{
return v * (u * v);
// ^ dot product
}
///Helper for computing the character sliding
static inline osg::Vec3f slide(const osg::Vec3f& direction, const osg::Vec3f &planeNormal)
{
return direction - project(direction, planeNormal);
}
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, WorldFrameData& worldData);
};
}
#endif