ChangeShapeTest.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. class ChangeShapeTest : public Test
  9. {
  10. public:
  11. JPH_DECLARE_RTTI_VIRTUAL(JPH_NO_EXPORT, ChangeShapeTest)
  12. // Description of the test
  13. virtual const char * GetDescription() const override
  14. {
  15. return "Demonstrates how to dynamically update the shape of a body.";
  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. // Optional settings menu
  25. virtual bool HasSettingsMenu() const override { return true; }
  26. virtual void CreateSettingsMenu(DebugUI *inUI, UIElement *inSubMenu) override;
  27. private:
  28. bool mActivateAfterSwitch = true;
  29. BodyID mBodyID;
  30. Array<RefConst<Shape>> mShapes;
  31. float mTime = 0.0f;
  32. int mShapeIdx = 0;
  33. };