From 890f6a3f971d719171bfba5e17381caa60c11a46 Mon Sep 17 00:00:00 2001 From: Matthew-TC <18335242+MattMorphic@users.noreply.github.com> Date: Tue, 19 May 2020 12:45:55 +0100 Subject: [PATCH] Add rigidBodyUpdated function to EventListener --- src/engine/DynamicsWorld.cpp | 3 +++ src/engine/EventListener.h | 5 +++++ 2 files changed, 8 insertions(+) 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) {} }; }