20 #include <OgreSceneNode.h>
21 #include <btBulletDynamicsCommon.h>
31 typedef std::pair<const btCollisionObject*, const btCollisionObject*>
CollisionPair;
32 typedef std::map<CollisionPair, std::function<void()>>
Triggers;
33 typedef std::shared_ptr<Physics>
shared;
36 const btScalar
PI = 3.14159265359;
41 Ogre::SceneNode* node,btCollisionShape* shape, btScalar mass);
44 btCollisionShape* shape, btScalar mass);
50 btCollisionShape*
create_shape(btVector3 coordinates, btScalar distance_to_origin);
61 void set_position(btRigidBody* body, btVector3 new_position);
65 btCollisionWorld::ClosestRayResultCallback
raytest(btVector3 position,
66 btVector3 next_destination);
67 void print_vector(std::string message, btVector3 vector3);
68 btVector3
rotate_vector(btVector3 vector, btVector3 axis, btScalar angle);
70 btScalar
get_angle(btVector3 origin, btVector3 destiny);
73 const btVector3
gravity_ = btVector3(0, -40, 0);
76 btSequentialImpulseConstraintSolver*
solver_;
void remove_rigid_body(btRigidBody *body)
Definition: physics.cpp:92
void clear_triggers()
Definition: physics.cpp:165
btCollisionWorld::ClosestRayResultCallback raytest(btVector3 position, btVector3 next_destination)
Definition: physics.cpp:182
btBroadphaseInterface * broadphase_
Definition: physics.h:75
Physics()
Definition: physics.cpp:20
btCollisionDispatcher * dispatcher_
Definition: physics.h:78
std::shared_ptr< Physics > shared
Definition: physics.h:33
btSequentialImpulseConstraintSolver * solver_
Definition: physics.h:76
void print_vector(std::string message, btVector3 vector3)
Definition: physics.cpp:190
btCollisionShape * create_shape(btVector3 halfExtent)
Definition: physics.cpp:97
const btScalar PI
Definition: physics.h:36
btVector3 rotate_vector(btVector3 vector, btVector3 axis, btScalar angle)
Definition: physics.cpp:198
void set_position(btRigidBody *body, btVector3 new_position)
Definition: physics.cpp:170
btScalar get_angle(btVector3 origin, btVector3 destiny)
Definition: physics.cpp:203
btDiscreteDynamicsWorld * dynamics_world_
Definition: physics.h:34
void load_mesh(std::string file)
btDefaultCollisionConfiguration * collision_configuration_
Definition: physics.h:77
virtual ~Physics()
Definition: physics.cpp:37
void add_collision_hooks(CollisionPair key, std::function< void()> callback)
Definition: physics.cpp:157
Triggers triggers_
Definition: physics.h:80
Shares vertices/indexes between Ogre and Bullet.
Definition: meshstrider.h:12
btRigidBody * create_rigid_body(const btTransform &world_transform, Ogre::SceneNode *node, btCollisionShape *shape, btScalar mass)
Definition: physics.cpp:46
void check_collision()
Definition: physics.cpp:136
float radians_to_angle(float radians)
Definition: physics.cpp:212
void set_transform(btRigidBody *body, btTransform transform)
Definition: physics.cpp:177
std::pair< const btCollisionObject *, const btCollisionObject * > CollisionPair
Definition: physics.h:31
void step_simulation(float deltaT, int maxSubSteps)
Definition: physics.cpp:130
float degree_to_radians(float degrees)
Definition: physics.cpp:217
btCompoundShape * create_compound_shape(btVector3 origin, btCollisionShape *child)
Definition: physics.cpp:118
const btVector3 gravity_
Definition: physics.h:73
std::map< CollisionPair, std::function< void()> > Triggers
Definition: physics.h:32
void add_rigid_body(btRigidBody *body_)
Definition: physics.cpp:87