|
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.
|
|
void | addKart (const AbstractKart *k) |
| Adds a kart to the physics engine.
|
|
void | addBody (btRigidBody *b) |
|
void | removeKart (const AbstractKart *k) |
| Removes a kart from the physics engine.
|
|
void | removeBody (btRigidBody *b) |
|
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 passed on.
|
|
void | update (int ticks) |
| Updates the physics simulation and handles all collisions.
|
|
void | draw () |
| A debug draw function to show the track and all karts.
|
|
STKDynamicsWorld * | getPhysicsWorld () const |
|
void | nextDebugMode () |
| Activates the next debug mode (or switches it off again).
|
|
void | setDebugMode (IrrDebugDrawer::DebugModeType mode) |
|
bool | isDebug () const |
| Returns true if the debug drawer is enabled.
|
|
IrrDebugDrawer * | getDebugDrawer () |
|
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.
|
|
|
static Physics * | get () |
|
static void | create () |
|
static void | destroy () |
|
|
bool | m_physics_loop_active |
| This flag is set while bullets time step processing is taking place.
|
|
std::vector< const AbstractKart * > | m_karts_to_delete |
| If kart need to be removed from the physics world while physics processing is taking place, store the pointers to the karts to be removed here, and remove them once the physics processing is finished.
|
|
STKDynamicsWorld * | m_dynamics_world |
| Pointer to the physics dynamics world.
|
|
IrrDebugDrawer * | m_debug_drawer |
| Used in physics debugging to draw the physics world.
|
|
btCollisionDispatcher * | m_dispatcher |
|
btBroadphaseInterface * | m_axis_sweep |
|
btDefaultCollisionConfiguration * | m_collision_conf |
|
CollisionList | m_all_collisions |
|
◆ Physics()
Initialise physics.
Create the bullet dynamics world.
◆ addKart()
Adds a kart to the physics engine.
This adds the rigid body and the vehicle but only if the kart is not already in the physics world.
- Parameters
-
kart | The kart to add. |
vehicle | The raycast vehicle object. |
◆ init()
void Physics::init |
( |
const Vec3 & |
world_min, |
|
|
const Vec3 & |
world_max |
|
) |
| |
The actual initialisation of the physics, which is called after the track model is loaded.
This allows the physics to use the actual track dimension for the axis sweep.
◆ KartKartCollision()
Handles the special case of two karts colliding with each other, which means that bombs must be passed on.
If both karts have a bomb, they'll explode immediately. This function is called from physics::update() on the server and if no networking is used, and from race_state on the client to replay what happened on the server.
- Parameters
-
kart_a | First kart involved in the collision. |
contact_point_a | Location of collision at first kart (in kart coordinates). |
kart_b | Second kart involved in the collision. |
contact_point_b | Location of collision at second kart (in kart coordinates). |
◆ removeKart()
Removes a kart from the physics engine.
This is used when rescuing a kart (and during cleanup).
- Parameters
-
◆ solveGroup()
btScalar Physics::solveGroup |
( |
btCollisionObject ** |
bodies, |
|
|
int |
numBodies, |
|
|
btPersistentManifold ** |
manifold, |
|
|
int |
numManifolds, |
|
|
btTypedConstraint ** |
constraints, |
|
|
int |
numConstraints, |
|
|
const btContactSolverInfo & |
info, |
|
|
btIDebugDraw * |
debugDrawer, |
|
|
btStackAlloc * |
stackAlloc, |
|
|
btDispatcher * |
dispatcher |
|
) |
| |
|
virtual |
This function is called at each internal bullet timestep.
It is used here to do the collision handling: using the contact manifolds after a physics time step might miss some collisions (when more than one internal time step was done, and the collision is added and removed). So this function stores all collisions in a list, which is then handled after the actual physics timestep. This list only stores a collision if it's not already in the list, so a collisions which is reported more than once is nevertheless only handled once. The list of collision Parameters: see bullet documentation for details.
◆ update()
void Physics::update |
( |
int |
ticks | ) |
|
Updates the physics simulation and handles all collisions.
- Parameters
-
ticks | Number of physics steps to simulate. |
◆ m_physics_loop_active
bool Physics::m_physics_loop_active |
|
private |
This flag is set while bullets time step processing is taking place.
It is used to avoid altering data structures that might be used (e.g. removing a kart while a loop over all karts is taking place, as can happen in collision handling).
The documentation for this class was generated from the following files: