2
0

ChangeObjectLayerTest.h 1.0 KB

1234567891011121314151617181920212223242526272829303132
  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. // This test will demonstrates how to use layers to disable collisions between other objects and how to change them on the fly.
  8. // The bodies will switch between the MOVING layer and the DEBRIS layer (debris only collides with static).
  9. class ChangeObjectLayerTest : public Test
  10. {
  11. public:
  12. JPH_DECLARE_RTTI_VIRTUAL(JPH_NO_EXPORT, ChangeObjectLayerTest)
  13. // Initialize the test
  14. virtual void Initialize() override;
  15. // Update the test, called before the physics update
  16. virtual void PrePhysicsUpdate(const PreUpdateParams &inParams) override;
  17. // Saving / restoring state for replay
  18. virtual void SaveState(StateRecorder &inStream) const override;
  19. virtual void RestoreState(StateRecorder &inStream) override;
  20. private:
  21. BodyID mMoving;
  22. BodyIDVector mDebris;
  23. bool mIsDebris = true;
  24. float mTime = 0.0f;
  25. };