diff --git a/src/engine/DynamicsWorld.cpp b/src/engine/DynamicsWorld.cpp index 80d8c7cd..9de4e16d 100644 --- a/src/engine/DynamicsWorld.cpp +++ b/src/engine/DynamicsWorld.cpp @@ -229,6 +229,9 @@ void DynamicsWorld::updateBodiesState() { // Update the broad-phase state of the body bodies[b]->updateBroadPhaseState(); + + // Notify the event listener that the body has been updated + if (mEventListener != nullptr) { mEventListener->rigidBodyUpdated(bodies[b]); } } } } diff --git a/src/engine/EventListener.h b/src/engine/EventListener.h index 59533959..63ceca92 100644 --- a/src/engine/EventListener.h +++ b/src/engine/EventListener.h @@ -66,6 +66,11 @@ class EventListener { /// engine will do several internal simulation steps. This method is /// called at the end of each internal simulation step. virtual void endInternalTick() {} + + /// Called every time a RigidBody is updated as part of the + /// DynamicsWorld::update() step. The pointer provided as a parameter + /// to this function is the RigidBody that has been updated. + virtual void rigidBodyUpdated(const RigidBody* body) {} }; }