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
193 static BinaryConstraintEdgeInteraction* getEdge(
const agx::Constraint* constraint );
271 agx::Bool remove( EdgeInteraction* edge );
342 void setEnableAutomaticCleanupWhenEmpty(
agx::Bool enable );
347 agx::Bool getEnableAutomaticCleanupWhenEmpty()
const;
356 void traverse( RigidBodyVisitor visitor,
agx::Bool includeDisabled =
false )
const;
365 void traverse( EdgeInteractionVisitor visitor,
agx::Bool includeDisabled =
false )
const;
376 void traverse(
const agx::RigidBody* rb, EdgeInteractionVisitor visitor,
agx::Bool includeDisabled =
false )
const;
392 const InternalState& getState()
const;
402 void getDebugRenderColor(
agx::Vec3& color )
const;
411 virtual
void updateVelocities();
417 virtual
void storeRelativeTransforms();
422 void postIntegrate();
429 void clearGeneratedInteractions();
436 virtual ~MergedBody() throw();
445 virtual
void setSimulation(
agxSDK::Simulation* simulation );
450 virtual
void onRemove(
agx::RigidBody* rb );
460 virtual
void onRemove(
agxCollide::Geometry* geometry );
465 virtual
void preCollide();
470 virtual
void preStep();
476 virtual
void postStep();
481 virtual
void onCleanup();
487 agxSDK::Simulation* getSimulation();
492 const
agxSDK::Simulation* getSimulation() const;
503 EdgeInteractionRefContainer edges;
506 virtual ~PairData() {}
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 ) )
560 RootBodyDataRef rootBodyData;
564 virtual ~MergedData() {}
573 ConstraintMergedData()
574 : mergedBody( nullptr ), edge( nullptr ) {}
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
848 virtual ~EdgeInteraction();
867 class AGXPHYSICS_EXPORT MergedBody::EmptyEdgeInteraction :
public MergedBody::EdgeInteraction
892 EmptyEdgeInteraction();
897 virtual ~EmptyEdgeInteraction();
909 class AGXPHYSICS_EXPORT MergedBody::ContactGeneratorEdgeInteraction :
public MergedBody::EdgeInteraction
934 ContactGeneratorEdgeInteraction();
939 virtual ~ContactGeneratorEdgeInteraction();
950 class AGXPHYSICS_EXPORT MergedBody::GeometryContactEdgeInteraction :
public MergedBody::EdgeInteraction
1007 const PointContainer& getPoints()
const;
1028 typedef std::function<agxCollide::Geometry*( agxCollide::Geometry*, agx::RigidBody* )> GeometryUpdateFunction;
1038 void updateGeometries( GeometryUpdateFunction geometryUpdateFunction );
1046 GeometryContactEdgeInteraction();
1051 virtual ~GeometryContactEdgeInteraction();
1059 PointContainer m_points;
1066 class
AGXPHYSICS_EXPORT MergedBody::BinaryConstraintEdgeInteraction : public MergedBody::EdgeInteraction
1073 explicit BinaryConstraintEdgeInteraction(
agx::Constraint* constraint );
1108 BinaryConstraintEdgeInteraction();
1113 virtual ~BinaryConstraintEdgeInteraction();
1127 class AGXPHYSICS_EXPORT MergedBody::ParticleParticleInteraction :
public MergedBody::EdgeInteraction
1152 ParticleParticleInteraction();
1157 virtual ~ParticleParticleInteraction();
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;
1192 const MergedBody* mb = MergedBody::get( rb );
1193 return mb !=
nullptr && mb->
isActive() ? mb :
nullptr;
1198 MergedBody* mb = MergedBody::get( rb );
1199 return mb !=
nullptr && mb->
isActive() ? mb :
nullptr;
1204 return rb !=
nullptr &&
1212 const MergedBody*
root = getActive( rb.
model() );
1218 const MergedBody*
root = getActive( rb );
1224 MergedBody*
root = getActive( 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;
1247 return ( m_tag & (
Int32)tag ) != 0;
AGXPHYSICS_EXPORT agx::RigidBody *& model()
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...
Merged states, neighbors etc.
Object with index of merged body and the original index of a merged object.
agx::BitState< State > InternalState
A std::pair, with both elements of the same type, and symmetric so (a, b) == (b, a) ...
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...
MergedBodyIndex(agx::Physics::RigidBodyPtr rb, agx::Physics::RigidBodyPtr orgRb)
Construct given object associated to index, and an original object associated to originalIndex.
Contact point data store in first rigid body local frame.
Base class for a merge split algorithm handling a set of merged bodies.
This namespace consists of a set of classes for handling geometric intersection tests including boole...
virtual void onRemoved(const MergedBody::EdgeInteractionRefContainer &, const agx::MergedBody *) const
Called when an edge is removed from the merged body.
agx::Physics::RigidBodyPtr getEntity() const
Internal method.
Base class for a strong interaction concept where there interaction is defined in the mass matrix par...
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.
agx::VectorPOD< Point > PointContainer
agx::SetVector< agx::MergedBodyRef > MergedBodyRefSetVector
#define AGXPHYSICS_EXPORT
agx::Bool isActive() const
agx::Vector< EdgeInteractionRef > EdgeInteractionRefContainer
The base class for a constraint.
virtual void generateInteraction(agxSDK::Simulation *, agxCollide::LocalGeometryContactVector &) override
Does nothing.
AGXCORE_EXPORT const InvalidIndexStruct InvalidIndex
VectorType::iterator iterator
#define AGX_DECLARE_POINTER_TYPES(type)
Representation of a name string.
agx::Bool isMerged() const
AGXPHYSICS_EXPORT agx::RigidBodyState & state()
Base class providing referencing counted objects.
The geometry representation used by the collision detection engine.
Structure holding several "normal" rigid bodies.
The body fixed node is attached to a body at a given offset.
Pointer to a entity instance of type Physics.RigidBody.
virtual void onAdd(agx::RigidBody *, const agx::MergedBody *) const
Called when a body is added to the merged body.
Vector containing 'raw' data.
agx::Vector< LocalGeometryContact > LocalGeometryContactVector
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Implements a Wire model with adaptive resolution.
State
Internal state of this merged body.
The rigid body class, combining a geometric model and a frame of reference.
Abstract base class for storing/restoring a line/drums with version control.
std::function< void(EdgeInteraction *) > EdgeInteractionVisitor
virtual void onRemove(agx::RigidBody *, const agx::MergedBody *) const
Called when a body is removed from the merged body.
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
agx::RigidBody * getRigidBody() const
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Class for writing serialized data in binary format to a stream.
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
#define AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE(T)
Use this in a pure abstract Serializable class to add the required methods Important: Use full namesp...
MergedBodyIndex()
Default constructor initializes both indices to Invalid Index.
#define AGX_DECLARE_VECTOR_TYPES(type)
MotionControl
The MotionControl enumeration indicates what makes a RigidBody move.
AGXCORE_EXPORT Component * root()
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
std::function< void(agx::RigidBody *) > RigidBodyVisitor
#define DOXYGEN_END_INTERNAL_BLOCK()
virtual void onAdded(EdgeInteraction *, const agx::MergedBody *) const
Called when an edge is added to the merged body.
#define DOXYGEN_START_INTERNAL_BLOCK()
agx::observer_ptr< Geometry > GeometryObserver
VectorType::const_iterator const_iterator
Flags
Flags for specifying what is enabled in the debug rendering system.