|
AGXDynamics
2.31.1.0
|
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 |
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.
| 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.
| agxSDK::UuidHashCollisionFilter::UuidHashCollisionFilter | ( | ) |
Default constructor, default mode is MATCH_ALL.
|
protectedvirtual |
| void agxSDK::UuidHashCollisionFilter::add | ( | agx::UInt32 | hash | ) |
Add UUID hash to the matching set.
| hash | - UUID hash to add to the matching set |
|
protectedinherited |
|
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().
|
inherited |
|
inherited |
Safe subclass casting, return nullptr if template type does not match.
Referenced by agxUtil::CollectBodiesAndWiresVisitor::visit().
|
inherited |
| agx::Bool agxSDK::UuidHashCollisionFilter::contains | ( | agx::UInt32 | hash | ) | const |
| hash | - UUID hash to check |
hash, otherwise false
|
protectedinherited |
|
static |
Searches for corresponding object's (e.g., Wire, Cable, Track etc.) UUID given geometry.
|
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.
|
staticprotectedinherited |
| Mode agxSDK::UuidHashCollisionFilter::getMode | ( | ) | const |
|
inherited |
|
inherited |
Subclass test.
Referenced by agx::Object::getAutoScopedResource(), agxData::EntityStorage::getInstances(), and agx::Object::getResource().
|
virtualinherited |
Called when narrow phase tests have determined overlap (when we have detailed intersection between the actual geometries).
Implementation.
| gc | - geometry contact of the overlapping geometries |
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().
|
virtualinherited |
Called once when narrow phase no longer finds overlaps between the two geometries.
| geometryPair | - the two geometries that no longer overlaps |
Reimplemented in agxModel::FractureGenerator::ContactFilter, agxModel::Tree::TreeExecuteFilter, and agxOSG::FilterContactByName.
Definition at line 116 of file ExecuteFilter.h.
|
inlineoverridevirtual |
Called by the other two match functions if they are not overridden.
Reimplemented from agxSDK::ExecuteFilter.
Definition at line 140 of file UuidHashCollisionFilter.h.
References agxCollide::Geometry::getRigidBody(), agxStream::Serializable::getUuid(), and agx::Uuid::hash().
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.
| void agxSDK::UuidHashCollisionFilter::remove | ( | agx::UInt32 | hash | ) |
Remove hash from the matching set.
| hash | - UUID hash to remove from the matching set |
|
staticprotectedinherited |
Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.
Set mode how the filtering is performed.
| mode | - new mode |
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().
|
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.
|
staticinherited |
|
mutableprotectedinherited |
Definition at line 240 of file Referenced.h.
|
mutableprotectedinherited |
Definition at line 239 of file Referenced.h.
|
mutableprotectedinherited |
Definition at line 241 of file Referenced.h.