ShapeFilter.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // SPDX-FileCopyrightText: 2021 Jorrit Rouwe
  2. // SPDX-License-Identifier: MIT
  3. #pragma once
  4. #include <Jolt/Physics/Body/BodyID.h>
  5. #include <Jolt/Core/NonCopyable.h>
  6. JPH_NAMESPACE_BEGIN
  7. class SubShapeID;
  8. /// Filter class
  9. class ShapeFilter : public NonCopyable
  10. {
  11. public:
  12. /// Destructor
  13. virtual ~ShapeFilter() = default;
  14. /// Filter function to determine if we should collide with a shape. Returns true if the filter passes.
  15. /// This overload is called when the query doesn't have a source shape (e.g. ray cast / collide point)
  16. virtual bool ShouldCollide(const SubShapeID &inSubShapeID2) const
  17. {
  18. return true;
  19. }
  20. /// Filter function to determine if two shapes should collide. Returns true if the filter passes.
  21. /// This overload is called when querying a shape vs a shape (e.g. collide object / cast object)
  22. virtual bool ShouldCollide(const SubShapeID &inSubShapeID1, const SubShapeID &inSubShapeID2) const
  23. {
  24. return true;
  25. }
  26. /// Set by the collision detection functions to the body ID of the body that we're colliding against before calling the ShouldCollide function
  27. mutable BodyID mBodyID2;
  28. };
  29. JPH_NAMESPACE_END