29#define MERGED_BODY_SERIALIZATION_VERSION_1 49
30#define MERGED_BODY_SERIALIZATION_VERSION_2 75
35 class MergeSplitHandler;
70 INTERACTION_GRAPH_DIRTY = 1 << 0,
72 READY_FOR_SOLVER = 1 << 2,
73 AUTO_CLEAN_WHEN_EMPTY = 1 << 3
410 virtual
void updateVelocities();
416 virtual
void storeRelativeTransforms();
421 void postIntegrate();
428 void clearGeneratedInteractions();
450 virtual
void setSimulation(
agxSDK::Simulation* simulation );
470 virtual
void preCollide();
475 virtual
void preStep();
481 virtual
void postStep();
486 virtual
void onCleanup();
497 const
agxSDK::Simulation* getSimulation() const;
505 virtual ~PairData() {}
512 typedef PairInteractionsContainer::iterator PairInteractionsIterator;
513 typedef PairInteractionsContainer::const_iterator PairInteractionsConstIterator;
539 INTEGRATE_POSITIONS = 1 << 0
543 using Flags = agx::BitState<Flag, agx::UInt16>;
549 : otherBodies(), relativeTransform(), mergedBody( nullptr ), id(
agx::
InvalidIndex ),
550 mergedWithWorldCounter( 0 ), rootBodyData( nullptr ), flags(
agx::
UInt16( 0 ) )
556 MergedBody* mergedBody;
559 RootBodyDataRef rootBodyData;
563 virtual ~MergedData() {}
572 ConstraintMergedData()
573 : mergedBody( nullptr ), edge( nullptr ) {}
575 MergedBody* mergedBody;
576 EdgeInteraction* edge;
579 virtual ~ConstraintMergedData() {}
587 void writeConnectivityGraph( std::ostream& stream )
const;
593 template<
typename DataT,
typename ObjT>
594 static DataT* getMergedData(
const ObjT& obj );
599 template<
typename DataT,
typename ObjT>
600 static DataT* getOrCreateMergedData( ObjT obj );
610 static agx::Bool isMerged(
const MergedData* data );
616 Key createKey( EdgeInteraction* edge )
const;
660 void remove( PairInteractionsIterator it );
675 void handleOnAdd( EdgeInteraction* edge );
680 void handleOnRemove(
const EdgeInteractionRefContainer& edges );
685 void handleOnMovedTo(
const EdgeInteractionRefContainer& edges, MergedBody* newMergedBody );
698 void commitGeneratedInteractions();
702 PairInteractionsContainer m_pairInteractions;
703 EdgeInteractionRefContainer m_removedEdges;
704 ListenerContainer m_listeners;
705 RigidBodyContainer m_bodies;
707 mutable InternalState m_state;
768 CONTACT_GENERATOR = 1 << 1,
770 BINARY_CONSTRAINT = CONSTRAINT | (1 << 3),
771 PARTICLE_GENERATOR = 1 << 4
1044 void updateGeometries( GeometryUpdateFunction geometryUpdateFunction );
1052 GeometryContactEdgeInteraction();
1057 virtual ~GeometryContactEdgeInteraction();
1062 virtual
void generateInteraction(
agxSDK::Simulation* simulation,
agxCollide::LocalGeometryContactVector& newContacts ) override;
1066 agxCollide::GeometryObserver m_geometries[ 2 ];
1171 template<
typename DataT,
typename ObjT>
1177 template<
typename DataT,
typename ObjT>
1186 const MergedData* data = getMergedData<MergedData>( rb );
1187 return data !=
nullptr ? data->mergedBody :
nullptr;
1192 MergedData* data = getMergedData<MergedData>( rb );
1193 return data !=
nullptr ? data->mergedBody :
nullptr;
1198 const MergedBody* mb = MergedBody::get( rb );
1199 return mb !=
nullptr && mb->
isActive() ? mb :
nullptr;
1205 return mb !=
nullptr && mb->
isActive() ? mb :
nullptr;
1210 return rb !=
nullptr &&
1225 return root !=
nullptr ?
root->getRigidBody() : rb;
1231 return root !=
nullptr ?
root->getRigidBody() : rb;
1236 return data !=
nullptr && data->mergedBody !=
nullptr;
1241 return m_simulation !=
nullptr && m_state.Is( READY_FOR_SOLVER );
1246 MergedData* data = getMergedData<MergedData>( rb );
1247 return data !=
nullptr ? data->rootBodyData :
nullptr;
1251 inline Bool MergedBody::EdgeInteraction::isTagged(InteractionTag tag)
const
1253 return ( m_tag & (Int32)tag ) != 0;
#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
#define AGX_DECLARE_VECTOR_TYPES(type)
The geometry representation used by the collision detection engine.
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...
Class for writing serialized data in binary format to a stream.
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Abstract base class for storing/restoring a line/drums with version control.
The body fixed node is attached to a body at a given offset.
The base class for a constraint.
This class is a combined container which has the find complexity of a HashTable, deterministic iterat...
@ MERGED_BODY
Merged states, neighbors etc.
Structure holding several "normal" rigid bodies.
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.
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.
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
std::function< void(EdgeInteraction *) > EdgeInteractionVisitor
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
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.
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.
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.
std::function< void(agx::RigidBody *) > RigidBodyVisitor
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.
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.
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
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
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.
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.
The rigid body class, combining a geometric model and a frame of reference.
MotionControl
The MotionControl enumeration indicates what makes a RigidBody move.
agx::Physics::RigidBodyPtr getEntity() const
Internal method.
This class is a combined container which has the find complexity of a HashTable, deterministic iterat...
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)
#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...
Flags
Flags for specifying what is enabled in the debug rendering system.
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Implements a Wire model with adaptive resolution.
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
agx::SetVector< agx::MergedBodyRef > MergedBodyRefSetVector
agx::ref_ptr< RigidBody > RigidBodyRef
AGXCORE_EXPORT const InvalidIndexStruct InvalidIndex
AGXCORE_EXPORT Component * root()
Object with index of merged body and the original index of a merged object.
MergedBodyIndex(agx::Physics::RigidBodyPtr rb, agx::Physics::RigidBodyPtr orgRb)
Construct given object associated to index, and an original object associated to originalIndex.
agx::Bool isMerged() const
MergedBodyIndex()
Default constructor initializes both indices to Invalid Index.
Contact point data store in first rigid body local frame.
Point(agx::Physics::ContactPointPtr pointPtr, agx::Physics::ContactMaterialPtr contactMaterial, const agx::AffineMatrix4x4 &toLocal, const agx::RigidBody *rb1, const agx::RigidBody *rb2)