SoftKeyframedRigTest.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
  2. // SPDX-FileCopyrightText: 2025 Jorrit Rouwe
  3. // SPDX-License-Identifier: MIT
  4. #pragma once
  5. #include <Tests/Test.h>
  6. #include <Jolt/Skeleton/Skeleton.h>
  7. #include <Jolt/Skeleton/SkeletalAnimation.h>
  8. #include <Jolt/Skeleton/SkeletonPose.h>
  9. #include <Utils/RagdollLoader.h>
  10. #include <Jolt/Physics/Ragdoll/Ragdoll.h>
  11. class SoftKeyframedRigTest : public Test
  12. {
  13. public:
  14. JPH_DECLARE_RTTI_VIRTUAL(JPH_NO_EXPORT, SoftKeyframedRigTest)
  15. // Description of the test
  16. virtual const char * GetDescription() const override
  17. {
  18. return "Tests a soft keyframed ragdoll moving towards a wall of boxes.\n"
  19. "This applies velocities to dynamic bodies to force the ragdoll to follow an animation.\n"
  20. "Since the bodies are dynamic, they will collide with static objects.";
  21. }
  22. // Destructor
  23. virtual ~SoftKeyframedRigTest() override;
  24. // Number used to scale the terrain and camera movement to the scene
  25. virtual float GetWorldScale() const override { return 0.2f; }
  26. virtual void Initialize() override;
  27. virtual void PrePhysicsUpdate(const PreUpdateParams &inParams) override;
  28. // Saving / restoring state for replay
  29. virtual void SaveState(StateRecorder &inStream) const override;
  30. virtual void RestoreState(StateRecorder &inStream) override;
  31. private:
  32. float mTime = 0.0f;
  33. Ref<RagdollSettings> mRagdollSettings;
  34. Ref<Ragdoll> mRagdoll;
  35. Ref<SkeletalAnimation> mAnimation;
  36. SkeletonPose mPose;
  37. };