30 #define MERGED_BODY_SERIALIZATION_VERSION_1 49
31 #define MERGED_BODY_SERIALIZATION_VERSION_2 75
36 class MergeSplitHandler;
71 INTERACTION_GRAPH_DIRTY = 1 << 0,
73 READY_FOR_SOLVER = 1 << 2,
74 AUTO_CLEAN_WHEN_EMPTY = 1 << 3
411 virtual
void updateVelocities();
417 virtual
void storeRelativeTransforms();
422 void postIntegrate();
429 void clearGeneratedInteractions();
445 virtual
void setSimulation(
agxSDK::Simulation* simulation );
465 virtual
void preCollide();
470 virtual
void preStep();
476 virtual
void postStep();
481 virtual
void onCleanup();
492 const
agxSDK::Simulation* getSimulation() const;
506 virtual ~PairData() {}
513 typedef PairInteractionsContainer::iterator PairInteractionsIterator;
514 typedef PairInteractionsContainer::const_iterator PairInteractionsConstIterator;
540 INTEGRATE_POSITIONS = 1 << 0
544 using Flags = agx::BitState<Flag, agx::UInt16>;
550 : otherBodies(), relativeTransform(), mergedBody( nullptr ), id(
agx::
InvalidIndex ),
551 mergedWithWorldCounter( 0 ), rootBodyData( nullptr ), flags(
agx::
UInt16( 0 ) )
557 MergedBody* mergedBody;
560 RootBodyDataRef rootBodyData;
564 virtual ~MergedData() {}
573 ConstraintMergedData()
574 : mergedBody( nullptr ), edge( nullptr ) {}
576 MergedBody* mergedBody;
577 EdgeInteraction* edge;
580 virtual ~ConstraintMergedData() {}
588 void writeConnectivityGraph( std::ostream& stream )
const;
594 template<
typename DataT,
typename ObjT>
595 static DataT* getMergedData(
const ObjT& obj );
600 template<
typename DataT,
typename ObjT>
601 static DataT* getOrCreateMergedData( ObjT obj );
611 static agx::Bool isMerged(
const MergedData* data );
617 Key createKey( EdgeInteraction* edge )
const;
661 void remove( PairInteractionsIterator it );
676 void handleOnAdd( EdgeInteraction* edge );
681 void handleOnRemove(
const EdgeInteractionRefContainer& edges );
686 void handleOnMovedTo(
const EdgeInteractionRefContainer& edges, MergedBody* newMergedBody );
699 void commitGeneratedInteractions();
703 PairInteractionsContainer m_pairInteractions;
704 EdgeInteractionRefContainer m_removedEdges;
705 ListenerContainer m_listeners;
706 RigidBodyContainer m_bodies;
708 mutable InternalState m_state;
769 CONTACT_GENERATOR = 1 << 1,
772 PARTICLE_GENERATOR = 1 << 4
1038 void updateGeometries( GeometryUpdateFunction geometryUpdateFunction );
1046 GeometryContactEdgeInteraction();
1051 virtual ~GeometryContactEdgeInteraction();
1165 template<
typename DataT,
typename ObjT>
1171 template<
typename DataT,
typename ObjT>
1180 const MergedData* data = getMergedData<MergedData>( rb );
1181 return data !=
nullptr ? data->mergedBody :
nullptr;
1186 MergedData* data = getMergedData<MergedData>( rb );
1187 return data !=
nullptr ? data->mergedBody :
nullptr;
1193 return mb !=
nullptr && mb->
isActive() ? mb :
nullptr;
1199 return mb !=
nullptr && mb->
isActive() ? mb :
nullptr;
1204 return rb !=
nullptr &&
1219 return root !=
nullptr ?
root->getRigidBody() : rb;
1225 return root !=
nullptr ?
root->getRigidBody() : rb;
1230 return data !=
nullptr && data->mergedBody !=
nullptr;
1235 return m_simulation !=
nullptr && m_state.Is( READY_FOR_SOLVER );
1240 MergedData* data = getMergedData<MergedData>( rb );
1241 return data !=
nullptr ? data->rootBodyData :
nullptr;
1245 inline
Bool MergedBody::EdgeInteraction::isTagged(InteractionTag tag)
const
1247 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.
@ 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
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.
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::Bool isTagged(InteractionTag tag) const
EmptyEdgeInteraction(agx::RigidBody *rb1, agx::RigidBody *rb2)
Construct given two rigid bodies.
virtual ~ParticleParticleInteraction()
Reference counted object, protected destructor.
static agx::MergedBody * get(agx::Constraint *constraint)
This method returns a merged body if the constraint has been involved in it, e.g.,...
static BinaryConstraintEdgeInteraction * getEdge(const agx::Constraint *constraint)
agx::Bool isActive() const
std::function< void(EdgeInteraction *) > EdgeInteractionVisitor
agx::Bool getValid() const
static agx::Bool split(agx::Constraint *constraint)
Removes the edge defined by the constraint from the merged body, if any.
static const agx::MergedBody * getActive(const agx::RigidBody *rb)
This method returns an agx::MergedBody that is active and in a simulation.
agx::Bool add(Listener *listener)
Add listener to receive callbacks during certain events.
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.
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.
agxCollide::Geometry * getGeometry2() const
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
static const agx::RigidBody * filter(const agx::RigidBody *rb)
Filters rb and returns the merged rigid body if rb is part of one.
agx::Bool remove(agx::RigidBody *rb)
Split/Remove a rigid body from this merged body.
const agx::HighLevelConstraintImplementation * getConstraint() const
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.
static agx::Bool isRoot(const agx::RigidBody *rb)
const agx::RigidBodyPtrVector * getNeighbors(const agx::RigidBody *rb) const
const PointContainer & getPoints() const
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.
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.
agx::HighLevelConstraintImplementation * getConstraint()
void traverse(RigidBodyVisitor visitor, agx::Bool includeDisabled=false) const
Traverse the internal interaction graph and receive callback for all rigid bodies (unique).
static const agx::MergedBody * get(const agx::RigidBody *rb)
This method returns an agx::MergedBody if rb has been added to one.
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 MergedBodyIndex findMergedBodyIndex(agx::Physics::RigidBodyPtr rb)
Similar to filter( const agx::RigidBody* rb ).
void setBodies(agx::RigidBody *rb1, agx::RigidBody *rb2)
Assign bodies during restore.
GeometryContactEdgeInteraction()
Default constructor used by serialization.
ParticleParticleInteraction(agx::RigidBody *substituteBody1, agx::RigidBody *substituteBody2)
Construct given two rigid bodies.
agxCollide::Geometry * getGeometry1() const
void debugPrint(const agx::RigidBody *rb) const
Debug prints (cout) interactions to rb.
const InternalState & getState() const
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.,...
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.
State
Internal state of this merged body.
virtual void restore(agxStream::InputArchive &in) override
Restores the two bodies and the construction state.
EmptyEdgeInteraction()
Default constructor used by serialization.
agx::Bool containsDeletedBodies() const
static BinaryConstraintEdgeInteraction * getEdge(const agx::HighLevelConstraintImplementation *constraint)
virtual ~Listener()
Reference counted object, protected destructor.
const EdgeInteractionRefContainer * getEdges(const agx::RigidBody *rb1, const agx::RigidBody *rb2) const
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::RigidBody * getRigidBody2() const
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
agx::RigidBody * getRigidBody() 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.
const agx::Name & getName() const
agx::RigidBody * getRigidBody1() const
Representation of a name string.
Pointer to a entity instance of type Physics.RigidBody.
AGXPHYSICS_EXPORT agx::RigidBodyState & state()
AGXPHYSICS_EXPORT agx::RigidBody *& model()
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.
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...
agx::observer_ptr< Geometry > GeometryObserver
agx::Vector< LocalGeometryContact > LocalGeometryContactVector
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...
InputRef< T > in(const char *name, T &obj)
Create an object with a name and a reference to the object that should be restored (usually a pointer...
OutputRef< Serializable > out(const char *name, const Serializable *obj)
Return an object that contain the name and the object that should be serialized to an archive.
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 Component * root()
AGXCORE_EXPORT const InvalidIndexStruct InvalidIndex
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)