SimulationShapeFilterTest.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
  2. // SPDX-FileCopyrightText: 2024 Jorrit Rouwe
  3. // SPDX-License-Identifier: MIT
  4. #pragma once
  5. #include <Tests/Test.h>
  6. // This test shows how to use a shape filter during the simulation to disable contacts between certain sub shapes
  7. class SimulationShapeFilterTest : public Test
  8. {
  9. public:
  10. JPH_DECLARE_RTTI_VIRTUAL(JPH_NO_EXPORT, SimulationShapeFilterTest)
  11. // Destructor
  12. virtual ~SimulationShapeFilterTest() override;
  13. // See: Test
  14. virtual void Initialize() override;
  15. private:
  16. // A demo of the shape filter
  17. class Filter : public ShapeFilter
  18. {
  19. public:
  20. virtual bool ShouldCollide(const Shape *inShape1, const SubShapeID &inSubShapeIDOfShape1, const Shape *inShape2, const SubShapeID &inSubShapeIDOfShape2) const override;
  21. // We're not interested in the other overload as it is only used by collision queries and not by the simulation
  22. using ShapeFilter::ShouldCollide;
  23. BodyID mPlatformID;
  24. BodyID mCompoundID;
  25. };
  26. Filter mShapeFilter;
  27. };