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;