diff --git a/src/engine/DynamicsWorld.cpp b/src/engine/DynamicsWorld.cpp index 3ade5ce2..15e9c344 100644 --- a/src/engine/DynamicsWorld.cpp +++ b/src/engine/DynamicsWorld.cpp @@ -107,6 +107,9 @@ void DynamicsWorld::update() { // While the time accumulator is not empty while(mTimer.isPossibleToTakeStep()) { + // Notify the event listener about the beginning of an internal tick + if (mEventListener != NULL) mEventListener->beginInternalTick(); + // Reset all the contact manifolds lists of each body resetContactManifoldListsOfBodies(); @@ -135,6 +138,9 @@ void DynamicsWorld::update() { updateBodiesState(); if (mIsSleepingEnabled) updateSleepingBodies(); + + // Notify the event listener about the end of an internal tick + if (mEventListener != NULL) mEventListener->endInternalTick(); } // Reset the external force and torque applied to the bodies diff --git a/src/engine/EventListener.h b/src/engine/EventListener.h index 2e17710f..1a8fca05 100644 --- a/src/engine/EventListener.h +++ b/src/engine/EventListener.h @@ -55,6 +55,17 @@ class EventListener { /// Called when a new contact point is found between two bodies virtual void newContact(const ContactPointInfo& contact) {} + /// Called at the beginning of an internal tick of the simulation step. + /// Each time the DynamicsWorld::update() method is called, the physics + /// engine will do several internal simulation steps. This method is + /// called at the beginning of each internal simulation step. + virtual void beginInternalTick() {} + + /// Called at the end of an internal tick of the simulation step. + /// Each time the DynamicsWorld::update() metho is called, the physics + /// engine will do several internal simulation steps. This method is + /// called at the end of each internal simulation step. + virtual void endInternalTick() {} }; }