87 INVALID_BROAD_PHASE_ALGORITHM = -1,
242 GeometryContactPtrVector::const_iterator
removeContact(GeometryContactPtrVector::const_iterator contact);
361 bool getEnableContactReduction()
const;
364 agx::UInt getContactReductionBinResolution()
const;
421 template<
typename F >
426 for (
agx::UInt i = 0, numGeometries = m_geometries.size(); !m_geometries.empty() && i < numGeometries - 1; ++i ) {
427 for (
agx::UInt j = i + 1; j < numGeometries; ++j ) {
433 if ( relevantCollision(m_geometries[ i ], m_geometries[ j ] ) &&
435 canCollide( m_geometries[ i ], m_geometries[ j ] ) &&
436 m_geometries[ i ]->getBoundingVolume()->hasOverlap( *m_geometries[ j ]->getBoundingVolume() ) ) {
437 reportOverlap( m_geometries[ i ], m_geometries[ j ] );
451 template<
typename F >
461 for (
agx::UInt i = 0, numBroadPhasePairs = broadPhasePairs.
size(); i < numBroadPhasePairs; ++i ) {
467 while ( !pairsToRemove.
empty() ) {
469 m_sweepAndPrune->removePair( pairsToRemove.
back().first, pairsToRemove.
back().second );
524 agx::Real getOrientedBoundsThreshold()
const;
631 void synchronizeTransforms();
636 void synchronizeBounds();
641 void printContacts(const
agx::String& title);
646 agxData::EntityStorage* getShapeStorage(
agxData::EntityModel* shapeModel);
648 agxData::EntityStorage *getGeometryStorage();
650 agxData::EntityStorage* getGeometryContactStorage();
651 agxData::EntityStorage* getContactPointStorage();
652 agxData::EntityStorage* getOrientedGeometryBoundStorage();
654 void setEnableParticleGridTasks(
bool flag);
655 void optimizeGridCellFitting();
658 agx::TaskGroup* getUpdateTask();
667 static
agx::Model* ClassModel();
671 typedef
agx::SymmetricPair<
unsigned> GeometryIDPair;
674 class SpaceSerializer : public
agxStream::Serializable
688 DisablePairVector m_disabledGeometryIDPairs;
692 SpaceSerializer( ) : m_space(nullptr) {}
693 const Space* m_space;
697 friend class SpaceSerializer;
709 void clearContactData();
712 void garbageCollect(
bool clearGcList = true);
714 void restore( const SpaceSerializer& ss );
716 void commitNewOverlaps();
725 template <typename T1, typename T2>
726 void calculateNarrowPhase(BroadPhasePair* pair, T1& contactContainer, T2& separationContainer);
728 void createGeometryContacts();
729 void startUpdateTimer(
agx::Task* task);
730 void stopUpdateTimerAndReport(
agx::Task* task);
731 void createShapeStorage(const
agx::Path& entityPath);
732 void updateContactState();
733 void createMissingContactMaterials();
734 void updateSweepAndPrune();
737 agx::Task* createSynchronizeTransformsTask();
738 agx::Task* createSynchronizeBoundsTask();
740 agx::Task* createUpdateNarrowPhaseTask( const
agx::String& implementation = "");
741 agx::Task* createUpdateContactStateTask();
743 void createParticlePairContacts();
744 void createParticleGeometryContacts();
752 bool removeSweepAndPrune();
755 friend class
agxSDK::SimulationFrameWriter;
763 agx::TaskGroupRef m_updateTask;
764 agx::TaskRef m_synchronizeTransformsTask;
765 agx::TaskRef m_synchronizeBoundsTask;
766 agx::TaskRef m_updateBroadPhaseTask;
767 agx::TaskRef m_updateNarrowPhaseTask;
768 agx::TaskRef m_updateContactStateTask;
769 agx::TaskRef m_createMissingMaterialsTask;
771 agx::TaskRef m_synchronizeTransformsTask2;
772 agx::TaskRef m_synchronizeBoundsTask2;
773 agx::TaskRef m_updateBroadPhaseTask2;
774 agx::TaskRef m_updateNarrowPhaseTask2;
775 agx::TaskRef m_updateContactStateTask2;
776 agx::TaskRef m_createMissingMaterialsTask2;
781 agxData::EntityStorageRef m_geometryStorage;
782 agxData::EntityStorageRef m_geometryContactStorage;
783 agxData::EntityStorageRef m_contactPointStorage;
784 agxData::EntityStorageRef m_broadPhasePairStorage;
785 agxData::EntityStorageRef m_geometryContactSeparations;
786 agxData::EntityStorageRef m_orientedGeometryBoundStorage;
787 agxData::BufferRef m_materialLessGeometryContacts;
788 agxData::BufferRef m_sortedGeometryContacts;
789 agxData::BufferRef m_sortedSeparationPairs;
790 agxData::BufferRef m_filteredBroadPhasePairs;
805 agx::Timer m_updateTimer;
806 agx::Task::ExecutionEvent::CallbackType m_startUpdateTimerCallback;
807 agx::Task::ExecutionEvent::CallbackType m_stopUpdateTimerAndReportCallback;
809 agxData::ValueRefT<
agx::Bool> m_contactReductionEnable;
810 agxData::ValueRefT<
agx::UInt> m_contactReductionBinResolution;
811 agxData::ValueRefT<
agx::UInt> m_contactReductionThreshold;
812 agxData::ValueRefT<
agx::UInt> m_narrowPhaseMinJobSize;
814 agxData::ValueRefT<
agx::Real> m_orientedBoundsThreshold;
820 agxData::BufferRef m_geometryContactInstanceBuffer;
821 agxData::BufferRef m_contactPointInstanceBuffer;
831 agxData::Buffer::
Event::CallbackType m_shapeTransformReallocationCallback;
834 agxData::EntityStorageRef m_collisionObjectStorage;
835 agxData::BufferRef m_collisionObjectBuffer_sourceIndex;
836 agxData::BufferRef m_collisionObjectBuffer_subsystem;
837 agxData::BufferRef m_collisionObjectBuffer_position;
838 agxData::BufferRef m_collisionObjectBuffer_radius;
839 agxData::BufferRef m_collisionObjectBuffer_obbIndex;
841 agxData::BufferRef m_gridOvelapBuffer_collisionObject1;
842 agxData::BufferRef m_gridOvelapBuffer_collisionObject2;
844 agx::TaskRef m_overlapTestTask;
848 typedef
agx::HashTableComponent<
agxData::GeometryPair,
agx::Physics::GeometryContactPtr> GridContactTableComponent;
854 agxData::Value::
Event::CallbackType m_gridCellSizeAlignmentCallback;
855 void gridCellSizeAlignmentCallback(
agxData::Value* sizeAlignment);
871 if (!(g1->isEnabled() && g2->isEnabled()))
874 if (!(g1->getEnableCollisions() && g2->getEnableCollisions()))
885 if (rb1 && (rb1 == rb2))
895 if (groupSet1 && groupSet2 && g1->getSpace() ==
this && g2->getSpace() ==
this && !m_collisionGroupManager->canSetsCollide(groupSet1, groupSet2))
905 return m_orientedGeometryBoundStorage;
910 return m_geometryContactStorage;
915 return m_contactPointStorage;
921 return m_collisionGroupManager;
924 AGX_FORCE_INLINE const CollisionGroupManager* Space::getCollisionGroupManager()
const
926 return m_collisionGroupManager;
940 return this->getEnablePair(
941 m_collisionGroupManager->getGroupId(group1),
942 m_collisionGroupManager->getGroupId(group2));
947 return m_collisionGroupManager->canGroupsCollide(group1, group2);
953 return m_broadPhasePairVector;
959 return m_separationPairVector;
970 if ( geometry1 == 0L || geometry2 == 0L || !geometry1->
isEnabled() || !geometry2->
isEnabled() )
978 if ( m_sweepAndPrune == 0L || geometry1 == 0L || geometry2 == 0L )
982 if ( it != m_externallyReportedPairs.end() )
983 m_externallyReportedPairs.erase( it );
985 m_sweepAndPrune->removePair( geometry1, geometry2 );
990 return m_contactReductionEnable->get();
995 return m_contactReductionBinResolution->get();
1000 return m_orientedBoundsThreshold->get();
#define AGX_DECLARE_POINTER_TYPES(type)
#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.
void setEnablePair(agx::UInt32 group1, agx::UInt32 group2, bool flag)
Enable/disable collisions between two geometry group ID:s.
void eraseDisabledGroupPair(agx::UInt32 group1, agx::UInt32 group2)
Consider using setEnablePair( group1, group2, true ) instead.
agxCollide::SweepAndPrune * getSweepAndPrune()
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
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.
bool add(Geometry *geometry)
Insert a new geometry into the Space so it can collide with other geometries.
Geometry * getGeometry(const agx::Name &name)
Find (linear search) the first Geometry in space with a matching name.
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 GeometryPairHash & getDisabledPairs() const
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()
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 setEnableContactReduction(bool flag)
Enable/Disable contact reduction between pairs of geometries.
const Geometry * getGeometry(const agx::Uuid &uuid) const
Find (linear search) the first Geometry in space matching the specified uuid.
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.
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
bool setBroadPhaseAlgorithm(BroadPhaseAlgorithm algorithm)
Specify a new broad phase algorithm implementation.
void resetParticleCellAssignments()
Geometry * getGeometryWithEntityId(agx::Index id)
Return Geometry in space matching the specified id.
void insertDisabledGroupPair(agx::UInt32 group1, agx::UInt32 group2)
Consider using setEnablePair( group1, group2, false ) instead.
void update()
Update the contact state of the entire space including Broad Phase and narrow phase.
void enableForContacts(F relevantCollision)
If for some reason a geometry or several geometries collides with more geometries now than previously...
const ParticlePairContactVector & getParticleParticleContacts()
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::Name &name) const
Find (linear search) the first Geometry in space with a matching name.
const Geometry * getGeometryWithEntityId(agx::Index id) const
Return Geometry in space matching the specified id.
const ParticleGeometryContactVector & getParticleGeometryContacts()
const GeometryContactPtrVector & getGeometryContacts() const
Access to the vector containing all narrow phase contacts.
void setOrientedBoundsThreshold(agx::Real threshold)
Sets the threshold where oriented bounds are created for Geometries.
agx::UInt getContactReductionThreshold() const
agx::SetVector< GeometryPair > GeometryPairHash
Geometry * getGeometry(const agx::Uuid &uuid)
Find (linear search) the first Geometry in space matching the specified uuid.
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.
void setEnableCollisions(const Geometry *g1, const Geometry *g2, bool flag)
Explicitly disable/enable a geometry pair.
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...
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 & geometry2()
AGXPHYSICS_EXPORT agx::Physics::GeometryPtr & geometry1()
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.
This class is a combined container which has the find complexity of a HashTable, deterministic iterat...
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...
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::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.
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.