19 #ifndef HEADER_PHYSICS_HPP
20 #define HEADER_PHYSICS_HPP
30 #include "btBulletDynamicsCommon.h"
32 #include "physics/irr_debug_drawer.hpp"
33 #include "physics/stk_dynamics_world.hpp"
34 #include "physics/user_pointer.hpp"
43 class Physics :
public btSequentialImpulseConstraintSolver
69 const UserPointer *b,
const btVector3 &contact_point_b)
71 if(a->is(UserPointer::UP_KART) &&
72 b->is(UserPointer::UP_KART) && a>b) {
89 const UserPointer *getUserPointer(
unsigned int n)
const
112 for(iterator i=begin(); i!=end(); i++) {
115 std::vector<CollisionPair>::push_back(p);
120 const UserPointer *b,
const btVector3 &contact_point_b)
122 push_back(
CollisionPair(a, contact_point_a, b, contact_point_b));
145 btCollisionDispatcher *m_dispatcher;
146 btBroadphaseInterface *m_axis_sweep;
147 btDefaultCollisionConfiguration *m_collision_conf;
157 static void create();
159 static void destroy();
161 void init (
const Vec3 &min_world,
const Vec3 &max_world);
179 virtual btScalar
solveGroup(btCollisionObject** bodies,
int numBodies,
180 btPersistentManifold** manifold,
int numManifolds,
181 btTypedConstraint** constraints,
int numConstraints,
182 const btContactSolverInfo& info,
183 btIDebugDraw* debugDrawer, btStackAlloc* stackAlloc,
184 btDispatcher* dispatcher);
187 #endif // HEADER_PHYSICS_HPP
void nextDebugMode()
Activates the next debug mode, or switches the mode off again.
Definition: irr_debug_drawer.cpp:37
void nextDebugMode()
Activates the next debug mode (or switches it off again).
Definition: physics.hpp:174
Definition: physics.hpp:108
CollisionPair(const UserPointer *a, const btVector3 &contact_point_a, const UserPointer *b, const btVector3 &contact_point_b)
The entries in Collision Pairs are sorted: if a projectile is included, it's always 'a'.
Definition: physics.hpp:68
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:62
Definition: irr_debug_drawer.hpp:33
void update(int ticks)
Updates the physics simulation and handles all collisions.
Definition: physics.cpp:177
const UserPointer * m_up[2]
The user pointer of the objects involved in this collision.
Definition: physics.hpp:60
Definition: physics.hpp:44
void draw()
A debug draw function to show the track and all karts.
Definition: physics.cpp:765
A UserPointer is stored as a user pointer in all bullet bodies.
Definition: user_pointer.hpp:36
void removeKart(const AbstractKart *k)
Removes a kart from the physics engine.
Definition: physics.cpp:150
void addKart(const AbstractKart *k)
Adds a kart to the physics engine.
Definition: physics.cpp:132
Physics()
Initialise physics.
Definition: physics.cpp:76
DebugModeType
The drawing mode to use: If bit 0 is set, draw the bullet collision shape of karts If bit 1 is set,...
Definition: irr_debug_drawer.hpp:39
A wrapper around bullets btVector3 to include conventient conversion functions (e....
Definition: vec3.hpp:35
const Vec3 & getContactPointCS(unsigned int n) const
Returns the contact point of the collision in car (local) coordinates.
Definition: physics.hpp:97
void KartKartCollision(AbstractKart *ka, const Vec3 &contact_point_a, AbstractKart *kb, const Vec3 &contact_point_b)
Handles the special case of two karts colliding with each other, which means that bombs must be passe...
Definition: physics.cpp:436
Bullet can report the same collision more than once (up to 4 contact points per collision.
Definition: physics.hpp:57
bool isDebug() const
Returns true if the debug drawer is enabled.
Definition: physics.hpp:177
A thin wrapper around bullet's btDiscreteDynamicsWorld.
Definition: stk_dynamics_world.hpp:29
void push_back(const UserPointer *a, const btVector3 &contact_point_a, const UserPointer *b, const btVector3 &contact_point_b)
Adds information about a collision to this vector.
Definition: physics.hpp:119
bool m_physics_loop_active
This flag is set while bullets time step processing is taking place.
Definition: physics.hpp:131
virtual btScalar solveGroup(btCollisionObject **bodies, int numBodies, btPersistentManifold **manifold, int numManifolds, btTypedConstraint **constraints, int numConstraints, const btContactSolverInfo &info, btIDebugDraw *debugDrawer, btStackAlloc *stackAlloc, btDispatcher *dispatcher)
This function is called at each internal bullet timestep.
Definition: physics.cpp:570
void init(const Vec3 &min_world, const Vec3 &max_world)
The actual initialisation of the physics, which is called after the track model is loaded.
Definition: physics.cpp:87
IrrDebugDrawer * m_debug_drawer
Used in physics debugging to draw the physics world.
Definition: physics.hpp:143
bool debugEnabled() const
Returns true if debug mode is enabled.
Definition: irr_debug_drawer.hpp:73
Vec3 m_contact_point[2]
The contact point for each object (in local coordincates).
Definition: physics.hpp:63
STKDynamicsWorld * m_dynamics_world
Pointer to the physics dynamics world.
Definition: physics.hpp:140
bool operator==(const CollisionPair &p)
Tests if two collision pairs involve the same objects.
Definition: physics.hpp:84
std::vector< const AbstractKart * > m_karts_to_delete
If kart need to be removed from the physics world while physics processing is taking place,...
Definition: physics.hpp:137