ChangeObjectLayerTest.h 971 B

12345678910111213141516171819202122232425262728293031
  1. // SPDX-FileCopyrightText: 2021 Jorrit Rouwe
  2. // SPDX-License-Identifier: MIT
  3. #pragma once
  4. #include <Tests/Test.h>
  5. #include <Jolt/Physics/Body/BodyID.h>
  6. // This test will demonstrates how to use layers to disable collisions between other objects and how to change them on the fly.
  7. // The bodies will switch between the MOVING layer and the DEBRIS layer (debris only collides with static).
  8. class ChangeObjectLayerTest : public Test
  9. {
  10. public:
  11. JPH_DECLARE_RTTI_VIRTUAL(ChangeObjectLayerTest)
  12. // Initialize the test
  13. virtual void Initialize() override;
  14. // Update the test, called before the physics update
  15. virtual void PrePhysicsUpdate(const PreUpdateParams &inParams) override;
  16. // Saving / restoring state for replay
  17. virtual void SaveState(StateRecorder &inStream) const override;
  18. virtual void RestoreState(StateRecorder &inStream) override;
  19. private:
  20. BodyID mMoving;
  21. BodyIDVector mDebris;
  22. bool mIsDebris = true;
  23. float mTime = 0.0f;
  24. };