SimCollideBodyVsBodyTest.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. class SimCollideBodyVsBodyTest : public Test, public ContactListener
  7. {
  8. public:
  9. JPH_DECLARE_RTTI_VIRTUAL(JPH_NO_EXPORT, SimCollideBodyVsBodyTest)
  10. // Description of the test
  11. virtual const char *GetDescription() const override
  12. {
  13. return "Overrides the collide body vs body function on the simulation to reduce the number of contact points generated between sensors and other objects in the simulation.\n"
  14. "This can be useful to improve performance if you don't need to know about all contact points and are only interested in an overlap/no-overlap result.\n"
  15. "The static world consists of a single compound shape with many pyramid sub shapes.";
  16. }
  17. // See: Test
  18. virtual void Initialize() override;
  19. virtual void PrePhysicsUpdate(const PreUpdateParams &inParams) override;
  20. // If this test implements a contact listener, it should be returned here
  21. virtual ContactListener *GetContactListener() override { return this; }
  22. // See: ContactListener
  23. virtual void OnContactAdded(const Body &inBody1, const Body &inBody2, const ContactManifold &inManifold, ContactSettings &ioSettings) override;
  24. virtual void OnContactPersisted(const Body &inBody1, const Body &inBody2, const ContactManifold &inManifold, ContactSettings &ioSettings) override;
  25. // Saving / restoring state for replay
  26. virtual void SaveState(StateRecorder &inStream) const override;
  27. virtual void RestoreState(StateRecorder &inStream) override;
  28. private:
  29. int mPrevMode = -1; // Previous mode
  30. float mTime = 0.0f; // Total elapsed time
  31. BodyID mSensorID; // Body ID of the sensor
  32. BodyIDVector mBodyIDs; // List of dynamic bodies
  33. };