Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
ShapeFilter.h
Go to the documentation of this file.
1// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
2// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
9
11
12class Shape;
13class SubShapeID;
14
17{
18public:
20 virtual ~ShapeFilter() = default;
21
26 virtual bool ShouldCollide([[maybe_unused]] const Shape *inShape2, [[maybe_unused]] const SubShapeID &inSubShapeIDOfShape2) const
27 {
28 return true;
29 }
30
39 virtual bool ShouldCollide([[maybe_unused]] const Shape *inShape1, [[maybe_unused]] const SubShapeID &inSubShapeIDOfShape1, [[maybe_unused]] const Shape *inShape2, [[maybe_unused]] const SubShapeID &inSubShapeIDOfShape2) const
40 {
41 return true;
42 }
43
46};
47
50{
51public:
53 explicit ReversedShapeFilter(const ShapeFilter &inFilter) : mFilter(inFilter)
54 {
55 mBodyID2 = inFilter.mBodyID2;
56 }
57
58 virtual bool ShouldCollide(const Shape *inShape2, const SubShapeID &inSubShapeIDOfShape2) const override
59 {
60 return mFilter.ShouldCollide(inShape2, inSubShapeIDOfShape2);
61 }
62
63 virtual bool ShouldCollide(const Shape *inShape1, const SubShapeID &inSubShapeIDOfShape1, const Shape *inShape2, const SubShapeID &inSubShapeIDOfShape2) const override
64 {
65 return mFilter.ShouldCollide(inShape2, inSubShapeIDOfShape2, inShape1, inSubShapeIDOfShape1);
66 }
67
68private:
69 const ShapeFilter & mFilter;
70};
71
#define JPH_NAMESPACE_END
Definition: Core.h:367
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:361
ID of a body. This is a way of reasoning about bodies in a multithreaded simulation while avoiding ra...
Definition: BodyID.h:13
Class that makes another class non-copyable. Usage: Inherit from NonCopyable.
Definition: NonCopyable.h:11
Helper class to reverse the order of the shapes in the ShouldCollide function.
Definition: ShapeFilter.h:50
virtual bool ShouldCollide(const Shape *inShape2, const SubShapeID &inSubShapeIDOfShape2) const override
Definition: ShapeFilter.h:58
virtual bool ShouldCollide(const Shape *inShape1, const SubShapeID &inSubShapeIDOfShape1, const Shape *inShape2, const SubShapeID &inSubShapeIDOfShape2) const override
Definition: ShapeFilter.h:63
ReversedShapeFilter(const ShapeFilter &inFilter)
Constructor.
Definition: ShapeFilter.h:53
Filter class.
Definition: ShapeFilter.h:17
virtual bool ShouldCollide(const Shape *inShape2, const SubShapeID &inSubShapeIDOfShape2) const
Definition: ShapeFilter.h:26
virtual bool ShouldCollide(const Shape *inShape1, const SubShapeID &inSubShapeIDOfShape1, const Shape *inShape2, const SubShapeID &inSubShapeIDOfShape2) const
Definition: ShapeFilter.h:39
virtual ~ShapeFilter()=default
Destructor.
BodyID mBodyID2
Set by the collision detection functions to the body ID of the body that we're colliding against befo...
Definition: ShapeFilter.h:45
Base class for all shapes (collision volume of a body). Defines a virtual interface for collision det...
Definition: Shape.h:178
A sub shape id contains a path to an element (usually a triangle or other primitive type) of a compou...
Definition: SubShapeID.h:23