AGX Dynamics 2.41.1.2
Loading...
Searching...
No Matches
agxCollide::Space Class Reference

This class contains all Geometries and performs Broad Phase and Narrow Phase collision detection to calculate overlapping Geometry pairs. More...

#include <Space.h>

+ Inheritance diagram for agxCollide::Space:

Public Types

enum  BroadPhaseAlgorithm { INVALID_BROAD_PHASE_ALGORITHM = -1 , SWEEP_AND_PRUNE , HIERARCHICAL_GRID }
 Enum for specifying which BroadPhase algorithm space should use. More...
 
typedef agx::SetVector< GeometryPair > GeometryPairHash
 
- Public Types inherited from agx::Component
typedef Event2< Component *, Object * > ObjectEvent
 Event when adding removing child objects.
 
typedef Callback1< Object * > TraverseCallback
 
- Public Types inherited from agx::Object
typedef agx::observer_ptr< const EventEventConstObserver
 
typedef agx::ref_ptr< const EventEventConstRef
 
typedef agx::observer_ptr< EventEventObserver
 
typedef agx::Vector< EventObserverEventObserverVector
 
typedef agx::VectorPOD< Event * > EventPtrVector
 
typedef agx::ref_ptr< EventEventRef
 
typedef agx::Vector< EventRefEventRefVector
 

Public Member Functions

 Space ()
 Default constructor.
 
 Space (agx::Device *device)
 Instantiate Space with a specific device.
 
bool add (Geometry *geometry)
 Insert a new geometry into the Space so it can collide with other geometries.
 
void addGeometryContacts (const LocalGeometryContactVector &localContacts)
 Explicitly add geometry contacts.
 
void addListener (agxCollide::SpaceListener *listener)
 Add a listener to space.
 
bool canCollide (const Geometry *g1, const Geometry *g2) const
 Check if two geometries can collide.
 
void cleanup ()
 Cleanup the internal state of the object.
 
void commitRemovedContacts ()
 Go through all the contact and contact points scheduled for removal and remove them from the list of contacts.
 
size_t computeNumberOfEnabledContactPoints () const
 
template<typename F >
void disableForContacts (F relevantCollision)
 If for some reason a geometry or several geometries collides with less geometries now than previously, we need to make sure that previous overlaps are removed, as they might remain otherwise.
 
template<typename F >
void enableForContacts (F relevantCollision)
 If for some reason a geometry or several geometries collides with more geometries now than previously, we need to make sure that current overlaps are reported, as they might be ignored otherwise.
 
void eraseDisabledGroupPair (agx::UInt32 group1, agx::UInt32 group2)
 Consider using setEnablePair( group1, group2, true ) instead.
 
agxCollide::DisabledCollisionsState findDisabledCollisionsState () const
 Find the complete state of disabled collisions, including name <-> name pairs, id <-> id pairs and geometry <-> geometry pairs.
 
BroadPhaseAlgorithm getBroadPhaseAlgorithm () const
 
const BroadPhasePairVectorgetBroadPhasePairs () const
 
GeometryContact getContact (Geometry *g1, Geometry *g2) const
 Returns geometry contact between two geometries, if existing.
 
agx::UInt getContactReductionBinResolution () const
 
agx::UInt getContactReductionThreshold () const
 
const GeometryPairHashgetDisabledPairs () const
 
bool getEnableContactReduction () const
 
bool getEnablePair (agx::UInt32 group1, agx::UInt32 group2) const
 Get information if group1 and group2 are allowed to collide.
 
bool getEnablePair (const agx::Name &group1, const agx::Name &group2) const
 Get information if group1 and group2 are allowed to collide.
 
const GeometryRefVectorgetGeometries () const
 
GeometrygetGeometry (const agx::Name &name)
 Find (linear search) the first Geometry in space with a matching name.
 
const GeometrygetGeometry (const agx::Name &name) const
 Find (linear search) the first Geometry in space with a matching name.
 
GeometrygetGeometry (const agx::Uuid &uuid)
 Find (linear search) the first Geometry in space matching the specified uuid.
 
const GeometrygetGeometry (const agx::Uuid &uuid) const
 Find (linear search) the first Geometry in space matching the specified uuid.
 
const GeometryContactPtrVectorgetGeometryContacts () const
 Access to the vector containing all narrow phase contacts.
 
size_t getGeometryContacts (GeometryContactPtrVector &matches, const agx::RigidBody *body1, const agx::RigidBody *body2=nullptr) const
 Extract a vector with all matching geometry contacts involving the two specified rigid bodies This method will perform a linear search through all contact points.
 
size_t getGeometryContacts (GeometryContactPtrVector &matches, const agxCollide::Geometry *geometry1, const agxCollide::Geometry *geometry2=nullptr) const
 Extract a vector with all matching geometry contacts involving the two specified geometries.
 
GeometrygetGeometryWithEntityId (agx::Index id)
 Return Geometry in space matching the specified id.
 
const GeometrygetGeometryWithEntityId (agx::Index id) const
 Return Geometry in space matching the specified id.
 
HierarchicalGridgetHierarchicalGrid ()
 
agx::Real getOrientedBoundsThreshold () const
 Returns the current threshold for where oriented bounds are created for Geometries.
 
const ParticleGeometryContactVectorgetParticleGeometryContacts ()
 
const ParticlePairContactVectorgetParticleParticleContacts ()
 
const SeparationPairVectorgetSeparationPairs () const
 
size_t getSeparationPairs (agx::Physics::GeometryPairPtrVector &matches, const agx::RigidBody *body1, const agx::RigidBody *body2=nullptr) const
 Extract a new vector including rigid bodies which just recently separated.
 
size_t getSeparationPairs (agx::Physics::GeometryPairPtrVector &matches, const agxCollide::Geometry *geometry1, const agxCollide::Geometry *geometry2=nullptr) const
 Extract a new vector including geometries which just recently separated.
 
agxCollide::SweepAndPrunegetSweepAndPrune ()
 
agx::UInt32 getUniqueGroupID ()
 
void insertDisabledGroupPair (agx::UInt32 group1, agx::UInt32 group2)
 Consider using setEnablePair( group1, group2, false ) instead.
 
bool intersect (const agx::Vec3 &point, const agx::Vec3 &direction, LocalGeometryContactVector &geometryContacts, LocalParticleGeometryContactVector &particleGeometryContacts, const agx::Real length=FLT_MAX/4)
 Sends a ray into the collision space and returns information about the objects the ray hits.
 
bool remove (Geometry *geometry)
 Remove a geometry from Space.
 
void removeContact (agx::Physics::GeometryContactPtr contact)
 Schedule a removal of a specified Narrow phase contact, the contact will not be removed until the method commitRemovedContacts() is called (during the next update())
 
GeometryContactPtrVector::const_iterator removeContact (GeometryContactPtrVector::const_iterator contact)
 Remove a specified GeometryContact from the list of contacts.
 
bool removeListener (agxCollide::SpaceListener *listener)
 Remove a listener from Space.
 
void removeOverlap (agxCollide::Geometry *geometry1, agxCollide::Geometry *geometry2)
 Remove a (Sweep and Prune) bounding overlap, if it exists, between geometry1 and geoemtry2.
 
void reportOverlap (agxCollide::Geometry *geometry1, agxCollide::Geometry *geometry2)
 Add an explicit bounding volume overlap between the two specified geometries.
 
void resetGeometryCellAssignments (agxCollide::Geometry *geometry)
 
void resetParticleCellAssignments ()
 
bool setBroadPhaseAlgorithm (BroadPhaseAlgorithm algorithm)
 Specify a new broad phase algorithm implementation.
 
void setContactReductionBinResolution (agx::UInt binResolution)
 Specify the default (for this Simulation) resolution used when evaluating contacts for reduction between geometry-geometry contacts.
 
void setContactReductionThreshold (agx::UInt threshold)
 Specify the lower threshold for the number of contact points needed per geometry contact in order to do contact reduction per geometry contact.
 
void setEnableCollisions (const Geometry *g1, const Geometry *g2, bool flag)
 Explicitly disable/enable a geometry pair.
 
void setEnableContactReduction (bool flag)
 Enable/Disable contact reduction between pairs of geometries.
 
void setEnableGeometry (Geometry *geometry, bool flag)
 
void setEnablePair (agx::UInt32 group1, agx::UInt32 group2, bool flag)
 Enable/disable collisions between two geometry group ID:s.
 
void setEnablePair (const agx::Name &group1, const agx::Name &group2, bool flag)
 
void setOrientedBoundsThreshold (agx::Real threshold)
 Sets the threshold where oriented bounds are created for Geometries.
 
bool testBoundingVolumeOverlap (GeometryPtrVector &testGeometries, GeometryPairVector &geometryPairs, ParticleGeometryPairVector &particleGeometryPairs, bool skip=true)
 Tests a number of geometries for bounding volume overlaps without changing the geometries already in space besides from updating bounding volumes.
 
bool testGeometryOverlap (GeometryPtrVector &testGeometries, LocalGeometryContactVector &geometryContacts, LocalParticleGeometryContactVector &particleGeometryContacts, bool skip=true)
 Test if a number of geometries collides with something already present in space without changing space, besides from updating some bounding volumes.
 
void update ()
 Update the contact state of the entire space including Broad Phase and narrow phase.
 
void updateBroadPhase ()
 Update the broad-phase state of the space.
 
void updateNarrowPhase ()
 Update the narrow phase state, calculating contact data for all overlapping geometry pairs.
 
- Public Member Functions inherited from agx::Component
 Component (const agx::Name &name=agx::Name(), agx::Model *model=agx::Component::ClassModel(), agx::Device *device=nullptr)
 
virtual void addObject (agx::Object *object, bool assignContext=true)
 Add an object to the component.
 
virtual String autoComplete (const String &partialName, StringVector &matchingNames) const
 
virtual void buildNavigationTree (agxJson::Value &eNode) const override
 
void configure (Model *model)
 
virtual void configure (TiXmlElement *eComponent) override
 
agx::DevicegetDevice ()
 
template<typename T >
T * getDevice ()
 
const agx::DevicegetDevice () const
 
template<typename T >
const T * getDevice () const
 
size_t getNumObjects (const agx::Name &name) const
 
agx::ObjectgetObject (const agx::Name &name, agx::Model *model, size_t index=0)
 
const agx::ObjectgetObject (const agx::Name &name, agx::Model *model, size_t index=0) const
 
agx::ObjectgetObject (const agx::Name &name, size_t index=0)
 
template<typename T >
T * getObject (const agx::Name &name, size_t index=0)
 
const agx::ObjectgetObject (const agx::Name &name, size_t index=0) const
 
template<typename T >
const T * getObject (const agx::Name &name, size_t index=0) const
 
const agx::ObjectRefVectorgetObjects () const
 
template<typename T >
void getObjects (agx::ObjectPtrVector &result, bool recursive=false) const
 
void getObjects (agx::ObjectPtrVector &result, const agx::Model *model, bool recursive=false) const
 
virtual ObjectgetResourceImpl (const Path &path, agx::Model *model) override
 
virtual void printSubtree () const override
 
void printSubtree (std::ostream &stream, int depth=0) const
 
virtual void rebind () override
 
void removeAllObjects ()
 Remove all components.
 
virtual void removeObject (agx::Object *object)
 Remove an object from the component.
 
void removeObject (const agx::Name &name, size_t index=0)
 Remove an object with a specified name (and optional index) from the component.
 
virtual void snapshot (TiXmlNode *eParent, const String &directory) const override
 
void traverse (ComponentVisitor *)
 
void traverse (const TraverseCallback &callback)
 
- Public Member Functions inherited from agx::Object
 Object (const Name &name=Name(), Model *model=Object::ClassModel())
 
void addListener (EventListener *listener)
 
virtual void buildNavigationTree (agxJson::Value &eNode) const
 
virtual void configure (TiXmlElement *)
 
agx::String fullName () const
 
agx::String fullPath () const
 
agx::String fullPath (const agx::Object *root) const
 
template<typename T >
T * getAutoScopedResource (const agx::Path &path)
 
template<typename T >
const T * getAutoScopedResource (const agx::Path &path) const
 
agx::ObjectgetAutoScopedResource (const agx::Path &path, agx::Model *model=nullptr)
 
const agx::ObjectgetAutoScopedResource (const agx::Path &path, agx::Model *model=nullptr) const
 
agx::ObjectgetContext ()
 
template<typename T >
T * getContext ()
 
const agx::ObjectgetContext () const
 
template<typename T >
const T * getContext () const
 
agx::UInt32 getId () const
 
const agx::NamegetImplementationName () const
 
agx::ModelgetModel ()
 
const agx::ModelgetModel () const
 
const agx::NamegetName () const
 
agx::ObjectgetNextSibling ()
 
const agx::ObjectgetNextSibling () const
 
agx::Path getPath () const
 
agx::Path getPath (const agx::Object *root) const
 
template<typename T >
T * getResource (const agx::Path &path)
 
template<typename T >
const T * getResource (const agx::Path &path) const
 
agx::ObjectgetResource (const agx::Path &path, agx::Model *model=nullptr)
 
const agx::ObjectgetResource (const agx::Path &path, agx::Model *model=nullptr) const
 
virtual agx::ObjectgetResourceImpl (const agx::Path &path, agx::Model *model)
 
agx::ObjectgetRootContext ()
 
const agx::ObjectgetRootContext () const
 
bool hasListener (EventListener *listener)
 
bool hasParent (const agx::Object *node) const
 
bool isUnique () const
 
virtual void printSubtree () const
 
virtual void rebind ()
 
void removeListener (EventListener *listener)
 
virtual void save (TiXmlElement *) const
 
virtual void setContext (agx::Object *context)
 
void setId (UInt32 id)
 
void setModel (agx::Model *model)
 Set the object model (handled automatically).
 
void setName (const agx::Name &name)
 Set the name of the object.
 
virtual void snapshot (TiXmlNode *, const String &) const
 
- Public Member Functions inherited from agx::Referenced
 Referenced ()
 Default constructor.
 
 Referenced (const Referenced &)
 
template<typename T >
T * as ()
 Subclass casting.
 
template<typename T >
const T * as () const
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match.
 
template<typename T >
const T * asSafe () const
 
int getReferenceCount () const
 
template<typename T >
bool is () const
 Subclass test.
 
Referencedoperator= (const Referenced &)
 Assignment operator. Will increment the number of references to the referenced object.
 
void reference (void *ptr=nullptr) const
 Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.
 
void unreference (void *ptr=nullptr) const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 
void unreference_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 
- Public Member Functions inherited from agxStream::Serializable
virtual ~Serializable ()
 Destructor for normal C++ use but hidden from SWIG bindings.
 
virtual const char * getClassName () const
 
bool getEnableSerialization () const
 
bool getEnableUuidGeneration ()
 
agx::UInt32 getIndex () const
 This index is given at creation of this object.
 
virtual StorageAgent * getStorageAgent () const =0
 
agx::Uuid getUuid () const
 
bool isFinished () const
 
void setEnableSerialization (bool flag)
 Set to false to disable serialization of this object.
 
void setFinished ()
 Tells this class that it is restored correctly and should not be deleted during destruction of an Archive.
 
void setUuid (const agx::Uuid &uuid)
 Explicitly set a Uuid on a serializable object.
 

Protected Member Functions

virtual ~Space ()
 Destructor.
 
- Protected Member Functions inherited from agx::Component
virtual ~Component ()
 
String expandAutoCompletionMatch (const String &query, const StringVector &matchingNames) const
 
void setDevice (Device *device)
 
- Protected Member Functions inherited from agx::Object
virtual ~Object ()
 
- Protected Member Functions inherited from agx::Referenced
virtual ~Referenced ()
 Destructor.
 
void allocateObserverVector () const
 
void deleteUsingDeleteHandler () const
 
- Protected Member Functions inherited from agxStream::Serializable
 Serializable ()
 Default constructor.
 
 Serializable (const Serializable &other)
 Copy constructor.
 
void generateUuid ()
 

Additional Inherited Members

- Static Public Member Functions inherited from agx::Component
static Component_load (TiXmlElement *eComponent, Device *device)
 
static agx::ModelClassModel ()
 
static Componentload (const Path &path, const Name &implementation, Device *device, const Path &_namespace=Path())
 
static Componentload (const String &path, const Path &_namespace=Path())
 
static Componentload (const String &path, Device *device, const Path &_namespace=Path())
 
static Componentload (TiXmlElement *eComponent, Device *device)
 
- Static Public Member Functions inherited from agx::Object
static agx::ModelClassModel ()
 
static agx::String generateName (const agx::String &bindPath)
 
static const HashSet< Object * > & getActiveObjects ()
 
static bool getEnableRebind ()
 Should rebinding be allowed? Right now a global setting.
 
static Objectload (const String &path, Device *device, const String &type, const String &attribute, const String &value)
 
template<typename T >
static T * load (const String &path, Device *device, const String &type, const String &attribute, const String &value)
 
static Objectload (const String &path, Device *device, const String &type="", size_t instance=0)
 
template<typename T >
static T * load (const String &path, Device *device, const String &type="", size_t instance=0)
 
static void load (const String &path, Device *device, ObjectPtrVector &loadedObjects)
 
static Objectload (TiXmlElement *eObject, Device *device)
 
template<typename T >
static T * load (TiXmlElement *eObject, Device *device)
 
static TiXmlDocument openDocument (const String &path)
 
static void setEnableRebind (bool flag)
 Sets if rebinding of objects should be allowed (Right now a global setting).
 
- Static Public Member Functions inherited from agx::Referenced
template<typename T >
static bool ValidateCast (const Referenced *object)
 
- Static Public Member Functions inherited from agxStream::Serializable
static void setEnableUuidGeneration (bool flag)
 Specify if there should be UUID:s generated for each new Serializable object. By default it is enabled.
 
- Public Attributes inherited from agx::Component
ObjectEvent addObjectEvent
 
ObjectEvent removeObjectEvent
 
- Static Protected Member Functions inherited from agx::Referenced
static DeleteHandlergetDeleteHandler ()
 
static void setDeleteHandler (DeleteHandler *handler)
 Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.
 
- Protected Attributes inherited from agx::Referenced
Mutex m_mutex
 
ObserverContainer m_observers
 
AtomicValue m_refCount
 

Detailed Description

This class contains all Geometries and performs Broad Phase and Narrow Phase collision detection to calculate overlapping Geometry pairs.

It also contains methods for explicit overlapping tests with rays etc.

Definition at line 85 of file Space.h.

Member Typedef Documentation

◆ GeometryPairHash

Definition at line 597 of file Space.h.

Member Enumeration Documentation

◆ BroadPhaseAlgorithm

Enum for specifying which BroadPhase algorithm space should use.

Enumerator
INVALID_BROAD_PHASE_ALGORITHM 
SWEEP_AND_PRUNE 

SAP good for scenes which are semi stationary.

Good for temporal coherency.

HIERARCHICAL_GRID 

Good for large scale scenes, particle systems where one can expect large motions between time steps.

Definition at line 90 of file Space.h.

Constructor & Destructor Documentation

◆ Space() [1/2]

agxCollide::Space::Space ( )

Default constructor.

◆ Space() [2/2]

agxCollide::Space::Space ( agx::Device device)

Instantiate Space with a specific device.

◆ ~Space()

virtual agxCollide::Space::~Space ( )
protectedvirtual

Destructor.

Member Function Documentation

◆ add()

bool agxCollide::Space::add ( Geometry geometry)

Insert a new geometry into the Space so it can collide with other geometries.

Returns
true if geometry is added successfully. False if geometry was already added.

◆ addGeometryContacts()

void agxCollide::Space::addGeometryContacts ( const LocalGeometryContactVector localContacts)

Explicitly add geometry contacts.

This must be done after Space::update(), and not from within a ContactEventListener; preferable via agxSDK::StepEventListener::pre(t). Contact materials are not automatically calculated; they must be explicitly set for each contact. Contacts without a contact material will be ignored. Impact state for each LocalGeometryContact has to be set manually by using the 'solveImpact'-member (default: on).

◆ addListener()

void agxCollide::Space::addListener ( agxCollide::SpaceListener listener)

Add a listener to space.

The listener will be signaled at add/remove geometry events.

◆ canCollide()

bool agxCollide::Space::canCollide ( const Geometry g1,
const Geometry g2 
) const

Check if two geometries can collide.

Following has to be true to make this method return true.

Both geometries have to be enabled if they belong to a group pair that is not disabled g1 != g2. collisions for g1 are not disabled against g2 (g1->setEnableCollisions(g2, false) if they both have a body, that it is not the same body.

Returns
true if the two geometries can collide.

Definition at line 870 of file Space.h.

References agx::SetVector< DataT, HashT >::contains(), and agx::RigidBody::getEnable().

◆ cleanup()

void agxCollide::Space::cleanup ( )

Cleanup the internal state of the object.

All Geometries will be removed one by one. The state after calling this method should be the same as creating a new object.

◆ commitRemovedContacts()

void agxCollide::Space::commitRemovedContacts ( )

Go through all the contact and contact points scheduled for removal and remove them from the list of contacts.

◆ computeNumberOfEnabledContactPoints()

size_t agxCollide::Space::computeNumberOfEnabledContactPoints ( ) const
Returns
the computed number of enabled geometry contact points in the simulation.

◆ disableForContacts()

template<typename F >
void agxCollide::Space::disableForContacts ( relevantCollision)
inline

If for some reason a geometry or several geometries collides with less geometries now than previously, we need to make sure that previous overlaps are removed, as they might remain otherwise.

Parameters
relevantCollisionA class that has the function const bool operator()(const agxCollide::Geometry*, const agxCollide::Geometry*) that returns whether or not the collision between the two geometries should be reevaluated

Definition at line 456 of file Space.h.

References agx::Vector< T, Allocator >::back(), agx::Container::empty(), agx::Physics::GeometryPairPtr::geometry1(), agx::Physics::GeometryPairPtr::geometry2(), agx::Physics::GeometryPtr::model(), agx::Vector< T, Allocator >::pop_back(), agx::Vector< T, Allocator >::push_back(), agx::Vector< T, Allocator >::reserve(), and agx::Container::size().

◆ enableForContacts()

template<typename F >
void agxCollide::Space::enableForContacts ( relevantCollision)
inline

If for some reason a geometry or several geometries collides with more geometries now than previously, we need to make sure that current overlaps are reported, as they might be ignored otherwise.

Parameters
relevantCollisionA class that has the function const bool operator()(const agxCollide::Geometry*, const agxCollide::Geometry*) that returns whether or not the collision between the two geometries should be reevaluated

Definition at line 426 of file Space.h.

◆ eraseDisabledGroupPair()

void agxCollide::Space::eraseDisabledGroupPair ( agx::UInt32  group1,
agx::UInt32  group2 
)

Consider using setEnablePair( group1, group2, true ) instead.

Similar to setEnablePair( group1, group2, true ) but this method doesn't look for (and adds) broad phase pairs matching the groups. I.e., this method isn't safe to use if you are unsure there are geometries overlapping matching the groups.

Parameters
group1- first group id
group2- second group id
See also
setEnablePair

◆ findDisabledCollisionsState()

agxCollide::DisabledCollisionsState agxCollide::Space::findDisabledCollisionsState ( ) const

Find the complete state of disabled collisions, including name <-> name pairs, id <-> id pairs and geometry <-> geometry pairs.

Returns
current disabled collisions state

◆ getBroadPhaseAlgorithm()

BroadPhaseAlgorithm agxCollide::Space::getBroadPhaseAlgorithm ( ) const
Returns
The active broad phase algorithm.

◆ getBroadPhasePairs()

const BroadPhasePairVector & agxCollide::Space::getBroadPhasePairs ( ) const
Returns
a vector of the current overlapping bounding volumes.

Definition at line 959 of file Space.h.

References agx::Vector< T, Allocator >::allocator(), and agxData::BufferProxyAllocator::update().

◆ getContact()

GeometryContact agxCollide::Space::getContact ( Geometry g1,
Geometry g2 
) const

Returns geometry contact between two geometries, if existing.

Parameters
g1The first geometry.
g2The second geometry.
Returns
Geometry contact between two geometries. If no matching geometry contact is found, an empty GeometryContact (GeometryContact()) will get returned. Thus, the return value should be checked for isValid() before being used.
Note
Works only for geometry contacts added by the general collision detection pipeline, not manually added ones; an alternative in that case is to use getGeometryContacts()).

◆ getContactReductionBinResolution()

agx::UInt agxCollide::Space::getContactReductionBinResolution ( ) const
Return values
Howmany bins per dimension for contact reduction between geometry pairs.

Definition at line 1002 of file Space.h.

◆ getContactReductionThreshold()

agx::UInt agxCollide::Space::getContactReductionThreshold ( ) const
Returns
Lower threshold number of contact points in a geometry contact in order run contact reduction on it.

◆ getDisabledPairs()

const GeometryPairHash & agxCollide::Space::getDisabledPairs ( ) const
Returns
an hashtable containing all pairs of disabled geometries

◆ getEnableContactReduction()

bool agxCollide::Space::getEnableContactReduction ( ) const
Returns
Is contact reduction for geometry pairs enabled?

Definition at line 997 of file Space.h.

◆ getEnablePair() [1/2]

bool agxCollide::Space::getEnablePair ( agx::UInt32  group1,
agx::UInt32  group2 
) const

Get information if group1 and group2 are allowed to collide.

Parameters
group1- First id
group2- Second id
Returns
true if the two groupID is allowed to collide, otherwise false.

Definition at line 954 of file Space.h.

◆ getEnablePair() [2/2]

bool agxCollide::Space::getEnablePair ( const agx::Name group1,
const agx::Name group2 
) const

Get information if group1 and group2 are allowed to collide.

Parameters
group1- First id
group2- Second id
Returns
true if the two groupID is allowed to collide, otherwise false.

Definition at line 947 of file Space.h.

◆ getGeometries()

const GeometryRefVector & agxCollide::Space::getGeometries ( ) const
Returns
vector of geometries which has been added to this space

Definition at line 942 of file Space.h.

◆ getGeometry() [1/4]

Geometry * agxCollide::Space::getGeometry ( const agx::Name name)

Find (linear search) the first Geometry in space with a matching name.

Parameters
name- name of geometry to search for
Returns
a pointer to the found Geometry, null if not found.

◆ getGeometry() [2/4]

const Geometry * agxCollide::Space::getGeometry ( const agx::Name name) const

Find (linear search) the first Geometry in space with a matching name.

Parameters
name- name of geometry to search for
Returns
a pointer to the found Geometry, null if not found.

◆ getGeometry() [3/4]

Geometry * agxCollide::Space::getGeometry ( const agx::Uuid uuid)

Find (linear search) the first Geometry in space matching the specified uuid.

Parameters
uuid- name of geometry to search for
Returns
a pointer to the found Geometry, null if not found.

◆ getGeometry() [4/4]

const Geometry * agxCollide::Space::getGeometry ( const agx::Uuid uuid) const

Find (linear search) the first Geometry in space matching the specified uuid.

Parameters
uuid- uuid of geometry to search for
Returns
a pointer to the found Geometry, null if not found.

◆ getGeometryContacts() [1/3]

const GeometryContactPtrVector & agxCollide::Space::getGeometryContacts ( ) const

Access to the vector containing all narrow phase contacts.

Returns
A reference to a vector with reference pointers to GeometryContact This vector contain pointers to GeometryContact which are valid during this simulation step only, so never store a pointer to them and use them over several time steps.

◆ getGeometryContacts() [2/3]

size_t agxCollide::Space::getGeometryContacts ( GeometryContactPtrVector matches,
const agx::RigidBody body1,
const agx::RigidBody body2 = nullptr 
) const

Extract a vector with all matching geometry contacts involving the two specified rigid bodies This method will perform a linear search through all contact points.

Parameters
body1- The first specified rigid body to search for among geometry contacts
body2- The second specified rigid body to search for among geometry contacts (if null only match body1)
matches- a vector with all matching geometry contact points This vector contain pointers to GeometryContact which are valid during this simulation step only, so never store a pointer to them and use them over several time steps.
Returns
number of matching geometry contacts

◆ getGeometryContacts() [3/3]

size_t agxCollide::Space::getGeometryContacts ( GeometryContactPtrVector matches,
const agxCollide::Geometry geometry1,
const agxCollide::Geometry geometry2 = nullptr 
) const

Extract a vector with all matching geometry contacts involving the two specified geometries.

This method will perform a linear search through all contact points.

Parameters
geometry1- The first specified geometry to search for among geometry contacts
geometry2- The second specified geometry to search for among geometry contacts (if null only match geometry1)
matches- a vector with all matching geometry contact points This vector contain pointers to GeometryContact which are valid during this simulation step only, so never store a pointer to them and use them over several time steps.
Returns
number of matching geometry contacts

◆ getGeometryWithEntityId() [1/2]

Geometry * agxCollide::Space::getGeometryWithEntityId ( agx::Index  id)

Return Geometry in space matching the specified id.

Note that the id specified here is the internal id of a geometry entity and not the id of the high level geometry object as returned by Geometry::getId()

Parameters
id- Entity id of geometry
Returns
a pointer to the corresponding Geometry, null if id is not in space or is invalid.

◆ getGeometryWithEntityId() [2/2]

const Geometry * agxCollide::Space::getGeometryWithEntityId ( agx::Index  id) const

Return Geometry in space matching the specified id.

Note that the id specified here is the internal id of a geometry entity and not the id of the high level geometry object as returned by Geometry::getId()

Parameters
id- Entity id of geometry
Returns
a pointer to the corresponding Geometry, null if id is not in space or is invalid.

◆ getHierarchicalGrid()

HierarchicalGrid * agxCollide::Space::getHierarchicalGrid ( )
Returns
The hierarchical grid.

Definition at line 1012 of file Space.h.

◆ getOrientedBoundsThreshold()

agx::Real agxCollide::Space::getOrientedBoundsThreshold ( ) const

Returns the current threshold for where oriented bounds are created for Geometries.

Definition at line 1007 of file Space.h.

◆ getParticleGeometryContacts()

const ParticleGeometryContactVector & agxCollide::Space::getParticleGeometryContacts ( )
Returns
the current ParticleGeometryContacts in the simulation

◆ getParticleParticleContacts()

const ParticlePairContactVector & agxCollide::Space::getParticleParticleContacts ( )
Returns
the current ParticleParticle contacts in the simulation

◆ getSeparationPairs() [1/3]

const SeparationPairVector & agxCollide::Space::getSeparationPairs ( ) const
Returns
a vector of the geometries which are no longer overlapping (could still have overlapping bounding volumes)

Definition at line 965 of file Space.h.

References agx::Vector< T, Allocator >::allocator(), and agxData::BufferProxyAllocator::update().

◆ getSeparationPairs() [2/3]

size_t agxCollide::Space::getSeparationPairs ( agx::Physics::GeometryPairPtrVector matches,
const agx::RigidBody body1,
const agx::RigidBody body2 = nullptr 
) const

Extract a new vector including rigid bodies which just recently separated.

Parameters
body1- Specifies the first rigid body to search for among the separation pairs
body2- Specifies the second rigid body to search for among the separation pairs, if nullptr then only match geometry1
matches- a vector of the geometries which are no longer overlapping (could still have overlapping bounding volumes)
Returns
size of matching vector

◆ getSeparationPairs() [3/3]

size_t agxCollide::Space::getSeparationPairs ( agx::Physics::GeometryPairPtrVector matches,
const agxCollide::Geometry geometry1,
const agxCollide::Geometry geometry2 = nullptr 
) const

Extract a new vector including geometries which just recently separated.

Parameters
geometry1- Specifies the first geometry to search for among the separation pairs
geometry2- Specifies the second geometry to search for among the separation pairs, if nullptr then only match geometry1
matches- a vector of the geometries which are no longer overlapping (could still have overlapping bounding volumes)
Returns
size of matching vector

◆ getSweepAndPrune()

agxCollide::SweepAndPrune * agxCollide::Space::getSweepAndPrune ( )
Returns
a pointer to the Sweep and prune implementation.

◆ getUniqueGroupID()

agx::UInt32 agxCollide::Space::getUniqueGroupID ( )
Returns
a unique group ID starting from 2^31

◆ insertDisabledGroupPair()

void agxCollide::Space::insertDisabledGroupPair ( agx::UInt32  group1,
agx::UInt32  group2 
)

Consider using setEnablePair( group1, group2, false ) instead.

Similar to setEnablePair( group1, group2, false ) but this method doesn't look for (and removes) broad phase pairs matching the groups. I.e., this method isn't safe to use if you are unsure there are geometries overlapping matching the groups.

Parameters
group1- first group id
group2- second group id
See also
setEnablePair

◆ intersect()

bool agxCollide::Space::intersect ( const agx::Vec3 point,
const agx::Vec3 direction,
LocalGeometryContactVector geometryContacts,
LocalParticleGeometryContactVector particleGeometryContacts,
const agx::Real  length = FLT_MAX/4 
)

Sends a ray into the collision space and returns information about the objects the ray hits.

The ray does not have to hit anything and the returned contact data can be empty.

Parameters
pointstart point of the ray
directionDirection of the ray
geometryContactsA GeometryContactPtrVector where contact data will be stored for the objects the ray intersected the objects are sorted closest to furthest away
particleGeometryContactsA GeometryContactPtrVector where contact data will be stored for the objects the ray intersected the objects are sorted closest to furthest away
lengthMax length of ray, objects further away than length will not be hit even if they are in the path of the ray
Returns
true if at least one object was intersected, otherwise false

◆ remove()

bool agxCollide::Space::remove ( Geometry geometry)

Remove a geometry from Space.

Parameters
geometry- Pointer to a Geometry that will be removed
Returns
true if geometry existed in space and was successfully removed

◆ removeContact() [1/2]

void agxCollide::Space::removeContact ( agx::Physics::GeometryContactPtr  contact)

Schedule a removal of a specified Narrow phase contact, the contact will not be removed until the method commitRemovedContacts() is called (during the next update())

Parameters
contact- Remove the specified contact.

Definition at line 971 of file Space.h.

References agx::Physics::GeometryContactPtr::enabled().

◆ removeContact() [2/2]

Remove a specified GeometryContact from the list of contacts.

It is important that this iterator is valid, i.e. accessed during the same time step and that the list of contacts is not modified since it is acquired.

Parameters
contact- iterator taken from the getGeometryContacts() at the same time step.

◆ removeListener()

bool agxCollide::Space::removeListener ( agxCollide::SpaceListener listener)

Remove a listener from Space.

Returns
true if removal was successful

◆ removeOverlap()

void agxCollide::Space::removeOverlap ( agxCollide::Geometry geometry1,
agxCollide::Geometry geometry2 
)

Remove a (Sweep and Prune) bounding overlap, if it exists, between geometry1 and geoemtry2.

It doesn't matter in which order the two geometries are passed to this method.

Parameters
geometry1- first geometry
geometry2- second geometry

Definition at line 985 of file Space.h.

◆ reportOverlap()

void agxCollide::Space::reportOverlap ( agxCollide::Geometry geometry1,
agxCollide::Geometry geometry2 
)

Add an explicit bounding volume overlap between the two specified geometries.

Parameters
geometry1,geometry2- The two geometries in the new Broad phase overlap.

Definition at line 977 of file Space.h.

References agxCollide::Geometry::isEnabled().

◆ resetGeometryCellAssignments()

void agxCollide::Space::resetGeometryCellAssignments ( agxCollide::Geometry geometry)

◆ resetParticleCellAssignments()

void agxCollide::Space::resetParticleCellAssignments ( )

◆ setBroadPhaseAlgorithm()

bool agxCollide::Space::setBroadPhaseAlgorithm ( BroadPhaseAlgorithm  algorithm)

Specify a new broad phase algorithm implementation.

Returns
false if the algorithm can't be changed, eg if using ParallelPGS solver, or particle system, which both require the HIERARCHICAL_GRID

◆ setContactReductionBinResolution()

void agxCollide::Space::setContactReductionBinResolution ( agx::UInt  binResolution)

Specify the default (for this Simulation) resolution used when evaluating contacts for reduction between geometry-geometry contacts.

A high value will keep more contacts, lower will result in more aggressive reduction the default. If no resolution is specified per material this value will be used. Commonly a value of 2-3 will give good results. Values from 1 to 10 are valid. This value will be used for all geometry contacts where either no contact material is set, or where the ContactReductionBinResolution of the contact material is 0.

Parameters
binResolution- parameter to ContactReducer.

◆ setContactReductionThreshold()

void agxCollide::Space::setContactReductionThreshold ( agx::UInt  threshold)

Specify the lower threshold for the number of contact points needed per geometry contact in order to do contact reduction per geometry contact.

Parameters
threshold- Lower threshold for number of contact points in a geometry contact in order run contact reduction on it.

◆ setEnableCollisions()

void agxCollide::Space::setEnableCollisions ( const Geometry g1,
const Geometry g2,
bool  flag 
)

Explicitly disable/enable a geometry pair.

◆ setEnableContactReduction()

void agxCollide::Space::setEnableContactReduction ( bool  flag)

Enable/Disable contact reduction between pairs of geometries.

Parameters
flag- if true, contact reduction is enabled.

◆ setEnableGeometry()

void agxCollide::Space::setEnableGeometry ( Geometry geometry,
bool  flag 
)

◆ setEnablePair() [1/2]

void agxCollide::Space::setEnablePair ( agx::UInt32  group1,
agx::UInt32  group2,
bool  flag 
)

Enable/disable collisions between two geometry group ID:s.

This can be used to group Geometries into separate collision groups, where collisions can be enabled/disabled between the different GeometryID groups.

The largest number for a group ID is defined to be 2^31 - 1 (2 147 483 647), the rest are reserved by space and can be accessed via getUniqueGroupID().

Parameters
group1- First group id
group2- Second group id
flag- If true, the geometries in groupID1 and groupID2 can collide, otherwise not.

◆ setEnablePair() [2/2]

void agxCollide::Space::setEnablePair ( const agx::Name group1,
const agx::Name group2,
bool  flag 
)

◆ setOrientedBoundsThreshold()

void agxCollide::Space::setOrientedBoundsThreshold ( agx::Real  threshold)

Sets the threshold where oriented bounds are created for Geometries.

Changing the value will create or destroy oriented bounds as necessary for already created Geometries.

◆ testBoundingVolumeOverlap()

bool agxCollide::Space::testBoundingVolumeOverlap ( GeometryPtrVector testGeometries,
GeometryPairVector geometryPairs,
ParticleGeometryPairVector particleGeometryPairs,
bool  skip = true 
)

Tests a number of geometries for bounding volume overlaps without changing the geometries already in space besides from updating bounding volumes.

Parameters
testGeometries- The vector with geometries that should be tested for overlaps. These may be rearranged to speed up testing.
geometryPairs- The geometry pairs which have overlapping bounding volumes
particleGeometryPairs- The particle-geometry pairs which have overlapping bounding volumes
skip- If true, skip collisions between geometries that both are in the testGeometries vector. Useful when some geometries are already added to space.
Returns
true if any overlaps were found.

◆ testGeometryOverlap()

bool agxCollide::Space::testGeometryOverlap ( GeometryPtrVector testGeometries,
LocalGeometryContactVector geometryContacts,
LocalParticleGeometryContactVector particleGeometryContacts,
bool  skip = true 
)

Test if a number of geometries collides with something already present in space without changing space, besides from updating some bounding volumes.

Parameters
testGeometriesThe vector with geometries that should be tested for overlaps. These may be rearranged to speed up testing.
geometryContacts- The geometry contacts that were found
particleGeometryContacts- The particle-geometry contacts that were found
skip- If true, skip collisions between geometries that both are in the testGeometries vector. Useful when some geometries are already added to space.
Returns
True if any overlaps were found.

◆ update()

void agxCollide::Space::update ( )

Update the contact state of the entire space including Broad Phase and narrow phase.

◆ updateBroadPhase()

void agxCollide::Space::updateBroadPhase ( )

Update the broad-phase state of the space.

◆ updateNarrowPhase()

void agxCollide::Space::updateNarrowPhase ( )

Update the narrow phase state, calculating contact data for all overlapping geometry pairs.

i.e. check all current bounding box overlaps for possible contacts


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