PhysicsStepListener.h 878 B

123456789101112131415161718192021222324
  1. // SPDX-FileCopyrightText: 2021 Jorrit Rouwe
  2. // SPDX-License-Identifier: MIT
  3. #pragma once
  4. namespace JPH {
  5. class PhysicsSystem;
  6. /// A listener class that receives a callback before every physics simulation step
  7. class PhysicsStepListener
  8. {
  9. public:
  10. /// Ensure virtual destructor
  11. virtual ~PhysicsStepListener() = default;
  12. /// Called before every simulation step (received inCollisionSteps times for every PhysicsSystem::Update(...) call)
  13. /// This is called while all bodies and constraints are locked for modifications. Multiple listeners can be executed in parallel and it is the responsibility of the listener
  14. /// to avoid race conditions.
  15. /// Note that this function is not called if there aren't any active bodies or when the physics system is updated with 0 delta time.
  16. virtual void OnStep(float inDeltaTime, PhysicsSystem &inPhysicsSystem) = 0;
  17. };
  18. } // JPH