BigWorldTest.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
  2. // SPDX-FileCopyrightText: 2022 Jorrit Rouwe
  3. // SPDX-License-Identifier: MIT
  4. #pragma once
  5. #include <Tests/Test.h>
  6. #include <Jolt/Physics/Ragdoll/Ragdoll.h>
  7. class BigWorldTest : public Test
  8. {
  9. public:
  10. JPH_DECLARE_RTTI_VIRTUAL(JPH_NO_EXPORT, BigWorldTest)
  11. // Description of the test
  12. virtual const char * GetDescription() const override
  13. {
  14. return "Tests the stability of a pile of ragdolls on a terrain at various distances from the origin.\n"
  15. "Renders far away ragdoll piles at the origin in wireframe.";
  16. }
  17. // Destructor
  18. virtual ~BigWorldTest() override;
  19. // Number used to scale the terrain and camera movement to the scene
  20. virtual float GetWorldScale() const override { return 0.2f; }
  21. virtual void Initialize() override;
  22. virtual void PrePhysicsUpdate(const PreUpdateParams &inParams) override;
  23. // Optional settings menu
  24. virtual bool HasSettingsMenu() const override { return true; }
  25. virtual void CreateSettingsMenu(DebugUI *inUI, UIElement *inSubMenu) override;
  26. virtual RMat44 GetCameraPivot(float inCameraHeading, float inCameraPitch) const override;
  27. virtual RVec3 GetDrawOffset() const override;
  28. #ifndef JPH_DOUBLE_PRECISION
  29. virtual String GetStatusString() const override { return "Define JPH_DOUBLE_PRECISION for an accurate simulation!"; }
  30. #endif // JPH_DOUBLE_PRECISION
  31. private:
  32. // If we want to draw the further scenes in wireframe
  33. inline static bool sDrawWireframe = true;
  34. // A bitfield that determines which piles to draw
  35. inline static uint32 sDrawPileMask = ~uint32(0);
  36. // Pivot for the camera
  37. inline static RVec3 sPivot { RVec3::sZero() };
  38. // Bookkeeping for a pile
  39. struct Pile
  40. {
  41. // Distance label for this test
  42. String GetLabel() const { return StringFormat("%.0f km", 1.0e-3 * double(mOrigin.Length())); }
  43. RVec3 mOrigin; ///< Origin for this pile
  44. Array<Ref<Ragdoll>> mRagdolls; ///< Ragdolls in the pile
  45. };
  46. Array<Pile> mPiles;
  47. };