ChangeObjectLayerTest.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
  2. // SPDX-FileCopyrightText: 2021 Jorrit Rouwe
  3. // SPDX-License-Identifier: MIT
  4. #pragma once
  5. #include <Tests/Test.h>
  6. #include <Jolt/Physics/Body/BodyID.h>
  7. class ChangeObjectLayerTest : public Test
  8. {
  9. public:
  10. JPH_DECLARE_RTTI_VIRTUAL(JPH_NO_EXPORT, ChangeObjectLayerTest)
  11. // Description of the test
  12. virtual const char * GetDescription() const override
  13. {
  14. return "Demonstrates how to use layers to disable collisions with other objects and how to change layers on the fly.\n"
  15. "The small cubes will switch between the MOVING layer and the DEBRIS layer (debris only collides with the static floor).";
  16. }
  17. // Initialize the test
  18. virtual void Initialize() override;
  19. // Update the test, called before the physics update
  20. virtual void PrePhysicsUpdate(const PreUpdateParams &inParams) override;
  21. // Saving / restoring state for replay
  22. virtual void SaveState(StateRecorder &inStream) const override;
  23. virtual void RestoreState(StateRecorder &inStream) override;
  24. private:
  25. BodyID mMoving;
  26. BodyIDVector mDebris;
  27. bool mIsDebris = true;
  28. float mTime = 0.0f;
  29. };