ChangeShapeTest.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  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. #include <Jolt/Physics/Collision/Shape/Shape.h>
  7. // This test will make a dynamic body cyle through various shapes
  8. class ChangeShapeTest : public Test
  9. {
  10. public:
  11. JPH_DECLARE_RTTI_VIRTUAL(ChangeShapeTest)
  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. // Optional settings menu
  20. virtual bool HasSettingsMenu() const override { return true; }
  21. virtual void CreateSettingsMenu(DebugUI *inUI, UIElement *inSubMenu) override;
  22. private:
  23. bool mActivateAfterSwitch = true;
  24. BodyID mBodyID;
  25. Array<RefConst<Shape>> mShapes;
  26. float mTime = 0.0f;
  27. int mShapeIdx = 0;
  28. };