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() );
240 virtual bool empty()
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;
#define AGXPHYSICS_EXPORT
The geometry representation used by the collision detection engine.
An assembly is a collection of basic simulation objects, such as rigid bodies, constraints,...
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...
Interface class used by internal objects running in parallel.
virtual bool add(agxCollide::Geometry *geometry)=0
virtual const agx::GravityField * getGravityField() const =0
virtual void setSimulation(agxSDK::Simulation *simulation)=0
virtual agx::Real getTimeStep() const =0
virtual void commit(agxSDK::Simulation *simulation)=0
virtual void transferToDefaultStorage(agx::ContactMaterial *material)=0
virtual void preParallelRun()=0
virtual void postParallelRun()=0
virtual void removeGroup(agxCollide::Geometry *geometry, agx::UInt32 id)=0
virtual void addGeometryContacts(const agxCollide::LocalGeometryContactVector &contacts)=0
virtual const agxSDK::MaterialManager * getMaterialManager() const =0
virtual void setEnable(agxCollide::Geometry *geometry, bool enable)=0
virtual agxSDK::Simulation * getSimulationUnsafe() const =0
virtual bool getRunningParallel() const =0
virtual void transferToSimulationStorage(agx::ContactMaterial *material)=0
virtual const agxSDK::Simulation * getSimulation() const =0
virtual bool remove(agxCollide::Geometry *geometry)=0
virtual void addGroup(agxCollide::Geometry *geometry, agx::UInt32 id)=0
virtual bool empty() const =0
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.
bool add(agx::Material *material)
Add a material to the simulation.
void commit(agxSDK::SimulationProxy *simulationProxy)
Internal method.
static agxSDK::SimulationProxyRef createDefaultProxy(agxSDK::Simulation *simulation)
Creates new simulation proxy of default type.
agxSDK::SimulationProxy * getSimulationProxy() const
Internal method.
The base class for a constraint.
The class GravityField is responsible for calculating and applying a gravity force on a set of bodies...
Representation of a name string.
The rigid body class, combining a geometric model and a frame of reference.
Base class for a strong interaction concept where there interaction is defined in the mass matrix par...
#define DOXYGEN_END_INTERNAL_BLOCK()
#define DOXYGEN_START_INTERNAL_BLOCK()
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Implements a Wire model with adaptive resolution.
std::lock_guard< T > ScopeLock
agx::ScopeLock is an alias for std::lock_guard