AGX Dynamics  2.37.3.2
agxSDK::UuidHashCollisionFilter Class Reference

Contact event filter matching UUID of instances, such as agxCollide::Geometry, agx::RigidBody, agxWire::Wire, agxCable::Cable, agxVehicle::Track and/or agxTerrain::Terrain. More...

#include <UuidHashCollisionFilter.h>

+ Inheritance diagram for agxSDK::UuidHashCollisionFilter:

Public Types

enum  Mode { MATCH_ALL, MATCH_OR, MATCH_AND }
 

Public Member Functions

 UuidHashCollisionFilter ()
 Default constructor, default mode is MATCH_ALL. More...
 
void add (agx::UInt32 hash)
 Add UUID hash to the matching set. More...
 
agx::Bool contains (agx::UInt32 hash) const
 
Mode getMode () const
 
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. More...
 
void remove (agx::UInt32 hash)
 Remove hash from the matching set. More...
 
void setMode (Mode mode)
 Set mode how the filtering is performed. More...
 
- Public Member Functions inherited from agxSDK::ExecuteFilter
virtual bool match (const agxCollide::GeometryContact &gc) const
 Called when narrow phase tests have determined overlap (when we have detailed intersection between the actual geometries). More...
 
virtual bool match (const agxCollide::GeometryPair &geometryPair) const
 Called once when narrow phase no longer finds overlaps between the two geometries. More...
 
- Public Member Functions inherited from agx::Referenced
 Referenced ()
 Default constructor. More...
 
 Referenced (const Referenced &)
 
template<typename T >
T * as ()
 Subclass casting. More...
 
template<typename T >
const T * as () const
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match. More...
 
template<typename T >
const T * asSafe () const
 
int getReferenceCount () const
 
template<typename T >
bool is () const
 Subclass test. More...
 
Referenced & operator= (const Referenced &)
 Assignment operator. Will increment the number of references to the referenced object. More...
 
void reference (void *ptr=nullptr) const
 Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
void unreference (void *ptr=nullptr) const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unreference_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 

Static Public Member Functions

static agx::UInt32 findCorrespondingUuid (const agxCollide::Geometry *geometry)
 Searches for corresponding object's (e.g., Wire, Cable, Track etc.) UUID given geometry. More...
 
static agx::UInt32 findUuid (const agx::Referenced *instance)
 Finds UUID hash of the given instance. More...
 
- Static Public Member Functions inherited from agx::Referenced
template<typename T >
static bool ValidateCast (const Referenced *object)
 

Protected Member Functions

virtual ~UuidHashCollisionFilter ()
 
- Protected Member Functions inherited from agxSDK::ExecuteFilter
 ExecuteFilter ()
 Default, hidden constructor. More...
 
virtual ~ExecuteFilter ()
 Destructor. More...
 
- Protected Member Functions inherited from agx::Referenced
virtual ~Referenced ()
 Destructor. More...
 
void allocateObserverVector () const
 
void deleteUsingDeleteHandler () const
 

Additional Inherited Members

- Static Protected Member Functions inherited from agx::Referenced
static DeleteHandler * getDeleteHandler ()
 
static void setDeleteHandler (DeleteHandler *handler)
 Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to. More...
 
- Protected Attributes inherited from agx::Referenced
Mutex m_mutex
 
ObserverContainer m_observers
 
AtomicValue m_refCount
 

Detailed Description

Contact event filter matching UUID of instances, such as agxCollide::Geometry, agx::RigidBody, agxWire::Wire, agxCable::Cable, agxVehicle::Track and/or agxTerrain::Terrain.

This filter is especially convenient when you have to map AGX Dynamics instances with other representations, e.g.,

auto uuid = agxSDK::UuidHashCollisionFilter::findUuid( myRep->getAgxInstance() );
assert( uuid > 0u );
uuidRepTable[ uuid ] = uuid;
uuidFilter->add( uuid );

...

void handleContact( agxCollide::GeometryContact* gc )
{
  auto uuid1 = agxSDK::UuidHashCollisionFilter::findCorrespondingUuid( gc->geometry( 0 ) );
  auto uuid2 = agxSDK::UuidHashCollisionFilter::findCorrespondingUuid( gc->geometry( 1 ) );

Check if uuid1 and/or uuid2 is in our uuidRepTable. }

A corresponding UUID is the UUID the given geometry is representing. E.g., if you have a wire and do filter->add( wire->getUuid().hash() ), then you'll find that: UuidHashCollisionFilter::findCorrespondingUuid( geometryContact->geometry(1) ) == wire->getUuid().hash() with an exception for agx::RigidBody which is tightly coupled to its geometries. If an UUID of a rigid body is added to this filter, the filter will match but UuidHashCollisionFilter::findCorrespondingUuid( geometryContact->geometry(0) ) will return the UUID of the given geometry.

This filter is matching a pair of corresponding UUIDs given the following modes: MATCH_ALL: Any pair of geometries is a match (listen to all contacts). MATCH_OR: At least one of the corresponding UUID must match our UUID set. MATCH_AND: Both corresponding UUIDs must match our UUID set.

Definition at line 57 of file UuidHashCollisionFilter.h.

Member Enumeration Documentation

◆ Mode

Enumerator
MATCH_ALL 

Any object results in a match.

Default.

MATCH_OR 

At least one of the two objects must match our UUIDs.

MATCH_AND 

Both objects must match our UUID set.

Definition at line 60 of file UuidHashCollisionFilter.h.

Constructor & Destructor Documentation

◆ UuidHashCollisionFilter()

agxSDK::UuidHashCollisionFilter::UuidHashCollisionFilter ( )

Default constructor, default mode is MATCH_ALL.

◆ ~UuidHashCollisionFilter()

virtual agxSDK::UuidHashCollisionFilter::~UuidHashCollisionFilter ( )
protectedvirtual

Member Function Documentation

◆ add()

void agxSDK::UuidHashCollisionFilter::add ( agx::UInt32  hash)

Add UUID hash to the matching set.

Parameters
hash- UUID hash to add to the matching set

◆ contains()

agx::Bool agxSDK::UuidHashCollisionFilter::contains ( agx::UInt32  hash) const
Parameters
hash- UUID hash to check
Returns
true if this filter is matching given UUID hash, otherwise false

◆ findCorrespondingUuid()

static agx::UInt32 agxSDK::UuidHashCollisionFilter::findCorrespondingUuid ( const agxCollide::Geometry *  geometry)
static

Searches for corresponding object's (e.g., Wire, Cable, Track etc.) UUID given geometry.

◆ findUuid()

static agx::UInt32 agxSDK::UuidHashCollisionFilter::findUuid ( const agx::Referenced *  instance)
static

Finds UUID hash of the given instance.

This utility method is mainly convenient in other languages where, e.g., getUuid of an object isn't exported and this method contains some logic matching the filtering that's made when this filter is executed. E.g., the UUID of an agxTerrain::Terrain instance is of its geometry.

If it's not possible to determine the UUID, 0 is returned.

◆ getMode()

Mode agxSDK::UuidHashCollisionFilter::getMode ( ) const
Returns
the current filtering mode

◆ match()

bool agxSDK::UuidHashCollisionFilter::match ( const agxCollide::Geometry *  geometry1,
const agxCollide::Geometry *  geometry2 
) const
inlineoverridevirtual

Called by the other two match functions if they are not overridden.

Returns
true if either impact, contact or separation events should see these matching geometries

Reimplemented from agxSDK::ExecuteFilter.

Definition at line 140 of file UuidHashCollisionFilter.h.

References agxCollide::Geometry::getRigidBody(), agxStream::Serializable::getUuid(), and agx::Uuid::hash().

◆ remove()

void agxSDK::UuidHashCollisionFilter::remove ( agx::UInt32  hash)

Remove hash from the matching set.

Parameters
hash- UUID hash to remove from the matching set

◆ setMode()

void agxSDK::UuidHashCollisionFilter::setMode ( Mode  mode)

Set mode how the filtering is performed.

Parameters
mode- new mode

The documentation for this class was generated from the following file: