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