64 class ReconfigureRequest;
91 INVALID_BROAD_PHASE_ALGORITHM = -1,
246 GeometryContactPtrVector::const_iterator
removeContact(GeometryContactPtrVector::const_iterator contact);
365 bool getEnableContactReduction()
const;
368 agx::UInt getContactReductionBinResolution()
const;
425 template<
typename F >
430 for (
agx::UInt i = 0, numGeometries = m_geometries.size(); !m_geometries.empty() && i < numGeometries - 1; ++i ) {
431 for (
agx::UInt j = i + 1; j < numGeometries; ++j ) {
437 if ( relevantCollision(m_geometries[ i ], m_geometries[ j ] ) &&
439 canCollide( m_geometries[ i ], m_geometries[ j ] ) &&
440 m_geometries[ i ]->getBoundingVolume()->hasOverlap( *m_geometries[ j ]->getBoundingVolume() ) ) {
441 reportOverlap( m_geometries[ i ], m_geometries[ j ] );
455 template<
typename F >
465 for (
agx::UInt i = 0, numBroadPhasePairs = broadPhasePairs.
size(); i < numBroadPhasePairs; ++i ) {
471 while ( !pairsToRemove.
empty() ) {
473 m_sweepAndPrune->removePair( pairsToRemove.
back().first, pairsToRemove.
back().second );
528 agx::Real getOrientedBoundsThreshold()
const;
635 void synchronizeTransforms();
640 void synchronizeBounds();
645 void printContacts(const
agx::String& title);
650 agxData::EntityStorage* getShapeStorage(
agxData::EntityModel* shapeModel);
652 agxData::EntityStorage *getGeometryStorage();
654 agxData::EntityStorage* getGeometryContactStorage();
655 agxData::EntityStorage* getContactPointStorage();
656 agxData::EntityStorage* getOrientedGeometryBoundStorage();
658 void setEnableParticleGridTasks(
bool flag);
659 void optimizeGridCellFitting();
662 agx::TaskGroup* getUpdateTask();
671 static
agx::Model* ClassModel();
675 typedef
agx::SymmetricPair<
unsigned> GeometryIDPair;
678 class SpaceSerializer : public
agxStream::Serializable
692 DisablePairVector m_disabledGeometryIDPairs;
696 SpaceSerializer( ) : m_space(nullptr) {}
697 const Space* m_space;
701 friend class SpaceSerializer;
713 void clearContactData();
716 void garbageCollect(
bool clearGcList = true);
718 void restore( const SpaceSerializer& ss );
720 void commitNewOverlaps();
729 template <typename T1, typename T2>
730 void calculateNarrowPhase(BroadPhasePair* pair, T1& contactContainer, T2& separationContainer);
732 void createGeometryContacts();
733 void startUpdateTimer(
agx::Task* task);
734 void stopUpdateTimerAndReport(
agx::Task* task);
735 void createShapeStorage(const
agx::Path& entityPath);
736 void updateContactState();
737 void createMissingContactMaterials();
738 void assignPerContactPointParameters();
739 void updateSweepAndPrune();
742 agx::Task* createSynchronizeTransformsTask();
743 agx::Task* createSynchronizeBoundsTask();
745 agx::Task* createUpdateNarrowPhaseTask( const
agx::String& implementation = "");
746 agx::Task* createUpdateContactStateTask();
748 void createParticlePairContacts();
749 void createParticleGeometryContacts();
757 bool removeSweepAndPrune();
760 friend class
agxSDK::SimulationFrameWriter;
770 agx::TaskGroupRef m_updateTask;
771 agx::TaskRef m_synchronizeTransformsTask;
772 agx::TaskRef m_synchronizeBoundsTask;
773 agx::TaskRef m_updateBroadPhaseTask;
774 agx::TaskRef m_updateNarrowPhaseTask;
775 agx::TaskRef m_updateContactStateTask;
776 agx::TaskRef m_createMissingMaterialsTask;
777 agx::TaskRef m_assignPerPointParameters;
779 agx::TaskRef m_synchronizeTransformsTask2;
780 agx::TaskRef m_synchronizeBoundsTask2;
781 agx::TaskRef m_updateBroadPhaseTask2;
782 agx::TaskRef m_updateNarrowPhaseTask2;
783 agx::TaskRef m_updateContactStateTask2;
784 agx::TaskRef m_createMissingMaterialsTask2;
785 agx::TaskRef m_assignPerPointParameters2;
790 agxData::EntityStorageRef m_geometryStorage;
791 agxData::EntityStorageRef m_geometryContactStorage;
792 agxData::EntityStorageRef m_contactPointStorage;
793 agxData::EntityStorageRef m_broadPhasePairStorage;
794 agxData::EntityStorageRef m_geometryContactSeparations;
795 agxData::EntityStorageRef m_orientedGeometryBoundStorage;
796 agxData::BufferRef m_materialLessGeometryContacts;
797 agxData::BufferRef m_sortedGeometryContacts;
798 agxData::BufferRef m_sortedSeparationPairs;
799 agxData::BufferRef m_filteredBroadPhasePairs;
814 agx::Timer m_updateTimer;
815 agx::Task::ExecutionEvent::CallbackType m_startUpdateTimerCallback;
816 agx::Task::ExecutionEvent::CallbackType m_stopUpdateTimerAndReportCallback;
818 agxData::ValueRefT<
agx::Bool> m_contactReductionEnable;
819 agxData::ValueRefT<
agx::UInt> m_contactReductionBinResolution;
820 agxData::ValueRefT<
agx::UInt> m_contactReductionThreshold;
821 agxData::ValueRefT<
agx::UInt> m_narrowPhaseMinJobSize;
823 agxData::ValueRefT<
agx::Real> m_orientedBoundsThreshold;
829 agxData::BufferRef m_geometryContactInstanceBuffer;
830 agxData::BufferRef m_contactPointInstanceBuffer;
840 agxData::Buffer::
Event::CallbackType m_shapeTransformReallocationCallback;
843 agxData::EntityStorageRef m_collisionObjectStorage;
844 agxData::BufferRef m_collisionObjectBuffer_sourceIndex;
845 agxData::BufferRef m_collisionObjectBuffer_subsystem;
846 agxData::BufferRef m_collisionObjectBuffer_position;
847 agxData::BufferRef m_collisionObjectBuffer_radius;
848 agxData::BufferRef m_collisionObjectBuffer_obbIndex;
850 agxData::BufferRef m_gridOvelapBuffer_collisionObject1;
851 agxData::BufferRef m_gridOvelapBuffer_collisionObject2;
853 agx::TaskRef m_overlapTestTask;
857 typedef
agx::HashTableComponent<
agxData::GeometryPair,
agx::Physics::GeometryContactPtr> GridContactTableComponent;
863 agxData::Value::
Event::CallbackType m_gridCellSizeAlignmentCallback;
864 void gridCellSizeAlignmentCallback(
agxData::Value* sizeAlignment);
880 if (!(g1->isEnabled() && g2->isEnabled()))
883 if (!(g1->getEnableCollisions() && g2->getEnableCollisions()))
894 if (rb1 && (rb1 == rb2))
904 if (groupSet1 && groupSet2 && g1->getSpace() ==
this && g2->getSpace() ==
this && !m_collisionGroupManager->canSetsCollide(groupSet1, groupSet2))
914 return m_orientedGeometryBoundStorage;
919 return m_geometryContactStorage;
924 return m_contactPointStorage;
930 return m_collisionGroupManager;
933 AGX_FORCE_INLINE const CollisionGroupManager* Space::getCollisionGroupManager()
const
935 return m_collisionGroupManager;
949 return this->getEnablePair(
950 m_collisionGroupManager->getGroupId(group1),
951 m_collisionGroupManager->getGroupId(group2));
956 return m_collisionGroupManager->canGroupsCollide(group1, group2);
962 return m_broadPhasePairVector;
968 return m_separationPairVector;
979 if ( geometry1 == 0L || geometry2 == 0L || !geometry1->
isEnabled() || !geometry2->
isEnabled() )
987 if ( m_sweepAndPrune == 0L || geometry1 == 0L || geometry2 == 0L )
991 if ( it != m_externallyReportedPairs.end() )
992 m_externallyReportedPairs.erase( it );
994 m_sweepAndPrune->removePair( geometry1, geometry2 );
999 return m_contactReductionEnable->get();
1004 return m_contactReductionBinResolution->get();
1009 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 agxUtil namespace contain classes and methods for utility functionality.
The agx namespace contains the dynamics/math part of the AGX Dynamics API.