AGX Dynamics 2.41.2.0
Loading...
Searching...
No Matches
Space.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#pragma once
18
20#include <agx/HashVector.h>
21
22#include <agx/SetVector.h>
23#include <agx/Vector.h>
24#include <agx/HashSet.h>
25#include <string>
26
27#include <agxCollide/Geometry.h>
29#include <agxCollide/Contacts.h>
31
35#include <agxCollide/Sphere.h>
36#include <agx/Task.h>
37#include <agx/Timer.h>
38#include <agx/Component.h>
40
46
47
48namespace agxIO
49{
50 class SceneExporter;
51}
52
53namespace agx
54{
55 class ParticleSystem;
56}
57
58namespace agxSDK
59{
60 class Simulation;
61}
62
63namespace agxUtil {
64 class ReconfigureRequest;
65}
66
67namespace agxCollide
68{
72 typedef std::pair<agx::Physics::ParticlePtr, agx::Physics::GeometryPtr> ParticleGeometryPair;
74
77
79
86 {
87 public:
88
91 INVALID_BROAD_PHASE_ALGORITHM = -1,
93 HIERARCHICAL_GRID
94 };
95
100
103
108 void cleanup();
109
115
120
125 bool add( Geometry* geometry );
126
132 bool remove( Geometry* geometry );
133
139 const Geometry* getGeometry( const agx::Name& name ) const;
140
148
155 const Geometry* getGeometry( const agx::Uuid& uuid ) const;
156
164
174
184
188 const GeometryRefVector& getGeometries() const;
189
194
198 void update();
199
205
213
225 size_t getGeometryContacts(GeometryContactPtrVector& matches, const agxCollide::Geometry *geometry1, const agxCollide::Geometry *geometry2 = nullptr) const;
226
238 size_t getGeometryContacts(GeometryContactPtrVector& matches, const agx::RigidBody *body1, const agx::RigidBody *body2 = nullptr) const;
239
246 GeometryContactPtrVector::const_iterator removeContact(GeometryContactPtrVector::const_iterator contact);
247
259
264
270
285 GeometryPtrVector& testGeometries,
286 GeometryPairVector& geometryPairs,
287 ParticleGeometryPairVector& particleGeometryPairs,
288 bool skip = true );
289
304 GeometryPtrVector& testGeometries,
305 LocalGeometryContactVector& geometryContacts,
306 LocalParticleGeometryContactVector& particleGeometryContacts,
307 bool skip = true
308 );
309
323
339 const agx::Vec3& point,
340 const agx::Vec3& direction,
341 LocalGeometryContactVector& geometryContacts,
342 LocalParticleGeometryContactVector& particleGeometryContacts,
343 const agx::Real length = FLT_MAX / 4
344 );
345
350 void setEnableContactReduction( bool flag );
351
363
365 bool getEnableContactReduction() const;
366
368 agx::UInt getContactReductionBinResolution() const;
369
376
381
386
398 void setEnablePair( agx::UInt32 group1, agx::UInt32 group2, bool flag );
399 void setEnablePair( const agx::Name& group1, const agx::Name& group2, bool flag );
400
407 bool getEnablePair( agx::UInt32 group1, agx::UInt32 group2 ) const;
408
415 bool getEnablePair(const agx::Name& group1, const agx::Name& group2) const;
416
425 template< typename F >
426 void enableForContacts(F relevantCollision)
427 {
428 // For all COMBINATIONS of geometries, check if the collision is possibly relevant
429 // and add them to broad phase if their bounding volumes are overlapping.
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 ) {
432 if ( i == j )
433 continue;
434
435 // Relevant collision:
436 // Report overlap.
437 if ( relevantCollision(m_geometries[ i ], m_geometries[ j ] ) &&
438 m_sweepAndPrune && // Only need to report overlaps to SAP, the grid will find them by itself on its next search.
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 ] );
442 }
443 }
444 }
445 }
446
455 template< typename F >
456 void disableForContacts(F relevantCollision)
457 {
458 // Among the current broad phase pairs, check if we have
459 // a relevant match of geometries. If so, remove (will send
460 // separation event if someone is listening to that).
461 GeometryPairVector pairsToRemove;
462 pairsToRemove.reserve( 16 );
463
464 const BroadPhasePairVector& broadPhasePairs = getBroadPhasePairs();
465 for ( agx::UInt i = 0, numBroadPhasePairs = broadPhasePairs.size(); i < numBroadPhasePairs; ++i ) {
466 const BroadPhasePairVector::value_type& bpPair = broadPhasePairs[ i ];
467 if ( bpPair.geometry1() && bpPair.geometry2() && relevantCollision(bpPair.geometry1().model(), bpPair.geometry2().model() ) )
468 pairsToRemove.push_back( GeometryPair( bpPair.geometry1().model(), bpPair.geometry2().model() ) );
469 }
470
471 while ( !pairsToRemove.empty() ) {
472 if (m_sweepAndPrune)
473 m_sweepAndPrune->removePair( pairsToRemove.back().first, pairsToRemove.back().second );
474 pairsToRemove.pop_back();
475 }
476 }
477
490
503
517 bool canCollide( const Geometry* g1, const Geometry* g2 ) const;
518
520 void setEnableCollisions(const Geometry* g1, const Geometry* g2, bool flag);
521
522 // To be called for geometries that are enabled/disabled
523 void setEnableGeometry(Geometry* geometry, bool flag);
524
528 agx::Real getOrientedBoundsThreshold() const;
529
535
541 void removeContact(agx::Physics::GeometryContactPtr contact);
542
547
551 const BroadPhasePairVector& getBroadPhasePairs() const;
552
556 const SeparationPairVector& getSeparationPairs() const;
557
558
566 size_t getSeparationPairs(agx::Physics::GeometryPairPtrVector &matches, const agxCollide::Geometry *geometry1, const agxCollide::Geometry *geometry2=nullptr) const;
567
575 size_t getSeparationPairs(agx::Physics::GeometryPairPtrVector& matches, const agx::RigidBody *body1, const agx::RigidBody *body2=nullptr) const;
576
577
582 void reportOverlap( agxCollide::Geometry* geometry1, agxCollide::Geometry* geometry2 );
583
590 void removeOverlap( agxCollide::Geometry* geometry1, agxCollide::Geometry* geometry2 );
591
596
598
601
604
605
609 HierarchicalGrid *getHierarchicalGrid();
610
613
616
619
626
627 public:
628
630
631
632
635 void synchronizeTransforms();
636
640 void synchronizeBounds();
645 void printContacts(const agx::String& title);
646
647 CollisionGroupManager* getCollisionGroupManager();
648 const CollisionGroupManager* getCollisionGroupManager() const;
649
650 agxData::EntityStorage* getShapeStorage(agxData::EntityModel* shapeModel);
651
652 agxData::EntityStorage *getGeometryStorage();
653
654 agxData::EntityStorage* getGeometryContactStorage();
655 agxData::EntityStorage* getContactPointStorage();
656 agxData::EntityStorage* getOrientedGeometryBoundStorage();
657
658 void setEnableParticleGridTasks(bool flag);
659 void optimizeGridCellFitting();
660
662 agx::TaskGroup* getUpdateTask();
663
664
665 SpaceListener::GeometryEvent addGeometryEvent;
666 SpaceListener::GeometryEvent removeGeometryEvent;
667
668 SpaceListener::ShapeEvent addShapeEvent;
669 SpaceListener::ShapeEvent removeShapeEvent;
670
671 static agx::Model* ClassModel();
672
674
675 typedef agx::SymmetricPair<unsigned> GeometryIDPair;
676
678 class SpaceSerializer : public agxStream::Serializable
679 {
680 public:
681 SpaceSerializer( const agxCollide::Space* space ) : m_space(space) {}
682 AGXSTREAM_DECLARE_SERIALIZABLE(agxCollide::Space::SpaceSerializer);
683
684 const agxCollide::Space* getSpace() const {
685 return m_space;
686 }
687 void setSpace( agxCollide::Space* space ) {
688 m_space = space;
689 }
690
691 typedef agx::Vector<GeometryIDPair> DisablePairVector;
692 DisablePairVector m_disabledGeometryIDPairs;
693 agx::UInt32 m_uniqueGroupID;
694
695 protected:
696 SpaceSerializer( ) : m_space(nullptr) {}
697 const Space* m_space;
698
699 };
700
701 friend class SpaceSerializer;
702 friend class agxSDK::Simulation;
703
705
706 protected:
707
709 virtual ~Space();
710
712
713 void clearContactData();
714
716 void garbageCollect(bool clearGcList = true);
717
718 void restore( const SpaceSerializer& ss );
719
720 void commitNewOverlaps();
721
722 friend class Geometry;
723
725 void init();
726
727
729 template <typename T1, typename T2>
730 void calculateNarrowPhase(BroadPhasePair* pair, T1& contactContainer, T2& separationContainer);
731
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();
740
741 void loadTasks(BroadPhaseAlgorithm algorithm);
742 agx::Task* createSynchronizeTransformsTask();
743 agx::Task* createSynchronizeBoundsTask();
744 agx::Task* createUpdateBroadPhaseTask(BroadPhaseAlgorithm algorithm);
745 agx::Task* createUpdateNarrowPhaseTask( const agx::String& implementation = "");
746 agx::Task* createUpdateContactStateTask();
747
748 void createParticlePairContacts();
749 void createParticleGeometryContacts();
750
751
753
754 private:
755 void validate();
756
757 bool removeSweepAndPrune();
758 bool removeGrid();
759
760 friend class agxSDK::SimulationFrameWriter;
761 friend class agxUtil::ReconfigureRequest;
762
763 void setCollisionGroupManager(CollisionGroupManager* m);
764
765 BroadPhaseAlgorithm m_broadPhaseAlgorithm;
766
767 HierarchicalGridRef m_grid;
768 agxCollide::SweepAndPruneRef m_sweepAndPrune;
769
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;
778
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;
786
787 GeometryRefVector m_geometries;
788 agx::Vector<GeometryObserver> m_potentialProblemGeometries;
789
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;
800
801 BroadPhasePairVector m_broadPhasePairVector;
802 SeparationPairVector m_separationPairVector;
803
804 GeometryPairHash m_disabledGeometryPairs;
805
806 friend class agxIO::SceneExporter;
808
809 agxCollide::SweepAndPrune::ExternallyReportedPairsContainer m_externallyReportedPairs;
810
811 typedef agx::HashVector< agx::Physics::GeometryPtr, GeometryRef > GeometryRemoveTable;
812 GeometryRemoveTable m_geometriesToRemove;
813
814 agx::Timer m_updateTimer;
815 agx::Task::ExecutionEvent::CallbackType m_startUpdateTimerCallback;
816 agx::Task::ExecutionEvent::CallbackType m_stopUpdateTimerAndReportCallback;
817
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;
822
823 agxData::ValueRefT<agx::Real> m_orientedBoundsThreshold;
824
825 GeometryRef m_ray;
826 SphereRef m_proxyParticle;
827
828 GeometryContactPtrVector m_geometryContacts;
829 agxData::BufferRef m_geometryContactInstanceBuffer;
830 agxData::BufferRef m_contactPointInstanceBuffer;
831
832 ParticleGeometryContactVector m_particleGeometryContacts;
833 ParticlePairContactVector m_particlePairContacts;
834
835 typedef agx::HashTable<agxData::EntityModel*, agxData::EntityStorage*> ShapeStorageTable;
836 ShapeStorageTable m_shapeStorageTable;
837
838 typedef agx::Vector< SpaceListenerRef > SpaceListenerRefVector;
839 SpaceListenerRefVector m_listeners;
840 agxData::Buffer::Event::CallbackType m_shapeTransformReallocationCallback;
841
842
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;
849
850 agxData::BufferRef m_gridOvelapBuffer_collisionObject1;
851 agxData::BufferRef m_gridOvelapBuffer_collisionObject2;
852
853 agx::TaskRef m_overlapTestTask;
854
855 agx::HashSet<Geometry*> m_skipTable;
856
857 typedef agx::HashTableComponent<agxData::GeometryPair, agx::Physics::GeometryContactPtr> GridContactTableComponent;
858 typedef agx::QuadraticProbingHashTable<agxData::GeometryPair, agx::Physics::GeometryContactPtr, agx::HashFn<agxData::GeometryPair>, agxData::BufferProxyAllocator> GridContactTable;
859
860
861 CollisionGroupManagerRef m_collisionGroupManager;
862
863 agxData::Value::Event::CallbackType m_gridCellSizeAlignmentCallback;
864 void gridCellSizeAlignmentCallback(agxData::Value* sizeAlignment);
865
866 GridContactTable* m_gridContactTable;
867 };
868
869 /* Implementation */
870 AGX_FORCE_INLINE bool Space::canCollide( const Geometry* g1, const Geometry* g2 ) const
871 {
872 if (!(g1 && g2) )
873 return false;
874
875 // We cannot collide with ourself. TODO Not necessarily true in general case, e.g., if a deformable is defined as one geometry
876 if (g1 == g2)
877 return false;
878
879 // One of the geometries are disabled for collision
880 if (!(g1->isEnabled() && g2->isEnabled()))
881 return false;
882
883 if (!(g1->getEnableCollisions() && g2->getEnableCollisions()))
884 return false;
885
886 const agx::RigidBody* rb1 = g1->getRigidBody();
887 const agx::RigidBody* rb2 = g2->getRigidBody();
888
889 // If one is disabled, ignore overlap.
890 if ( (rb1 && !rb1->getEnable()) || (rb2 && !rb2->getEnable()) )
891 return false;
892
893 // not same (non-null) body
894 if (rb1 && (rb1 == rb2))
895 return false;
896
897 // Is this geometry pair disabled?
898 if (m_disabledGeometryPairs.contains( GeometryPair(const_cast<Geometry*>(g1), const_cast<Geometry*>(g2)) ))
899 return false;
900
901 // Can these two groups collide?
902 const agx::Physics::CollisionGroupSetPtr& groupSet1 = g1->getGroupSet();
903 const agx::Physics::CollisionGroupSetPtr& groupSet2 = g2->getGroupSet();
904 if (groupSet1 && groupSet2 && g1->getSpace() == this && g2->getSpace() == this && !m_collisionGroupManager->canSetsCollide(groupSet1, groupSet2))
905 return false;
906
907 return true;
908 }
909
911
912 AGX_FORCE_INLINE agxData::EntityStorage* Space::getOrientedGeometryBoundStorage()
913 {
914 return m_orientedGeometryBoundStorage;
915 }
916
917 AGX_FORCE_INLINE agxData::EntityStorage* Space::getGeometryContactStorage()
918 {
919 return m_geometryContactStorage;
920 }
921
922 AGX_FORCE_INLINE agxData::EntityStorage* Space::getContactPointStorage()
923 {
924 return m_contactPointStorage;
925 }
926
927
928 AGX_FORCE_INLINE CollisionGroupManager* Space::getCollisionGroupManager()
929 {
930 return m_collisionGroupManager;
931 }
932
933 AGX_FORCE_INLINE const CollisionGroupManager* Space::getCollisionGroupManager() const
934 {
935 return m_collisionGroupManager;
936 }
937
938 AGX_FORCE_INLINE agxData::EntityStorage *Space::getGeometryStorage() { return m_geometryStorage; }
939
941
942 AGX_FORCE_INLINE const GeometryRefVector& Space::getGeometries() const
943 {
944 return m_geometries;
945 }
946
947 AGX_FORCE_INLINE bool Space::getEnablePair( const agx::Name& group1, const agx::Name& group2 ) const
948 {
949 return this->getEnablePair(
950 m_collisionGroupManager->getGroupId(group1),
951 m_collisionGroupManager->getGroupId(group2));
952 }
953
954 AGX_FORCE_INLINE bool Space::getEnablePair( agx::UInt32 group1, agx::UInt32 group2 ) const
955 {
956 return m_collisionGroupManager->canGroupsCollide(group1, group2);
957 }
958
959 AGX_FORCE_INLINE const BroadPhasePairVector& Space::getBroadPhasePairs() const
960 {
961 m_broadPhasePairVector.allocator().update();
962 return m_broadPhasePairVector;
963 }
964
965 AGX_FORCE_INLINE const SeparationPairVector& Space::getSeparationPairs() const
966 {
967 m_separationPairVector.allocator().update();
968 return m_separationPairVector;
969 }
970
971 AGX_FORCE_INLINE void Space::removeContact(agx::Physics::GeometryContactPtr contact)
972 {
973 if (contact)
974 contact.enabled() = false;
975 }
976
977 AGX_FORCE_INLINE void Space::reportOverlap( Geometry* geometry1, Geometry* geometry2 )
978 {
979 if ( geometry1 == 0L || geometry2 == 0L || !geometry1->isEnabled() || !geometry2->isEnabled() )
980 return;
981
982 m_externallyReportedPairs.insert( SweepAndPrune::SymmetricGeometryPtrPair( geometry1, geometry2 ), SweepAndPrune::SymmetricGeometryRefPair( geometry1, geometry2 ) );
983 }
984
985 AGX_FORCE_INLINE void Space::removeOverlap( Geometry* geometry1, Geometry* geometry2 )
986 {
987 if ( m_sweepAndPrune == 0L || geometry1 == 0L || geometry2 == 0L )
988 return;
989
990 auto it = m_externallyReportedPairs.find( SweepAndPrune::SymmetricGeometryPtrPair( geometry1, geometry2 ) );
991 if ( it != m_externallyReportedPairs.end() )
992 m_externallyReportedPairs.erase( it );
993 else
994 m_sweepAndPrune->removePair( geometry1, geometry2 );
995 }
996
997 AGX_FORCE_INLINE bool Space::getEnableContactReduction() const
998 {
999 return m_contactReductionEnable->get();
1000 }
1001
1002 AGX_FORCE_INLINE agx::UInt Space::getContactReductionBinResolution() const
1003 {
1004 return m_contactReductionBinResolution->get();
1005 }
1006
1007 AGX_FORCE_INLINE agx::Real Space::getOrientedBoundsThreshold() const
1008 {
1009 return m_orientedBoundsThreshold->get();
1010 }
1011
1012 AGX_FORCE_INLINE HierarchicalGrid *Space::getHierarchicalGrid() { return m_grid; }
1013
1014}
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
Definition: Serializable.h:208
#define AGXPHYSICS_EXPORT
Complete disabled collisions state in a simulation including disabled given name, group id (integer) ...
A contact between two geometries.
Definition: Contacts.h:336
The geometry representation used by the collision detection engine.
Definition: Geometry.h:92
bool isEnabled() const
Alias for getEnable Return whether the geometry should be used in intersection tests.
Definition: Geometry.h:805
Class for listening for add/remove geometry events for an associated Space.
Definition: SpaceListener.h:30
This class contains all Geometries and performs Broad Phase and Narrow Phase collision detection to c...
Definition: Space.h:86
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.
Definition: Space.h:90
@ SWEEP_AND_PRUNE
SAP good for scenes which are semi stationary.
Definition: Space.h:92
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...
Definition: Space.h:456
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...
Definition: Space.h:426
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
Definition: Space.h:597
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.
Definition: EntityStorage.h:73
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:131
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:45
A component is an object containing other objects, enabling hierarchical structuring.
Definition: Component.h:39
bool empty() const
Definition: Container.h:136
size_t size() const
Definition: Container.h:134
An agx::Device is an abstract representation of a device on which data can be stored and processed.
Definition: Device.h:58
Inheritance with partial specialization due to bug with ref_ptr containers.
Representation of a name string.
Definition: Name.h:33
Pointer to a entity instance of type Physics.BroadPhasePair.
Pointer to a entity instance of type Physics.CollisionGroupSet.
A geometry contact hold contact information between two geometries.
AGXPHYSICS_EXPORT agx::Bool & enabled()
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.
Definition: RigidBody.h:52
bool getEnable() const
Access the state enable flag.
Definition: RigidBody.h:1129
This class is a combined container which has the find complexity of a HashTable, deterministic iterat...
Definition: SetVector.h:38
bool contains(const T2 &key) const
Hash search for the data in the container.
Definition: SetVector.h:225
A std::pair, with both elements of the same type, and symmetric so (a, b) == (b, a)
Definition: SymmetricPair.h:32
A UUID, or Universally unique identifier, is intended to uniquely identify information in a distribut...
Definition: Uuid.h:42
Templated vector class.
Definition: agx/Vector.h:53
Allocator & allocator()
Definition: agx/Vector.h:1001
T & back() const
Definition: agx/Vector.h:707
void reserve(size_t size)
Reserve capacity in the vector.
Definition: agx/Vector.h:583
void pop_back()
Definition: agx/Vector.h:754
void push_back(const T2 &value)
Definition: agx/Vector.h:715
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:89
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:88
#define AGX_FORCE_INLINE
Definition: macros.h:58
This namespace consists of a set of classes for handling geometric intersection tests including boole...
agx::Vector< agx::Physics::ParticlePairContactPtr > ParticlePairContactVector
Definition: Space.h:76
agx::Vector< agx::Physics::GeometryPairPtr, agxData::BufferProxyAllocator > SeparationPairVector
Definition: Space.h:70
agx::Vector< agx::Physics::GeometryPairPtr > LocalSeparationPairVector
Definition: Space.h:71
agx::Vector< agx::Physics::BroadPhasePairPtr, agxData::BufferProxyAllocator > BroadPhasePairVector
Definition: Space.h:69
agx::Vector< agx::Physics::ParticleGeometryContactPtr > ParticleGeometryContactVector
Definition: Space.h:75
std::pair< agx::Physics::ParticlePtr, agx::Physics::GeometryPtr > ParticleGeometryPair
Definition: Space.h:72
agx::Vector< ParticleGeometryPair > ParticleGeometryPairVector
Definition: Space.h:73
Contains classes for low level data storage for AGX.
Definition: Container.h:23
The agxIO namespace contains classes for reading, writing and finding files.
Definition: Material.h:42
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:31
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.
uint32_t UInt32
Definition: Integer.h:32
uint64_t UInt
Definition: Integer.h:27
double Real
Definition: Real.h:42
UInt32 Index
Definition: Integer.h:44