Add internal physics tick callback methods in EventListener class

This commit is contained in:
Daniel Chappuis 2015-01-20 22:17:40 +01:00
parent 9f4e63361f
commit 68958d0ed1
2 changed files with 17 additions and 0 deletions

View File

@ -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

View File

@ -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() {}
};
}