SimShapeFilter.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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 <Jolt/Core/NonCopyable.h>
  6. JPH_NAMESPACE_BEGIN
  7. class Body;
  8. class Shape;
  9. class SubShapeID;
  10. /// Filter class used during the simulation (PhysicsSystem::Update) to filter out collisions at shape level
  11. class SimShapeFilter : public NonCopyable
  12. {
  13. public:
  14. /// Destructor
  15. virtual ~SimShapeFilter() = default;
  16. /// Filter function to determine if two shapes should collide. Returns true if the filter passes.
  17. /// This overload is called during the simulation (PhysicsSystem::Update) and must be registered with PhysicsSystem::SetSimShapeFilter.
  18. /// It is called at each level of the shape hierarchy, so if you have a compound shape with a box, this function will be called twice.
  19. /// It will not be called on triangles that are part of another shape, i.e a mesh shape will not trigger a callback per triangle.
  20. /// Note that this function is called from multiple threads and must be thread safe. All properties are read only.
  21. /// @param inBody1 1st body that is colliding
  22. /// @param inShape1 1st shape that is colliding
  23. /// @param inSubShapeIDOfShape1 The sub shape ID that will lead from inBody1.GetShape() to inShape1
  24. /// @param inBody2 2nd body that is colliding
  25. /// @param inShape2 2nd shape that is colliding
  26. /// @param inSubShapeIDOfShape2 The sub shape ID that will lead from inBody2.GetShape() to inShape2
  27. virtual bool ShouldCollide([[maybe_unused]] const Body &inBody1, [[maybe_unused]] const Shape *inShape1, [[maybe_unused]] const SubShapeID &inSubShapeIDOfShape1,
  28. [[maybe_unused]] const Body &inBody2, [[maybe_unused]] const Shape *inShape2, [[maybe_unused]] const SubShapeID &inSubShapeIDOfShape2) const
  29. {
  30. return true;
  31. }
  32. };
  33. JPH_NAMESPACE_END