ConstraintVsCOMChangeTest.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
  2. // SPDX-FileCopyrightText: 2023 Jorrit Rouwe
  3. // SPDX-License-Identifier: MIT
  4. #pragma once
  5. #include <Tests/Test.h>
  6. class ConstraintVsCOMChangeTest : public Test
  7. {
  8. public:
  9. JPH_DECLARE_RTTI_VIRTUAL(JPH_NO_EXPORT, ConstraintVsCOMChangeTest)
  10. // Description of the test
  11. virtual const char * GetDescription() const override
  12. {
  13. return "This test demonstrates how to notify a constraint that the center of mass of a body changed.\n"
  14. "Constraints store their attachment points in center of mass space.";
  15. }
  16. // See: Test
  17. virtual void Initialize() override;
  18. virtual void PrePhysicsUpdate(const PreUpdateParams& inParams) override;
  19. virtual void SaveState(StateRecorder &inStream) const override;
  20. virtual void RestoreState(StateRecorder &inStream) override;
  21. private:
  22. void UpdateShapes();
  23. RefConst<Shape> mBox;
  24. Array<Body *> mBodies;
  25. Array<Ref<Constraint>> mConstraints;
  26. static constexpr float cBoxSize = 2.0f;
  27. float mTime = 0.0f;
  28. int mNumShapes = -1;
  29. };