ConstraintVsCOMChangeTest.h 965 B

1234567891011121314151617181920212223242526272829303132
  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. // This test demonstrates how to notify a constraint that the center of mass of a body changed (constraints store their attachment points in center of mass space).
  7. class ConstraintVsCOMChangeTest : public Test
  8. {
  9. public:
  10. JPH_DECLARE_RTTI_VIRTUAL(JPH_NO_EXPORT, ConstraintVsCOMChangeTest)
  11. // See: Test
  12. virtual void Initialize() override;
  13. virtual void PrePhysicsUpdate(const PreUpdateParams& inParams) override;
  14. virtual void SaveState(StateRecorder& inStream) const override;
  15. virtual void RestoreState(StateRecorder& inStream) override;
  16. private:
  17. void UpdateShapes();
  18. RefConst<Shape> mBox;
  19. Array<Body *> mBodies;
  20. Array<Ref<Constraint>> mConstraints;
  21. static constexpr float cBoxSize = 2.0f;
  22. float mTime = 0.0f;
  23. int mNumShapes = -1;
  24. };