AGX Dynamics 2.42.1.1
Loading...
Searching...
No Matches
MergedBody.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
19
20#include <agx/BitState.h>
23#include <agx/InternalData.h>
24
28
29#define MERGED_BODY_SERIALIZATION_VERSION_1 49
30#define MERGED_BODY_SERIALIZATION_VERSION_2 75
31
32namespace agxSDK
33{
34 class Simulation;
35 class MergeSplitHandler;
36}
37
38namespace agxWire
39{
40 class BodyFixedNode;
41}
42
43namespace agx
44{
48
55 {
56 public:
57 // Interactions.
58 AGX_DECLARE_POINTER_TYPES( EdgeInteraction );
59 AGX_DECLARE_POINTER_TYPES( EmptyEdgeInteraction );
60 AGX_DECLARE_POINTER_TYPES( ContactGeneratorEdgeInteraction );
61 AGX_DECLARE_POINTER_TYPES( GeometryContactEdgeInteraction );
62 AGX_DECLARE_POINTER_TYPES( BinaryConstraintEdgeInteraction );
63 AGX_DECLARE_POINTER_TYPES( ParticleParticleInteraction );
64
68 enum State
69 {
70 INTERACTION_GRAPH_DIRTY = 1 << 0,
71 RESTORED = 1 << 1,
72 READY_FOR_SOLVER = 1 << 2,
73 AUTO_CLEAN_WHEN_EMPTY = 1 << 3
74 };
75
81 {
85 inline MergedBodyIndex() : index( agx::InvalidIndex ), originalIndex( agx::InvalidIndex ) {}
86
92 : index( rb ? rb.calculateIndex() : agx::InvalidIndex ), originalIndex( orgRb ? orgRb.calculateIndex() : agx::InvalidIndex ) {}
93
97 inline agx::Bool isMerged() const { return originalIndex != agx::InvalidIndex && index != originalIndex; }
98
101 };
102
103 public:
104 // Listeners and visitors.
106 typedef std::function< void( agx::RigidBody* ) > RigidBodyVisitor;
107 typedef std::function< void( EdgeInteraction* ) > EdgeInteractionVisitor;
108 typedef agx::BitState< State > InternalState;
110
111 public:
119 static const agx::MergedBody* get( const agx::RigidBody* rb );
120
128 static agx::MergedBody* get( agx::RigidBody* rb );
129
135 static const agx::MergedBody* getActive( const agx::RigidBody* rb );
136
142 static agx::MergedBody* getActive( agx::RigidBody* rb );
143
148 static agx::Bool isRoot( const agx::RigidBody* rb );
149
154 static MergedBodyIndex findMergedBodyIndex( agx::Physics::RigidBodyPtr rb );
155
162 static const agx::RigidBody* filter( const agx::RigidBody* rb );
163 static agx::RigidBody* filter( agx::RigidBody* rb );
164
170
178 static agx::MergedBody* get( agx::Constraint* constraint );
179
187 static const agx::MergedBody* get( const agx::Constraint* constraint );
188
192 static BinaryConstraintEdgeInteraction* getEdge( const agx::Constraint* constraint );
193
197 static BinaryConstraintEdgeInteraction* getEdge( const agx::HighLevelConstraintImplementation* constraint );
198
203 static agx::Bool split( agx::Constraint* constraint );
204
210
218
219 public:
224
232
236 const agx::Name& getName() const;
237
242 void setName(const agx::Name& name);
243
248
255 agx::Bool add( EdgeInteraction* edge );
256
263 agx::Bool merge( agx::MergedBody* other, EdgeInteraction* edge );
264
270 agx::Bool remove( EdgeInteraction* edge );
271
279
285 agx::Bool add( Listener* listener );
286
292 agx::Bool remove( Listener* listener );
293
300
304 agx::Bool merged( const agx::RigidBody* rb1, const agx::RigidBody* rb2 ) const;
305
310
315
319 agx::Bool isActive() const;
320
325
330
342
347
348#ifndef SWIG
355 void traverse( RigidBodyVisitor visitor, agx::Bool includeDisabled = false ) const;
356
364 void traverse( EdgeInteractionVisitor visitor, agx::Bool includeDisabled = false ) const;
365
375 void traverse( const agx::RigidBody* rb, EdgeInteractionVisitor visitor, agx::Bool includeDisabled = false ) const;
376
385 void traverse( const agx::RigidBody* rb, RigidBodyVisitor visitor, agx::Bool includeDisabled = false ) const;
386#endif
387
391 const InternalState& getState() const;
392
396 void debugPrint( const agx::RigidBody* rb ) const;
397
401 void getDebugRenderColor( agx::Vec3& color ) const;
402
403 public:
406
410 virtual void updateVelocities();
411
416 virtual void storeRelativeTransforms();
417
421 void postIntegrate();
422
428 void clearGeneratedInteractions();
430
435 agx::Bool updateProperties();
436
437 protected:
441 virtual ~MergedBody() throw();
442
443 friend class agxSDK::Simulation; // Remove of bodies and constraints.
444 friend class agxCollide::Space; // Remove of geometries from space.
445 friend class agx::RigidBody; // Remove of geometries from bodies.
450 virtual void setSimulation( agxSDK::Simulation* simulation );
451
455 virtual void onRemove( agx::RigidBody* rb );
456
460 virtual void onRemove( agx::Constraint* constraint );
461
465 virtual void onRemove( agxCollide::Geometry* geometry );
466
470 virtual void preCollide();
471
475 virtual void preStep();
476
481 virtual void postStep();
482
486 virtual void onCleanup();
487
488 protected:
492 agxSDK::Simulation* getSimulation();
493
497 const agxSDK::Simulation* getSimulation() const;
498
499 private:
500 struct PairData : public agx::Referenced
501 {
503
504 protected:
505 virtual ~PairData() {}
506 };
507 typedef agx::ref_ptr<PairData> PairDataRef;
508
510 typedef agx::Vector<EdgeInteractionConstRef> EdgeInteractionConstRefContainer;
511 typedef agx::HashVector<Key, PairDataRef> PairInteractionsContainer;
512 typedef PairInteractionsContainer::iterator PairInteractionsIterator;
513 typedef PairInteractionsContainer::const_iterator PairInteractionsConstIterator;
514 typedef agx::Vector<RigidBodyRef> RigidBodyContainer;
515 typedef agx::Vector<ListenerRef> ListenerContainer;
516
517 private:
519
523 struct RootBodyData : public agx::Referenced
524 {
525 RootBodyData( agx::MergedBody* mb, agx::StrongInteraction* si ) : rootBody( mb ), strongInteraction( si ) {}
526
527 MergedBody* rootBody;
528 agx::StrongInteractionRef strongInteraction;
529 };
530 typedef agx::ref_ptr<RootBodyData> RootBodyDataRef;
531
535 struct AGXPHYSICS_EXPORT MergedData : public agx::Referenced
536 {
537 enum Flag : agx::UInt16
538 {
539 INTEGRATE_POSITIONS = 1 << 0
542 };
543 using Flags = agx::BitState<Flag, agx::UInt16>;
544
548 MergedData()
549 : otherBodies(), relativeTransform(), mergedBody( nullptr ), id( agx::InvalidIndex ),
550 mergedWithWorldCounter( 0 ), rootBodyData( nullptr ), flags( agx::UInt16( 0 ) )
551 {
552 }
553
554 agx::RigidBodyPtrVector otherBodies;
555 agx::AffineMatrix4x4 relativeTransform;
556 MergedBody* mergedBody;
557 agx::UInt id;
558 agx::Int32 mergedWithWorldCounter;
559 RootBodyDataRef rootBodyData;
560 Flags flags;
561
562 protected:
563 virtual ~MergedData() {}
564 };
565 typedef agx::ref_ptr<MergedData> MergedDataRef;
566
570 struct AGXPHYSICS_EXPORT ConstraintMergedData : public agx::Referenced
571 {
572 ConstraintMergedData()
573 : mergedBody( nullptr ), edge( nullptr ) {}
574
575 MergedBody* mergedBody;
576 EdgeInteraction* edge;
578 protected:
579 virtual ~ConstraintMergedData() {}
580 };
581 typedef agx::ref_ptr<ConstraintMergedData> ConstraintMergedDataRef;
582
587 void writeConnectivityGraph( std::ostream& stream ) const;
588
589 private:
593 template<typename DataT, typename ObjT>
594 static DataT* getMergedData( const ObjT& obj );
595
599 template<typename DataT, typename ObjT>
600 static DataT* getOrCreateMergedData( ObjT obj );
601
605 static RootBodyData* getRootBodyData( const agx::RigidBody* rb );
606
610 static agx::Bool isMerged( const MergedData* data );
611
612 private:
616 Key createKey( EdgeInteraction* edge ) const;
617
621 Key createKey( const agx::RigidBody* rb1, const agx::RigidBody* rb2 ) const;
622
630 MergedData* add( agx::RigidBody* rb, agx::Bool fireOnAddEvent = true );
631
638 void erase( agx::RigidBody* rb, agx::Bool fireOnRemoveEvent = true );
639
645 void remove( agx::RigidBody* rb, MergedData* rbData, agx::Bool saveRemovedEdges );
646
653 agx::Bool remove( EdgeInteraction* edge, agx::Bool saveRemovedEdge );
654
660 void remove( PairInteractionsIterator it );
661
665 void fireOnAdd( agx::RigidBody* rb ) const;
666
670 void fireOnRemove( agx::RigidBody* rb ) const;
671
675 void handleOnAdd( EdgeInteraction* edge );
676
680 void handleOnRemove( const EdgeInteractionRefContainer& edges );
681
685 void handleOnMovedTo( const EdgeInteractionRefContainer& edges, MergedBody* newMergedBody );
686
690 void updateDynamicsProperties( agx::RigidBody::MotionControl motionControl,
691 const agx::Vec3& centerOfMassPosition,
692 agx::Real totalMass );
693
698 void commitGeneratedInteractions();
699
700 private:
701 RigidBodyRef m_rb;
702 PairInteractionsContainer m_pairInteractions;
703 EdgeInteractionRefContainer m_removedEdges;
704 ListenerContainer m_listeners;
705 RigidBodyContainer m_bodies;
706 agxSDK::Simulation* m_simulation;
707 mutable InternalState m_state;
708 agx::Mutex m_mutex;
709 agx::Name m_name;
710 };
711
715 class AGXPHYSICS_EXPORT MergedBody::Listener : public agx::Referenced
716 {
717 public:
723 virtual ListenerRef clone() = 0;
724
728 virtual void onAdd( agx::RigidBody* /*rb*/, const agx::MergedBody* /*mergedBody*/ ) const {}
729
733 virtual void onRemove( agx::RigidBody* /*rb*/, const agx::MergedBody* /*mergedBody*/ ) const {}
734
738 virtual void onAdded( EdgeInteraction* /*edge*/, const agx::MergedBody* /*mergedBody*/ ) const {}
739
743 virtual void onRemoved( const MergedBody::EdgeInteractionRefContainer& /*edges*/, const agx::MergedBody* /*mergedBody*/ ) const {}
744
748 virtual void onMovedFromTo( const MergedBody::EdgeInteractionRefContainer& /*edges*/, const agx::MergedBody* /*fromMergedBody*/, const agx::MergedBody* /*toMergedBody*/ ) const {}
749
750 protected:
754 virtual ~Listener();
755 };
756
760 class AGXPHYSICS_EXPORT MergedBody::EdgeInteraction : public agx::Referenced, public agxStream::Serializable
761 {
762 public:
763#ifndef SWIG
765 {
766 NONE = 0,
767 CONTACT = 1 << 0,
768 CONTACT_GENERATOR = 1 << 1,
769 CONSTRAINT = 1 << 2,
770 BINARY_CONSTRAINT = CONSTRAINT | (1 << 3),
771 PARTICLE_GENERATOR = 1 << 4
772 };
773#endif
774
775 public:
780
785
790
795
796#ifndef SWIG
801#endif
802
803 public:
809
810 AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE( MergedBody::EdgeInteraction );
811
815 virtual void store( agxStream::OutputArchive& out ) const override;
816
820 virtual void restore( agxStream::InputArchive& in ) override;
821
825 virtual void storeLightData( agxStream::StorageStream& str ) const override;
826
830 virtual void restoreLightData( agxStream::StorageStream& str ) override;
831
832 protected:
833#ifndef SWIG
842#endif
843
848
853
854 private:
855 agx::RigidBodyObserver m_bodies[ 2 ];
856 agx::Bool m_hadValidRb[ 2 ];
857 agx::Bool m_valid;
858 agx::Int32 m_tag;
859 };
860
866 class AGXPHYSICS_EXPORT MergedBody::EmptyEdgeInteraction : public MergedBody::EdgeInteraction
867 {
868 public:
873
874 public:
875 AGXSTREAM_DECLARE_SERIALIZABLE( MergedBody::EmptyEdgeInteraction );
876
880 virtual void storeLightData( agxStream::StorageStream& str ) const override;
881
885 virtual void restoreLightData( agxStream::StorageStream& str ) override;
886
887 protected:
892
897
901 virtual void generateInteraction( agxSDK::Simulation* /*simulation*/, agxCollide::LocalGeometryContactVector& /*newContacts*/ ) override {}
902 };
903
908 class AGXPHYSICS_EXPORT MergedBody::ContactGeneratorEdgeInteraction : public MergedBody::EdgeInteraction
909 {
910 public:
915
916 public:
917 AGXSTREAM_DECLARE_SERIALIZABLE( MergedBody::ContactGeneratorEdgeInteraction );
918
922 virtual void storeLightData( agxStream::StorageStream& str ) const override;
923
927 virtual void restoreLightData( agxStream::StorageStream& str ) override;
928
929 protected:
934
939
943 virtual void generateInteraction( agxSDK::Simulation* simulation, agxCollide::LocalGeometryContactVector& newContacts ) override;
944 };
945
949 class AGXPHYSICS_EXPORT MergedBody::GeometryContactEdgeInteraction : public MergedBody::EdgeInteraction
950 {
951 public:
956 {
958 {
961 TANGENT_V_DIRECTION
962 };
963
966 agx::Physics::ContactMaterialPtr contactMaterial,
967 const agx::AffineMatrix4x4& toLocal,
968 const agx::RigidBody* rb1,
969 const agx::RigidBody* rb2 );
970
977 };
979
980 public:
986
996 agx::RigidBody* rb1,
997 agxCollide::Geometry* geometry2,
998 agx::RigidBody* rb2 );
999
1004
1009
1014
1015 public:
1016 AGXSTREAM_DECLARE_SERIALIZABLE( MergedBody::GeometryContactEdgeInteraction );
1017
1021 virtual void storeLightData( agxStream::StorageStream& str ) const override;
1022
1026 virtual void restoreLightData( agxStream::StorageStream& str ) override;
1027
1029#ifndef SWIG
1034 typedef std::function<agxCollide::Geometry*( agxCollide::Geometry*, agx::RigidBody* )> GeometryUpdateFunction;
1035
1044 void updateGeometries( GeometryUpdateFunction geometryUpdateFunction );
1045#endif
1047
1048 protected:
1052 GeometryContactEdgeInteraction();
1053
1057 virtual ~GeometryContactEdgeInteraction();
1058
1062 virtual void generateInteraction( agxSDK::Simulation* simulation, agxCollide::LocalGeometryContactVector& newContacts ) override;
1063
1064 private:
1065 PointContainer m_points;
1066 agxCollide::GeometryObserver m_geometries[ 2 ];
1067 };
1068
1072 class AGXPHYSICS_EXPORT MergedBody::BinaryConstraintEdgeInteraction : public MergedBody::EdgeInteraction
1073 {
1074 public:
1080
1086
1091
1096
1097 public:
1098 AGXSTREAM_DECLARE_SERIALIZABLE( MergedBody::BinaryConstraintEdgeInteraction );
1099
1103 virtual void storeLightData( agxStream::StorageStream& str ) const override;
1104
1108 virtual void restoreLightData( agxStream::StorageStream& str ) override;
1109
1110 protected:
1115
1120
1124 virtual void generateInteraction( agxSDK::Simulation* simulation, agxCollide::LocalGeometryContactVector& newContacts ) override;
1125
1126 private:
1128 };
1129
1133 class AGXPHYSICS_EXPORT MergedBody::ParticleParticleInteraction : public MergedBody::EdgeInteraction
1134 {
1135 public:
1139 ParticleParticleInteraction(agx::RigidBody* substituteBody1, agx::RigidBody* substituteBody2);
1140
1141 public:
1142 AGXSTREAM_DECLARE_SERIALIZABLE(MergedBody::ParticleParticleInteraction);
1143
1147 virtual void storeLightData(agxStream::StorageStream& str) const override;
1148
1152 virtual void restoreLightData(agxStream::StorageStream& str) override;
1153
1154 protected:
1159
1164
1168 virtual void generateInteraction(agxSDK::Simulation* /*simulation*/, agxCollide::LocalGeometryContactVector& /*newContacts*/) override;
1169 };
1170
1171 template<typename DataT, typename ObjT>
1172 AGX_FORCE_INLINE DataT* MergedBody::getMergedData( const ObjT& obj )
1173 {
1174 return agx::InternalData::get<DataT>( obj, agx::InternalData::MERGED_BODY );
1175 }
1176
1177 template<typename DataT, typename ObjT>
1178 AGX_FORCE_INLINE DataT* MergedBody::getOrCreateMergedData( ObjT obj )
1179 {
1180 agxAssert( obj != nullptr );
1181 return agx::InternalData::getOrCreate<DataT>( obj, agx::InternalData::MERGED_BODY );
1182 }
1183
1184 AGX_FORCE_INLINE const MergedBody* MergedBody::get( const RigidBody* rb )
1185 {
1186 const MergedData* data = getMergedData<MergedData>( rb );
1187 return data != nullptr ? data->mergedBody : nullptr;
1188 }
1189
1190 AGX_FORCE_INLINE MergedBody* MergedBody::get( RigidBody* rb )
1191 {
1192 MergedData* data = getMergedData<MergedData>( rb );
1193 return data != nullptr ? data->mergedBody : nullptr;
1194 }
1195
1196 AGX_FORCE_INLINE const MergedBody* MergedBody::getActive( const RigidBody* rb )
1197 {
1198 const MergedBody* mb = MergedBody::get( rb );
1199 return mb != nullptr && mb->isActive() ? mb : nullptr;
1200 }
1201
1202 AGX_FORCE_INLINE MergedBody* MergedBody::getActive( RigidBody* rb )
1203 {
1204 MergedBody* mb = MergedBody::get( rb );
1205 return mb != nullptr && mb->isActive() ? mb : nullptr;
1206 }
1207
1208 inline Bool MergedBody::isRoot( const RigidBody* rb )
1209 {
1210 return rb != nullptr &&
1211 rb->getEntity().state().mergedRootBody();
1212 }
1213
1215 {
1216 if ( !rb )
1217 return MergedBodyIndex();
1218 const MergedBody* root = getActive( rb.model() );
1219 return root != nullptr ? MergedBodyIndex( root->getRigidBody()->getEntity(), rb ) : MergedBodyIndex( rb, rb );
1220 }
1221
1222 AGX_FORCE_INLINE const RigidBody* MergedBody::filter( const RigidBody* rb )
1223 {
1224 const MergedBody* root = getActive( rb );
1225 return root != nullptr ? root->getRigidBody() : rb;
1226 }
1227
1228 AGX_FORCE_INLINE RigidBody* MergedBody::filter( RigidBody* rb )
1229 {
1230 MergedBody* root = getActive( rb );
1231 return root != nullptr ? root->getRigidBody() : rb;
1232 }
1233
1234 AGX_FORCE_INLINE Bool MergedBody::isMerged( const MergedData* data )
1235 {
1236 return data != nullptr && data->mergedBody != nullptr;
1237 }
1238
1239 AGX_FORCE_INLINE Bool MergedBody::isActive() const
1240 {
1241 return m_simulation != nullptr && m_state.Is( READY_FOR_SOLVER );
1242 }
1243
1244 AGX_FORCE_INLINE MergedBody::RootBodyData* MergedBody::getRootBodyData( const RigidBody* rb )
1245 {
1246 MergedData* data = getMergedData<MergedData>( rb );
1247 return data != nullptr ? data->rootBodyData : nullptr;
1248 }
1249
1251 inline Bool MergedBody::EdgeInteraction::isTagged(InteractionTag tag) const
1252 {
1253 return ( m_tag & (Int32)tag ) != 0;
1254 }
1256}
1257
#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:207
#define AGXPHYSICS_EXPORT
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition: agx/Vector.h:34
The geometry representation used by the collision detection engine.
Definition: Geometry.h:92
Base class for a merge split algorithm handling a set of merged bodies.
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:131
Class for reading a binary stream of serialized data.
Definition: InputArchive.h:51
Class for writing serialized data in binary format to a stream.
Definition: OutputArchive.h:57
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:44
Abstract base class for storing/restoring a line/drums with version control.
Definition: StorageStream.h:49
The body fixed node is attached to a body at a given offset.
The base class for a constraint.
Definition: Constraint.h:89
This class is a combined container which has the find complexity of a HashTable, deterministic iterat...
Definition: HashVector.h:41
@ MERGED_BODY
Merged states, neighbors etc.
Definition: InternalData.h:42
Structure holding several "normal" rigid bodies.
Definition: MergedBody.h:55
void setEnableAutomaticCleanupWhenEmpty(agx::Bool enable)
If true, this merged body will remove itself from the simulation and clear all internal states when i...
MergedBody()
Construct merged body, default containing a root rigid body.
agx::Bool add(EdgeInteraction *edge)
Add an edge interaction defining a base interaction between one or two rigid bodies that will be cons...
agx::UInt getNumPairs() const
static agx::MergedBody * get(agx::Constraint *constraint)
This method returns a merged body if the constraint has been involved in it, e.g.,...
void setName(const agx::Name &name)
Assign new name to this MergedBOdy Default: "".
virtual void generateInteraction(agxSDK::Simulation *, agxCollide::LocalGeometryContactVector &) override
Does nothing.
Definition: MergedBody.h:901
virtual void generateInteraction(agxSDK::Simulation *simulation, agxCollide::LocalGeometryContactVector &newContacts)=0
Generate interaction or do nothing.
agxCollide::Geometry * getGeometry1() const
virtual ~EmptyEdgeInteraction()
Reference counted object, protected destructor.
agx::Bool remove(Listener *listener)
Remove listener from this merged body.
agx::Bool remove(EdgeInteraction *edge)
Remove an edge interaction from this merged body.
virtual void onAdded(EdgeInteraction *, const agx::MergedBody *) const
Called when an edge is added to the merged body.
Definition: MergedBody.h:738
ContactGeneratorEdgeInteraction(agx::RigidBody *rb1, agx::RigidBody *rb2)
Construct given two rigid bodies.
virtual void storeLightData(agxStream::StorageStream &str) const override
Store non-structural data to stream.
agx::RigidBody * getRigidBody() const
agx::Bool isTagged(InteractionTag tag) const
EmptyEdgeInteraction(agx::RigidBody *rb1, agx::RigidBody *rb2)
Construct given two rigid bodies.
const agx::Name & getName() const
virtual ~ParticleParticleInteraction()
Reference counted object, protected destructor.
const EdgeInteractionRefContainer * getEdges(const agx::RigidBody *rb1, const agx::RigidBody *rb2) const
agx::Bool isActive() const
Definition: MergedBody.h:1239
std::function< void(EdgeInteraction *) > EdgeInteractionVisitor
Definition: MergedBody.h:107
agx::Bool getValid() const
agx::HighLevelConstraintImplementation * getConstraint()
static agx::Bool split(agx::Constraint *constraint)
Removes the edge defined by the constraint from the merged body, if any.
agx::Bool add(Listener *listener)
Add listener to receive callbacks during certain events.
agx::RigidBody * getRigidBody1() const
virtual ~ContactGeneratorEdgeInteraction()
Reference counted object, protected destructor.
agx::BitState< State > InternalState
Definition: MergedBody.h:108
static agx::Bool split(agx::HighLevelConstraintImplementation *constraint)
Removes the edge defined by the constraint from the merged body, if any.
virtual void onAdd(agx::RigidBody *, const agx::MergedBody *) const
Called when a body is added to the merged body.
Definition: MergedBody.h:728
const agx::HighLevelConstraintImplementation * getConstraint() const
virtual void store(agxStream::OutputArchive &out) const override
Stores the two bodies and the construction state.
static agx::Bool split(agx::RigidBody *rb)
Split rigid body if merged.
static agx::Bool shouldIntegratePosition(const agx::RigidBody *rb)
GeometryContactEdgeInteraction(agx::Physics::GeometryContactPtr gcPtr)
Construct given a geometry contact data.
virtual void restoreLightData(agxStream::StorageStream &str) override
Restore non-structural data from stream.
virtual void onRemove(agx::RigidBody *, const agx::MergedBody *) const
Called when a body is removed from the merged body.
Definition: MergedBody.h:733
virtual void onMovedFromTo(const MergedBody::EdgeInteractionRefContainer &, const agx::MergedBody *, const agx::MergedBody *) const
Called when the edges between two bodies are moved from one merged body to another.
Definition: MergedBody.h:748
std::function< void(agx::RigidBody *) > RigidBodyVisitor
Definition: MergedBody.h:106
agx::Bool remove(agx::RigidBody *rb)
Split/Remove a rigid body from this merged body.
ParticleParticleInteraction()
Default constructor used by serialization.
virtual void generateInteraction(agxSDK::Simulation *simulation, agxCollide::LocalGeometryContactVector &newContacts) override
Checks for contacts between the bodies and adds them.
virtual void onRemoved(const MergedBody::EdgeInteractionRefContainer &, const agx::MergedBody *) const
Called when an edge is removed from the merged body.
Definition: MergedBody.h:743
ContactGeneratorEdgeInteraction()
Default constructor used by serialization.
BinaryConstraintEdgeInteraction(agx::Constraint *constraint)
Construct given a one or two body constraint.
const PointContainer & getPoints() const
virtual ~BinaryConstraintEdgeInteraction()
Reference counted object, protected destructor.
void traverse(EdgeInteractionVisitor visitor, agx::Bool includeDisabled=false) const
Traverse the internal interaction graph and receive callback for each edge interaction.
void traverse(RigidBodyVisitor visitor, agx::Bool includeDisabled=false) const
Traverse the internal interaction graph and receive callback for all rigid bodies (unique).
EdgeInteraction(agx::RigidBody *rb1, agx::RigidBody *rb2, InteractionTag tag, agx::Bool valid=true)
Construct given two rigid bodies and a valid flag.
BinaryConstraintEdgeInteraction()
Default constructor used by serialization.
static BinaryConstraintEdgeInteraction * getEdge(const agx::HighLevelConstraintImplementation *constraint)
const agx::RigidBodyPtrVector * getNeighbors(const agx::RigidBody *rb) const
void setBodies(agx::RigidBody *rb1, agx::RigidBody *rb2)
Assign bodies during restore.
ParticleParticleInteraction(agx::RigidBody *substituteBody1, agx::RigidBody *substituteBody2)
Construct given two rigid bodies.
void debugPrint(const agx::RigidBody *rb) const
Debug prints (cout) interactions to rb.
GeometryContactEdgeInteraction(agxCollide::Geometry *geometry1, agx::RigidBody *rb1, agxCollide::Geometry *geometry2, agx::RigidBody *rb2)
Construct given two geometries.
void getDebugRenderColor(agx::Vec3 &color) const
Color of this merged body used for debug rendering.
agx::Bool getEnableAutomaticCleanupWhenEmpty() const
virtual ~EdgeInteraction()
Reference counted object, protected destructor.
static BinaryConstraintEdgeInteraction * getEdge(const agx::Constraint *constraint)
State
Internal state of this merged body.
Definition: MergedBody.h:69
agxCollide::Geometry * getGeometry2() const
virtual void restore(agxStream::InputArchive &in) override
Restores the two bodies and the construction state.
EmptyEdgeInteraction()
Default constructor used by serialization.
static const agx::MergedBody * get(const agx::Constraint *constraint)
This method returns a merged body if the constraint has been involved in it, e.g.,...
agx::Bool containsDeletedBodies() const
virtual ~Listener()
Reference counted object, protected destructor.
agx::Vector< EdgeInteractionRef > EdgeInteractionRefContainer
Definition: MergedBody.h:109
agx::Bool merge(agx::MergedBody *other, EdgeInteraction *edge)
Merges this with other and clears other.
virtual MergedBodyRef clone()
Creates an empty clone of this merged body where each object that supports cloning also are cloned.
agx::MergedBodyRefVector splitIslands()
Splits into islands.
void traverse(const agx::RigidBody *rb, EdgeInteractionVisitor visitor, agx::Bool includeDisabled=false) const
Traverse the internal interaction graph and receive callback for each edge interaction where rb is pa...
agx::VectorPOD< Point > PointContainer
Definition: MergedBody.h:978
agx::Bool merged(const agx::RigidBody *rb1, const agx::RigidBody *rb2) const
agx::Bool isEmpty() const
const InternalState & getState() const
agx::RigidBody * getRigidBody2() const
AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE(MergedBody::EdgeInteraction)
BinaryConstraintEdgeInteraction(agx::HighLevelConstraintImplementation *constraint)
Construct given constraint implementation of a binary constraint.
virtual ListenerRef clone()=0
This listener will be cloned when e.g., splitIslands is used.
void traverse(const agx::RigidBody *rb, RigidBodyVisitor visitor, agx::Bool includeDisabled=false) const
Traverse neighboring bodies to rb.
Representation of a name string.
Definition: Name.h:33
Pointer to a entity instance of type Physics.ContactMaterial.
Pointer to a entity instance of type Physics.ContactPoint.
A geometry contact hold contact information between two geometries.
Pointer to a entity instance of type Physics.RigidBody.
AGXPHYSICS_EXPORT agx::RigidBody *& model()
AGXPHYSICS_EXPORT agx::RigidBodyState & state()
Base class providing referencing counted objects.
Definition: Referenced.h:120
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:49
MotionControl
The MotionControl enumeration indicates what makes a RigidBody move.
Definition: RigidBody.h:60
agx::Physics::RigidBodyPtr getEntity() const
Internal method.
Definition: RigidBody.h:1153
This class is a combined container which has the find complexity of a HashTable, deterministic iterat...
Definition: SetVector.h:38
Base class for a strong interaction concept where there interaction is defined in the mass matrix par...
A std::pair, with both elements of the same type, and symmetric so (a, b) == (b, a)
Definition: SymmetricPair.h:32
#define agxAssert(expr)
Definition: debug.h:143
#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...
Flags
Flags for specifying what is enabled in the debug rendering system.
Definition: RenderManager.h:57
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:31
Implements a Wire model with adaptive resolution.
Definition: MergedBody.h:39
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
uint16_t UInt16
Definition: Integer.h:31
int32_t Int32
Definition: Integer.h:37
agx::SetVector< agx::MergedBodyRef > MergedBodyRefSetVector
Definition: MergedBody.h:47
std::mutex Mutex
Definition: Referenced.h:99
bool Bool
Definition: Integer.h:40
uint64_t UInt
Definition: Integer.h:27
agx::ref_ptr< RigidBody > RigidBodyRef
Definition: RigidBody.h:41
double Real
Definition: Real.h:41
AGXCORE_EXPORT const InvalidIndexStruct InvalidIndex
AGXCORE_EXPORT Component * root()
Object with index of merged body and the original index of a merged object.
Definition: MergedBody.h:81
MergedBodyIndex(agx::Physics::RigidBodyPtr rb, agx::Physics::RigidBodyPtr orgRb)
Construct given object associated to index, and an original object associated to originalIndex.
Definition: MergedBody.h:91
agx::Bool isMerged() const
Definition: MergedBody.h:97
MergedBodyIndex()
Default constructor initializes both indices to Invalid Index.
Definition: MergedBody.h:85
Contact point data store in first rigid body local frame.
Definition: MergedBody.h:956
Point(agx::Physics::ContactPointPtr pointPtr, agx::Physics::ContactMaterialPtr contactMaterial, const agx::AffineMatrix4x4 &toLocal, const agx::RigidBody *rb1, const agx::RigidBody *rb2)