AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
UuidHashCollisionFilter.h
Go to the documentation of this file.
1/*
2Copyright 2007-2024. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#pragma once
18
20
21namespace agxSDK
22{
58 {
59 public:
60 enum Mode
61 {
64 MATCH_AND
65 };
66
67 public:
77 static agx::UInt32 findUuid( const agx::Referenced* instance );
78
84
85 public:
90
95 void setMode( Mode mode );
96
100 Mode getMode() const;
101
106 void add( agx::UInt32 hash );
107
112 void remove( agx::UInt32 hash );
113
119
120 public:
121 virtual bool match( const agxCollide::Geometry* geometry1,
122 const agxCollide::Geometry* geometry2 ) const override;
123
124 using ExecuteFilter::match;
125
126 protected:
128
129 private:
130 agx::Bool isMatch( const agxCollide::Geometry* geometry ) const;
131
132 private:
134
135 private:
136 Mode m_mode;
137 UInt32Set m_uuids;
138 };
139
141 const agxCollide::Geometry* geometry2 ) const
142 {
143 return m_mode == MATCH_ALL ||
144 ( m_mode == MATCH_OR && ( isMatch( geometry1 ) || isMatch( geometry2 ) ) ) ||
145 ( m_mode == MATCH_AND && ( isMatch( geometry1 ) && isMatch( geometry2 ) ) );
146 }
147
148 inline agx::Bool UuidHashCollisionFilter::isMatch( const agxCollide::Geometry* geometry ) const
149 {
150 const auto rbUuid = geometry->getRigidBody() != nullptr ?
151 geometry->getRigidBody()->getUuid().hash() :
152 0u;
153 return contains( findCorrespondingUuid( geometry ) ) ||
154 contains( rbUuid );
155 }
156}
#define AGXPHYSICS_EXPORT
The geometry representation used by the collision detection engine.
Definition Geometry.h:92
agx::RigidBody * getRigidBody()
Definition Geometry.h:790
Abstract base class that implements a filter that selects which events should trigger a Listener.
Contact event filter matching UUID of instances, such as agxCollide::Geometry, agx::RigidBody,...
UuidHashCollisionFilter()
Default constructor, default mode is MATCH_ALL.
agx::Bool contains(agx::UInt32 hash) const
void setMode(Mode mode)
Set mode how the filtering is performed.
static agx::UInt32 findUuid(const agx::Referenced *instance)
Finds UUID hash of the given instance.
void remove(agx::UInt32 hash)
Remove hash from the matching set.
static agx::UInt32 findCorrespondingUuid(const agxCollide::Geometry *geometry)
Searches for corresponding object's (e.g., Wire, Cable, Track etc.) UUID given geometry.
void add(agx::UInt32 hash)
Add UUID hash to the matching set.
virtual bool match(const agxCollide::Geometry *geometry1, const agxCollide::Geometry *geometry2) const override
Called by the other two match functions if they are not overridden.
@ MATCH_AND
Both objects must match our UUID set.
@ MATCH_OR
At least one of the two objects must match our UUIDs.
@ MATCH_ALL
Any object results in a match.
agx::Uuid getUuid() const
Base class providing referencing counted objects.
Definition Referenced.h:120
UInt32 hash() const
Definition Uuid.h:213
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition Constraint.h:31
uint32_t UInt32
Definition Integer.h:32
bool Bool
Definition Integer.h:40