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
47};
48
51{
52public:
54 explicit ReversedShapeFilter(const ShapeFilter &inFilter) : mFilter(inFilter)
55 {
56 mBodyID2 = inFilter.mBodyID2;
57 }
58
59 virtual bool ShouldCollide(const Shape *inShape2, const SubShapeID &inSubShapeIDOfShape2) const override
60 {
61 return mFilter.ShouldCollide(inShape2, inSubShapeIDOfShape2);
62 }
63
64 virtual bool ShouldCollide(const Shape *inShape1, const SubShapeID &inSubShapeIDOfShape1, const Shape *inShape2, const SubShapeID &inSubShapeIDOfShape2) const override
65 {
66 return mFilter.ShouldCollide(inShape2, inSubShapeIDOfShape2, inShape1, inSubShapeIDOfShape1);
67 }
68
69private:
70 const ShapeFilter & mFilter;
71};
72
#define JPH_NAMESPACE_END
Definition Core.h:414
#define JPH_NAMESPACE_BEGIN
Definition Core.h:408
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:51
virtual bool ShouldCollide(const Shape *inShape2, const SubShapeID &inSubShapeIDOfShape2) const override
Definition ShapeFilter.h:59
virtual bool ShouldCollide(const Shape *inShape1, const SubShapeID &inSubShapeIDOfShape1, const Shape *inShape2, const SubShapeID &inSubShapeIDOfShape2) const override
Definition ShapeFilter.h:64
ReversedShapeFilter(const ShapeFilter &inFilter)
Constructor.
Definition ShapeFilter.h:54
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
Definition ShapeFilter.h:46
Base class for all shapes (collision volume of a body). Defines a virtual interface for collision det...
Definition Shape.h:186
A sub shape id contains a path to an element (usually a triangle or other primitive type) of a compou...
Definition SubShapeID.h:23