31 template<
typename T >
32 class SimulationProxyT :
public T
39 : m_simulationProxy(
agxSDK::Simulation::createDefaultProxy( nullptr ) ) {}
41 virtual ~SimulationProxyT() {}
46 virtual void addNotification(
agxSDK::Simulation* simulation ) { handleAddNotification( simulation ); }
51 virtual void removeNotification(
agxSDK::Simulation* simulation ) { handleRemoveNotification( simulation ); }
56 virtual void addNotification() { handleAddNotification( getSimulation() ); }
61 virtual void removeNotification() { handleRemoveNotification( getSimulation() ); }
69 if ( simulation !=
nullptr ) {
70 simulation->
commit( m_simulationProxy );
81 agxAssert( m_simulationProxy->getSimulation() ==
nullptr || m_simulationProxy->empty() );
157 virtual bool add(
agx::RigidBody* body,
bool addGeometries =
true )
override;
163 virtual bool remove(
agx::RigidBody* body,
bool removeGeometries = true )
override;
169 virtual void setEnable(
agx::RigidBody* body,
bool enable )
override;
240 virtual bool empty()
const override;
245 virtual bool getRunningParallel()
const override;
250 virtual void preParallelRun()
override;
255 virtual void postParallelRun()
override;
267 virtual agx::Real getTimeStep()
const override;
298 virtual ~SimulationProxy() {}
309 template<
typename T >
310 class AddRemoveCompatibleObject
313 AddRemoveCompatibleObject() {}
315 bool add( T*
object )
317 if (
object ==
nullptr || m_objectsToAdd.contains(
object ) )
322 m_objectsToAdd.push_back(
object );
323 m_objectsToRemove.findAndErase(
object );
328 bool remove( T* object )
330 if (
object ==
nullptr || m_objectsToRemove.contains(
object ) )
335 m_objectsToRemove.push_back(
object );
336 m_objectsToAdd.findAndErase(
object );
343 while ( !m_objectsToAdd.empty() ) {
344 simulation->
add( m_objectsToAdd.back() );
345 m_objectsToAdd.pop_back();
348 while ( !m_objectsToRemove.empty() ) {
349 simulation->
remove( m_objectsToRemove.back() );
350 m_objectsToRemove.pop_back();
354 bool empty()
const {
return m_objectsToAdd.empty() && m_objectsToRemove.empty(); }
360 ObjRefContainer m_objectsToAdd;
361 ObjRefContainer m_objectsToRemove;
365 template<
typename T >
366 class AddRemoveEnableCompatibleObject :
public AddRemoveCompatibleObject< T >
369 AddRemoveEnableCompatibleObject() {}
371 void setEnable( T*
object,
bool enable )
373 if (
object ==
nullptr )
379 if ( m_objectsToEnable.contains(
object ) )
381 m_objectsToEnable.push_back(
object );
382 m_objectsToDisable.findAndErase(
object );
385 if ( m_objectsToDisable.contains(
object ) )
387 m_objectsToDisable.push_back(
object );
388 m_objectsToEnable.findAndErase(
object );
394 AddRemoveCompatibleObject< T >::commit( simulation );
396 while ( !m_objectsToEnable.empty() ) {
397 m_objectsToEnable.back()->setEnable(
true );
398 m_objectsToEnable.pop_back();
401 while ( !m_objectsToDisable.empty() ) {
402 m_objectsToDisable.back()->setEnable(
false );
403 m_objectsToDisable.pop_back();
407 bool empty()
const {
return AddRemoveCompatibleObject<T>::empty() && m_objectsToEnable.empty() && m_objectsToDisable.empty(); }
413 ObjRefContainer m_objectsToEnable;
414 ObjRefContainer m_objectsToDisable;
424 bool m_runningParallel;
425 AddRemoveEnableCompatibleObject< agxCollide::Geometry > m_geometries;
426 AddRemoveEnableCompatibleObject< agx::RigidBody > m_rigidBodies;
427 AddRemoveEnableCompatibleObject< agx::Constraint > m_constraints;
428 AddRemoveEnableCompatibleObject< agx::StrongInteraction > m_strongInteractions;
429 AddRemoveCompatibleObject< agxSDK::Assembly > m_asssemblies;
430 AddRemoveEnableCompatibleObject< agxSDK::EventListener > m_eventListeners;
431 GeometryRefIdContainer m_geometryGroupsAdd;
432 GeometryRefIdContainer m_geometryGroupsRemove;
433 GeometryRefNameContainer m_namedGeometryGroupsAdd;
434 GeometryRefNameContainer m_namedGeometryGroupsRemove;
Base class for a strong interaction concept where there interaction is defined in the mass matrix par...
bool add(agx::Material *material)
Add a material to the simulation.
#define AGXPHYSICS_EXPORT
The base class for a constraint.
Representation of a name string.
The geometry representation used by the collision detection engine.
AGXPHYSICS_EXPORT void addGroup(const agx::RigidBody *body, unsigned id)
For the specified body, add the collision group ID to its geometries.
Implements a Wire model with adaptive resolution.
std::lock_guard< T > ScopeLock
agx::ScopeLock is an alias for std::lock_guard
void commit(agxSDK::SimulationProxy *simulationProxy)
Internal method.
static agxSDK::SimulationProxyRef createDefaultProxy(agxSDK::Simulation *simulation)
Creates new simulation proxy of default type.
The rigid body class, combining a geometric model and a frame of reference.
AGXPHYSICS_EXPORT void removeGroup(const agx::RigidBody *body, unsigned id)
For the specified body, remove the collision group ID to its geometries.
An EventListener can be associated to a Simulation and triggered upon various events.
Simulation unique manager that handles logics around and parameters in contact materials given two ag...
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
bool remove(agx::ContactMaterial *material)
Remove an explicit contact material from the set of existing ContactMaterials.
The class GravityField is responsible for calculating and applying a gravity force on a set of bodies...
Interface class used by internal objects running in parallel.
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
agxSDK::SimulationProxy * getSimulationProxy() const
Internal method.
#define DOXYGEN_END_INTERNAL_BLOCK()
#define DOXYGEN_START_INTERNAL_BLOCK()
An assembly is a collection of basic simulation objects, such as rigid bodies, constraints, geometries.