BigWorldTest.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. // This test tests the performance of a pile of ragdolls on a terrain at various distances from the origin.
  8. class BigWorldTest : public Test
  9. {
  10. public:
  11. JPH_DECLARE_RTTI_VIRTUAL(BigWorldTest)
  12. // Destructor
  13. virtual ~BigWorldTest() override;
  14. // Number used to scale the terrain and camera movement to the scene
  15. virtual float GetWorldScale() const override { return 0.2f; }
  16. virtual void Initialize() override;
  17. virtual void PrePhysicsUpdate(const PreUpdateParams &inParams) override;
  18. // Optional settings menu
  19. virtual bool HasSettingsMenu() const override { return true; }
  20. virtual void CreateSettingsMenu(DebugUI *inUI, UIElement *inSubMenu) override;
  21. virtual RMat44 GetCameraPivot(float inCameraHeading, float inCameraPitch) const override;
  22. virtual RVec3 GetDrawOffset() const override;
  23. #ifndef JPH_DOUBLE_PRECISION
  24. virtual String GetStatusString() const override { return "Define JPH_DOUBLE_PRECISION for an accurate simulation!"; }
  25. #endif // JPH_DOUBLE_PRECISION
  26. private:
  27. // If we want to draw the further scenes in wireframe
  28. inline static bool sDrawWireframe = true;
  29. // A bitfield that determines which piles to draw
  30. inline static uint32 sDrawPileMask = ~uint32(0);
  31. // Pivot for the camera
  32. inline static RVec3 sPivot { RVec3::sZero() };
  33. // Bookkeeping for a pile
  34. struct Pile
  35. {
  36. // Distance label for this test
  37. String GetLabel() const { return StringFormat("%.0f km", 1.0e-3 * double(mOrigin.Length())); }
  38. RVec3 mOrigin; ///< Origin for this pile
  39. Array<Ref<Ragdoll>> mRagdolls; ///< Ragdolls in the pile
  40. };
  41. Array<Pile> mPiles;
  42. };