87 INVALID_BROAD_PHASE_ALGORITHM = -1,
357 bool getEnableContactReduction()
const;
360 agx::UInt getContactReductionBinResolution()
const;
417 template<
typename F >
422 for (
agx::UInt i = 0, numGeometries = m_geometries.size(); !m_geometries.empty() && i < numGeometries - 1; ++i ) {
423 for (
agx::UInt j = i + 1; j < numGeometries; ++j ) {
429 if ( relevantCollision(m_geometries[ i ], m_geometries[ j ] ) &&
431 canCollide( m_geometries[ i ], m_geometries[ j ] ) &&
432 m_geometries[ i ]->getBoundingVolume()->hasOverlap( *m_geometries[ j ]->getBoundingVolume() ) ) {
433 reportOverlap( m_geometries[ i ], m_geometries[ j ] );
447 template<
typename F >
457 for (
agx::UInt i = 0, numBroadPhasePairs = broadPhasePairs.
size(); i < numBroadPhasePairs; ++i ) {
463 while ( !pairsToRemove.
empty() ) {
465 m_sweepAndPrune->removePair( pairsToRemove.
back().first, pairsToRemove.
back().second );
520 agx::Real getOrientedBoundsThreshold()
const;
627 void synchronizeTransforms();
632 void synchronizeBounds();
637 void printContacts(const
agx::
String& title);
642 agxData::EntityStorage* getShapeStorage(
agxData::EntityModel* shapeModel);
644 agxData::EntityStorage *getGeometryStorage();
646 agxData::EntityStorage* getGeometryContactStorage();
647 agxData::EntityStorage* getContactPointStorage();
648 agxData::EntityStorage* getOrientedGeometryBoundStorage();
650 void setEnableParticleGridTasks(
bool flag);
651 void optimizeGridCellFitting();
654 agx::TaskGroup* getUpdateTask();
663 static
agx::Model* ClassModel();
667 typedef
agx::SymmetricPair<
unsigned> GeometryIDPair;
670 class SpaceSerializer : public
agxStream::Serializable
684 DisablePairVector m_disabledGeometryIDPairs;
688 SpaceSerializer( ) : m_space(nullptr) {}
689 const Space* m_space;
693 friend class SpaceSerializer;
710 void restore( const SpaceSerializer& ss );
712 void commitNewOverlaps();
721 template <typename T1, typename T2>
722 void calculateNarrowPhase(BroadPhasePair* pair, T1& contactContainer, T2& separationContainer);
724 void createGeometryContacts();
725 void startUpdateTimer(
agx::Task* task);
726 void stopUpdateTimerAndReport(
agx::Task* task);
727 void createShapeStorage(const
agx::Path& entityPath);
728 void updateContactState();
729 void createMissingContactMaterials();
730 void updateSweepAndPrune();
733 agx::Task* createSynchronizeTransformsTask();
734 agx::Task* createSynchronizeBoundsTask();
736 agx::Task* createUpdateNarrowPhaseTask( const
agx::
String& implementation = "");
737 agx::Task* createUpdateContactStateTask();
739 void createParticlePairContacts();
740 void createParticleGeometryContacts();
748 bool removeSweepAndPrune();
751 friend class
agxSDK::SimulationFrameWriter;
801 agx::Timer m_updateTimer;
802 agx::Task::ExecutionEvent::CallbackType m_startUpdateTimerCallback;
803 agx::Task::ExecutionEvent::CallbackType m_stopUpdateTimerAndReportCallback;
827 agxData::Buffer::
Event::CallbackType m_shapeTransformReallocationCallback;
850 agxData::Value::
Event::CallbackType m_gridCellSizeAlignmentCallback;
851 void gridCellSizeAlignmentCallback(
agxData::Value* sizeAlignment);
867 if (!(g1->isEnabled() && g2->isEnabled()))
870 if (!(g1->getEnableCollisions() && g2->getEnableCollisions()))
881 if (rb1 && (rb1 == rb2))
891 if (groupSet1 && groupSet2 && g1->getSpace() ==
this && g2->getSpace() ==
this && !m_collisionGroupManager->canSetsCollide(groupSet1, groupSet2))
901 return m_orientedGeometryBoundStorage;
906 return m_geometryContactStorage;
911 return m_contactPointStorage;
917 return m_collisionGroupManager;
920 AGX_FORCE_INLINE const CollisionGroupManager* Space::getCollisionGroupManager()
const
922 return m_collisionGroupManager;
936 return this->getEnablePair(
937 m_collisionGroupManager->getGroupId(group1),
938 m_collisionGroupManager->getGroupId(group2));
943 return m_collisionGroupManager->canGroupsCollide(group1, group2);
949 return m_broadPhasePairVector;
955 return m_separationPairVector;
966 if ( geometry1 == 0L || geometry2 == 0L || !geometry1->
isEnabled() || !geometry2->
isEnabled() )
974 if ( m_sweepAndPrune == 0L || geometry1 == 0L || geometry2 == 0L )
978 if ( it != m_externallyReportedPairs.end() )
979 m_externallyReportedPairs.erase( it );
981 m_sweepAndPrune->removePair( geometry1, geometry2 );
986 return m_contactReductionEnable->get();
991 return m_contactReductionBinResolution->get();
996 return m_orientedBoundsThreshold->get();
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
#define AGXPHYSICS_EXPORT
Complete disabled collisions state in a simulation including disabled given name, group id (integer) ...
The geometry representation used by the collision detection engine.
bool isEnabled() const
Alias for getEnable Return whether the geometry should be used in intersection tests.
Class for listening for add/remove geometry events for an associated Space.
This class contains all Geometries and performs Broad Phase and Narrow Phase collision detection to c...
Space()
Default constructor.
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 ...
void updateBroadPhase()
Update the broad-phase state of the space.
bool remove(Geometry *geometry)
Remove a geometry from Space.
Geometry * getGeometry(const agx::Name &name)
Find (linear search) the first Geometry in space with a matching name.
void setEnablePair(agx::UInt32 group1, agx::UInt32 group2, bool flag)
Enable/disable collisions between two geometry group ID:s.
agx::UInt getContactReductionBinResolution() const
void eraseDisabledGroupPair(agx::UInt32 group1, agx::UInt32 group2)
Consider using setEnablePair( group1, group2, true ) instead.
const BroadPhasePairVector & getBroadPhasePairs() 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 computeNumberOfEnabledContactPoints() const
const ParticlePairContactVector & getParticleParticleContacts()
void resetGeometryCellAssignments(agxCollide::Geometry *geometry)
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.
void setContactReductionBinResolution(agx::UInt binResolution)
Specify the default (for this Simulation) resolution used when evaluating contacts for reduction betw...
Space(agx::Device *device)
Instantiate Space with a specific device.
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.
agxCollide::SweepAndPrune * getSweepAndPrune()
bool add(Geometry *geometry)
Insert a new geometry into the Space so it can collide with other geometries.
void setEnableGeometry(Geometry *geometry, bool flag)
void setContactReductionThreshold(agx::UInt threshold)
Specify the lower threshold for the number of contact points needed per geometry contact in order to ...
const ParticleGeometryContactVector & getParticleGeometryContacts()
void removeOverlap(agxCollide::Geometry *geometry1, agxCollide::Geometry *geometry2)
Remove a (Sweep and Prune) bounding overlap, if it exists, between geometry1 and geoemtry2.
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 me...
agx::UInt32 getUniqueGroupID()
const SeparationPairVector & getSeparationPairs() const
const Geometry * getGeometry(const agx::Name &name) const
Find (linear search) the first Geometry in space with a matching name.
const GeometryContactPtrVector & getGeometryContacts() const
Access to the vector containing all narrow phase contacts.
void addGeometryContacts(const LocalGeometryContactVector &localContacts)
Explicitly add geometry contacts.
GeometryContact getContact(Geometry *g1, Geometry *g2) const
Returns geometry contact between two geometries, if existing.
void cleanup()
Cleanup the internal state of the object.
BroadPhaseAlgorithm
Enum for specifying which BroadPhase algorithm space should use.
@ SWEEP_AND_PRUNE
SAP good for scenes which are semi stationary.
void setEnablePair(const agx::Name &group1, const agx::Name &group2, bool flag)
bool removeListener(agxCollide::SpaceListener *listener)
Remove a listener from Space.
void reportOverlap(agxCollide::Geometry *geometry1, agxCollide::Geometry *geometry2)
Add an explicit bounding volume overlap between the two specified geometries.
void setEnableContactReduction(bool flag)
Enable/Disable contact reduction between pairs of geometries.
bool getEnableContactReduction() const
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.
const Geometry * getGeometry(agx::Index id) const
Find (linear search) the first Geometry in space matching the specified id.
agxCollide::DisabledCollisionsState findDisabledCollisionsState() const
Find the complete state of disabled collisions, including name <-> name pairs, id <-> id pairs and ge...
void disableForContacts(F relevantCollision)
If for some reason a geometry or several geometries collides with less geometries now than previously...
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 spac...
BroadPhaseAlgorithm getBroadPhaseAlgorithm() const
Geometry * getGeometry(agx::Index id)
Find (linear search) the first Geometry in space matching the specified id.
bool setBroadPhaseAlgorithm(BroadPhaseAlgorithm algorithm)
Specify a new broad phase algorithm implementation.
void resetParticleCellAssignments()
void insertDisabledGroupPair(agx::UInt32 group1, agx::UInt32 group2)
Consider using setEnablePair( group1, group2, false ) instead.
HierarchicalGrid * getHierarchicalGrid()
void update()
Update the contact state of the entire space including Broad Phase and narrow phase.
agx::Real getOrientedBoundsThreshold() const
Returns the current threshold for where oriented bounds are created for Geometries.
void enableForContacts(F relevantCollision)
If for some reason a geometry or several geometries collides with more geometries now than previously...
void commitRemovedContacts()
Go through all the contact and contact points scheduled for removal and remove them from the list of ...
const Geometry * getGeometry(const agx::Uuid &uuid) const
Find (linear search) the first Geometry in space matching the specified uuid.
void setOrientedBoundsThreshold(agx::Real threshold)
Sets the threshold where oriented bounds are created for Geometries.
agx::UInt getContactReductionThreshold() const
agx::SetVector< GeometryPair > GeometryPairHash
bool getEnablePair(agx::UInt32 group1, agx::UInt32 group2) const
Get information if group1 and group2 are allowed to collide.
void updateNarrowPhase()
Update the narrow phase state, calculating contact data for all overlapping geometry pairs.
void addListener(agxCollide::SpaceListener *listener)
Add a listener to space.
GeometryContactPtrVector::const_iterator removeContact(GeometryContactPtrVector::const_iterator contact)
Remove a specified GeometryContact from the list of contacts.
const GeometryPairHash & getDisabledPairs() const
void setEnableCollisions(const Geometry *g1, const Geometry *g2, bool flag)
Explicitly disable/enable a geometry pair.
Geometry * getGeometry(const agx::Uuid &uuid)
Find (linear search) the first Geometry in space matching the specified uuid.
Data storage for a collection of entity instances of a specified EntityModel.
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
const agxCollide::GeometryRefVector & getGeometries() const
void clearContactData()
Clears contact data in the simulation.
bool restore(const agx::String &filename, agx::UInt selection=READ_DEFAULT)
Restore state from a serialized scene file.
void garbageCollect()
Use with caution!
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
A component is an object containing other objects, enabling hierarchical structuring.
An agx::Device is an abstract representation of a device on which data can be stored and processed.
Inheritance with partial specialization due to bug with ref_ptr containers.
Representation of a name string.
Pointer to a entity instance of type Physics.BroadPhasePair.
Pointer to a entity instance of type Physics.CollisionGroupSet.
AGXPHYSICS_EXPORT agx::Physics::GeometryPtr & geometry1()
AGXPHYSICS_EXPORT agx::Physics::GeometryPtr & geometry2()
AGXPHYSICS_EXPORT agxCollide::Geometry *& model()
Inheritance with partial specialization due to bug with ref_ptr containers.
The rigid body class, combining a geometric model and a frame of reference.
bool getEnable() const
Access the state enable flag.
bool contains(const T2 &key) const
Hash search for the data in the container.
A std::pair, with both elements of the same type, and symmetric so (a, b) == (b, a)
A UUID, or Universally unique identifier, is intended to uniquely identify information in a distribut...
const GeometryContact * * const_iterator
void reserve(size_t size)
Reserve capacity in the vector.
void push_back(const T2 &value)
#define DOXYGEN_END_INTERNAL_BLOCK()
#define DOXYGEN_START_INTERNAL_BLOCK()
This namespace consists of a set of classes for handling geometric intersection tests including boole...
agx::Vector< agx::Physics::ParticlePairContactPtr > ParticlePairContactVector
agx::Vector< agx::Physics::GeometryPairPtr, agxData::BufferProxyAllocator > SeparationPairVector
AGX_DECLARE_POINTER_TYPES(SpaceListener)
agx::Vector< agx::Physics::GeometryPairPtr > LocalSeparationPairVector
agx::Vector< agx::Physics::BroadPhasePairPtr, agxData::BufferProxyAllocator > BroadPhasePairVector
agx::Vector< agx::Physics::ParticleGeometryContactPtr > ParticleGeometryContactVector
std::pair< agx::Physics::ParticlePtr, agx::Physics::GeometryPtr > ParticleGeometryPair
agx::Vector< ParticleGeometryPair > ParticleGeometryPairVector
Contains classes for low level data storage for AGX.
agx::SymmetricPair< agx::Physics::GeometryPtr > GeometryPair
agx::ref_ptr< Buffer > BufferRef
agx::ref_ptr< EntityStorage > EntityStorageRef
The agxIO namespace contains classes for reading, writing and finding files.
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
This namespace contain classes for streaming classes into archives, ASCII, binary for storage (serial...
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
agx::ref_ptr< Task > TaskRef
AgXString< std::string > String
agx::ref_ptr< TaskGroup > TaskGroupRef
LinearProbingHashTable< KeyT, DataT, HashT, AllocatorT > HashTable
void AGXPHYSICS_EXPORT init()
Initialize agx.