AGXDynamics  2.31.1.0
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...
 
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
 
agx::Bool contains (agx::UInt32 hash) const
 
Mode getMode () const
 
int getReferenceCount () const
 
template<typename T >
bool is () const
 Subclass test. More...
 
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...
 
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 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 remove (agx::UInt32 hash)
 Remove hash from the matching set. More...
 
void setMode (Mode mode)
 Set mode how the filtering is performed. 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...
 
template<typename T >
static bool ValidateCast (const Referenced *object)
 

Protected Member Functions

virtual ~UuidHashCollisionFilter ()
 
void allocateObserverVector () const
 
void deleteUsingDeleteHandler () const
 

Static Protected Member Functions

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

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

◆ allocateObserverVector()

void agx::Referenced::allocateObserverVector ( ) const
protectedinherited

◆ as() [1/2]

template<typename T >
T* agx::Referenced::as ( )
inherited

Subclass casting.

Template type must match actual type, dynamic_cast assertion will fail otherwise.

Referenced by agx::InternalData::get(), agxVehicle::Track::getNode(), agx::InternalData::getOrCreate(), and agx::InternalData::hasData().

◆ as() [2/2]

template<typename T >
const T* agx::Referenced::as ( ) const
inherited

◆ asSafe() [1/2]

template<typename T >
T* agx::Referenced::asSafe ( )
inherited

Safe subclass casting, return nullptr if template type does not match.

Referenced by agxUtil::CollectBodiesAndWiresVisitor::visit().

◆ asSafe() [2/2]

template<typename T >
const T* agx::Referenced::asSafe ( ) const
inherited

◆ 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

◆ deleteUsingDeleteHandler()

void agx::Referenced::deleteUsingDeleteHandler ( ) const
protectedinherited

◆ 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.

◆ getDeleteHandler()

static DeleteHandler* agx::Referenced::getDeleteHandler ( )
staticprotectedinherited
Returns
a DeleteHandler.

◆ getMode()

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

◆ getReferenceCount()

int agx::Referenced::getReferenceCount ( ) const
inherited
Returns
the number pointers currently referencing this object.

◆ is()

template<typename T >
bool agx::Referenced::is ( ) const
inherited

◆ match() [1/3]

bool agxSDK::ExecuteFilter::match ( const agxCollide::GeometryContact &  gc) const
virtualinherited

Called when narrow phase tests have determined overlap (when we have detailed intersection between the actual geometries).

Implementation.

Parameters
gc- geometry contact of the overlapping geometries
Returns
true when this filter has determined that the GeometryContact should be used for triggering either an impact or a contact event

Reimplemented in agxModel::FractureGenerator::ContactFilter, agxModel::Tree::TreeExecuteFilter, and agxOSG::FilterContactByName.

Definition at line 110 of file ExecuteFilter.h.

References agxCollide::GeometryContact::geometry().

Referenced by agxWire::LinkObjectStabilizingAlgorithm::getLink(), agxModel::TireFilter::match(), and agxOSG::FilterContactByName::match().

◆ match() [2/3]

bool agxSDK::ExecuteFilter::match ( const agxCollide::GeometryPair &  geometryPair) const
virtualinherited

Called once when narrow phase no longer finds overlaps between the two geometries.

Parameters
geometryPair- the two geometries that no longer overlaps
Returns
true when this filter has determined that the geometry pair should be used for triggering a separation event

Reimplemented in agxModel::FractureGenerator::ContactFilter, agxModel::Tree::TreeExecuteFilter, and agxOSG::FilterContactByName.

Definition at line 116 of file ExecuteFilter.h.

◆ match() [3/3]

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().

◆ reference()

void agx::Referenced::reference ( void *  ptr = nullptr) const
inherited

Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.

This method should be used with care, always balanced with the same number of calls to unreference.

◆ remove()

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

Remove hash from the matching set.

Parameters
hash- UUID hash to remove from the matching set

◆ setDeleteHandler()

static void agx::Referenced::setDeleteHandler ( DeleteHandler *  handler)
staticprotectedinherited

Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.

◆ setMode()

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

Set mode how the filtering is performed.

Parameters
mode- new mode

◆ unreference()

void agx::Referenced::unreference ( void *  ptr = nullptr) const
inherited

Decrement the reference count by one, indicating that a pointer to this object is referencing it.

If the reference count goes to zero, it is assumed that this object is no longer referenced and is automatically deleted.

This method should be used with care, always balanced with the same number of calls to reference.

Referenced by agxData::EntityRef< ContactMaterialPtr >::~EntityRef().

◆ unreference_nodelete()

void agx::Referenced::unreference_nodelete ( ) const
inherited

Decrement the reference count by one, indicating that a pointer to this object is referencing it.

However, do not delete it, even if ref count goes to 0. Warning, unref_nodelete() should only be called if the user knows exactly who will be responsible for, one should prefer unref() over unref_nodelete() as the later can lead to memory leaks.

◆ ValidateCast()

template<typename T >
static bool agx::Referenced::ValidateCast ( const Referenced *  object)
staticinherited

Member Data Documentation

◆ m_mutex

Mutex agx::Referenced::m_mutex
mutableprotectedinherited

Definition at line 240 of file Referenced.h.

◆ m_observers

ObserverContainer agx::Referenced::m_observers
mutableprotectedinherited

Definition at line 239 of file Referenced.h.

◆ m_refCount

AtomicValue agx::Referenced::m_refCount
mutableprotectedinherited

Definition at line 241 of file Referenced.h.


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