AGX Dynamics  2.35.0.1
ParticleSystem.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #ifndef AGX_PARTICLESYSTEM_H
18 #define AGX_PARTICLESYSTEM_H
19 
20 #include <agx/Referenced.h>
21 #include <agx/Component.h>
22 #include <agx/Bound.h>
26 #include <agx/Material.h>
27 #include <agx/Emitter.h>
28 #include <agxStream/Serializable.h>
29 #include <agx/Task.h>
30 #include <agxCollide/Geometry.h>
31 #include <agxCollide/Space.h>
32 #include <typeinfo>
33 #include <agx/Logger.h>
34 
35 namespace agxData
36 {
38 }
39 
40 namespace agxIO
41 {
42  class Image;
43 }
44 
45 namespace agxSDK
46 {
47  class Simulation;
48 }
49 
50 AGX_TYPE_BINDING( agxData::ParticlePair, "ParticlePair" )
51 
52 namespace agx
53 {
57 
58 
68  {
69  public:
70  static Model* ClassModel();
71 
75  virtual bool setUpdateTask( Task* updateTask );
76 
80  Task* getUpdateTask();
81 
85  virtual void addNotification( agxSDK::Simulation* simulation );
86 
91 
95  agxData::EntityRange createParticles( size_t numParticles );
96 
101 
106 
111  void destroyParticles( const agxData::EntityPtrVector& particles );
112 
117 
126 
130  bool isValid( Physics::ParticlePtr particle ) const;
131 
136 
141 
142 #if (!defined SWIG ) || ( defined SWIGCSHARP || defined SWIGJAVA)
146  const agx::Physics::ParticlePtrArray getParticles() const;
147  agx::Physics::ParticlePtrArray getParticles();
148 #endif
149 
152 
160  agx::Physics::ParticlePtrVector spawnParticlesInBound( const agx::Bound3& bound, Real radius, const agx::Vec3& spacing, agx::Real jitterFactor = agx::Real( 0 ) );
161 
171 
180  agx::Physics::ParticlePtrVector spawnParticlesInBoundHCP( const agx::Bound3& bound, Real radius, const agx::Vec3& spacing, agx::Real jitterFactor = agx::Real( 0 ) );
181 
191 
200 
209 
219 
229 
235  void colorParticlesWithLevelsInBound( const agx::Bound3& bound, const agx::Vec4fVector& colors );
236 
240  size_t getNumParticles() const;
241 
246 
251 
260  void setParticleRadius( Real radius, bool updateExistingParticles = false );
261 
270  virtual void setParticleMass( Real mass, bool updateExistingParticles = false );
271 
280  void setMaterial( Material* material, bool updateExistingParticles = false );
281 
286  const Material* getMaterial() const;
287 
292 
296  agxData::EntityStorage* getParticleStorage();
297 
301  const agxData::EntityStorage* getParticleStorage() const;
302 
306  agxData::EntityStorage* getParticlePairContactStorage();
307 
311  agxData::EntityStorage* getGeometryParticleContactListStorage();
312 
316  agxData::EntityStorage* getParticleGeometryContactStorage();
317 
322 
327 
332 
337 
342 
347 
353 
354  // Returns the total contact forces between the particles in the system
356 
357  // Returns the total particle-geometry contact forces in the system.
359 
360  // Calculates the total particle volume in the particle system
362 
365 
367 
371  void setEnableCollisions( const agxCollide::Geometry* geometry, bool flag );
372 
376  bool getEnableCollisions( const agxCollide::Geometry* geometry ) const;
377 
381  const agxCollide::GeometryHashVector& getDisabledCollisions() const;
382 
383 
392  // bool canCollide( const agxCollide::Geometry* geometry ) const;
393 
402  void addCollisionGroup( agx::UInt32 id, bool updateExistingParticles = true );
403  void addCollisionGroup( const agx::Name& id, bool updateExistingParticles = true );
404 
409  void removeCollisionGroup( agx::UInt32 id, bool updateExistingParticles = true );
410  void removeCollisionGroup( const agx::Name& id, bool updateExistingParticles = true );
411 
422 
429 
438 
445  bool hasCollisionGroup( agx::UInt32 id ) const;
446  bool hasCollisionGroup( const agx::Name& id ) const;
447 
451  agx::Physics::CollisionGroupSetPtr getCollisionGroupSet() const;
452 
454 
458  bool hasCustomBuffer( const agx::String& buffername, const agx::String& formatName );
459 
465  void addCustomBufferReal( const agx::String& buffername );
466 
473  void setCustomBufferValueReal( agx::Index id, const agx::String& buffername, agx::Real val );
474 
481  agx::Real getCustomBufferValueReal( agx::Index id, const agx::String& buffername );
482 
488  void addCustomBufferInt( const agx::String& buffername );
489 
496  void setCustomBufferValueInt( agx::Index id, const agx::String& buffername, agx::Int val );
497 
504  agx::Int getCustomBufferValueInt( agx::Index id, const agx::String& buffername );
505 
511  void addCustomBufferReal32( const agx::String& buffername );
512 
519  void setCustomBufferValueReal32( agx::Index id, const agx::String& buffername, agx::Real32 val );
520 
527  agx::Real32 getCustomBufferValueReal32( agx::Index id, const agx::String& buffername );
528 
534  void addCustomBufferVec3( const agx::String& buffername );
535 
542  void setCustomBufferValueVec3( agx::Index id, const agx::String& buffername, agx::Vec3 val );
543 
550  agx::Vec3 getCustomBufferValueVec3( agx::Index id, const agx::String& buffername );
551 
554 
556  virtual void destroySingleParticle( agx::Index particleId );
557 
559  virtual void setSingleParticleRadius( agx::Index particleId, agx::Real radius );
560 
563 
565  virtual void setSingleParticleMass( agx::Index particleId, agx::Real mass );
566 
569 
571  virtual void setSingleParticleColor( agx::Index particleId, const agx::Vec4f& color );
572 
575 
577  virtual void setSingleParticleVelocity( agx::Index particleId, const agx::Vec3& velocity );
578 
581 
584 
586  virtual void setSingleParticleForce( agx::Index particleId, const agx::Vec3& force );
587 
590 
593 
596 
604 
609 
615 
620 
626 
630  void attach();
631 
636  void detach();
637 
638  // private
639  void _setGravityTask( Task* task );
640  void setSpace( agxCollide::Space* space );
642 
644 
645  agx::Vector<agx::Physics::ParticlePtr> createParticlesFromImage( agxIO::Image* image, agx::Real particleRadius, const agx::Vec3& center, agx::Real radiusJitter );
646 
648  static Vec3u calculateFilledBoundPacking( agx::Vec3Vector& result, agx::Bound3 bound, const agx::Vec3& spacing, agx::Real boundarySpacing = agx::Real( 0 ), agx::Real jitterFactor = agx::Real( 0 ) );
649  static size_t calculateFilledBoundPackingHCP( agx::Vec3Vector& result, agx::Bound3 bound, const agx::Vec3& distance, agx::Real boundarySpacing = agx::Real( 0 ), agx::Real jitterFactor = agx::Real( 0 ) );
650  static void calculateFilledGeometryPacking( agx::Vec3Vector& result, agxCollide::Geometry* geometry, const agx::Vec3& spacing, agx::Real boundarySpacing = agx::Real( 0 ), agx::Real jitterFactor = agx::Real( 0 ) );
651  static void calculateFilledGeometryPackingHCP( agx::Vec3Vector& result, agxCollide::Geometry* geometry, const agx::Vec3& spacing, agx::Real boundarySpacing = agx::Real( 0 ), agx::Real jitterFactor = agx::Real( 0 ) );
652 
653  template<typename T>
654  void addCustomBufferT( const agx::String& name );
655 
656  template<typename T>
657  void setCustomBufferValueT( agx::Index id, const agx::String& buffername, const T valueT );
658 
659  template<typename T>
660  T getCustomBufferValueT( agx::Index id, const agx::String& buffername );
661 
662  agxSDK::Simulation* getSimulation() const;
663 
664  agx::Physics::ParticlePtrVector convertRangeToParticlePtrVector( agxData::EntityRange& entityRange );
665 
667 
669 
670  protected:
671  ParticleSystem( const String& model, Device* device = CpuDevice::instance() );
672  ParticleSystem(); // Only used for restoring from serialization
673 
674  virtual ~ParticleSystem();
675 
676  void init( bool createMaterial = true );
677  void setCollisionGroupSet( agx::Physics::CollisionGroupSetPtr );
678  void invalidLicenseCallback();
679  TaskGroupRef m_updateTask;
680  void setRadiusOnParticles( agxData::EntityRange& entityRange, agx::Real radius );
681 
682  protected:
690  class AGXPHYSICS_EXPORT MaterialUuidBufferListener : public agxData::Buffer::EventListener, public agx::Referenced
691  {
692  public:
696  virtual void updateCallback( agxData::Buffer* buffer ) override;
697  virtual void updateCallback( agxData::Buffer* buffer, agx::Index index ) override;
698  virtual void updateCallback( agxData::Buffer* buffer, agx::IndexRange range ) override;
699  virtual void updateCallback( agxData::Buffer* buffer, agxData::Array< agx::Index > indexSet ) override;
700 
701  protected:
704  // Variables
706  private:
708  agxSDK::Simulation* m_simulation;
709  };
710 
717  class AGXPHYSICS_EXPORT UpdateRenderingListener : public agxData::Buffer::EventListener, public agx::Referenced
718  {
719  public:
723  virtual void updateCallback( agxData::Buffer* buffer ) override;
724  virtual void updateCallback( agxData::Buffer* buffer, agx::Index index ) override;
725  virtual void updateCallback( agxData::Buffer* buffer, agx::IndexRange range ) override;
726  virtual void updateCallback( agxData::Buffer* buffer, agxData::Array< agx::Index > indexSet ) override;
727 
728  protected:
731  // Variables
733  private:
735  agxSDK::Simulation* m_simulation;
736  };
737 
738  protected:
740  private:
741  agxData::EntityStorageRef m_particleCellStorage;
742  agxData::EntityStorageRef m_cellBlockStorage;
743  agxData::EntityStorageRef m_particleZoneStorage;
744  agxData::EntityStorageRef m_collisionParticleStorage;
745  agxData::EntityStorageRef m_particleGeometryContactStorage;
746  agxData::EntityStorageRef m_particlePairContactStorage;
747  agxData::EntityStorageRef m_geometryParticleContactListStorage;
748 
749  agxData::BufferRef m_materialUuidBuffer;
750  agxData::BufferRef m_stateBuffer;
751  agxData::BufferRef m_cellBlockPermutation;
752  agxData::BufferRef m_deadCellBlocks;
753  agxData::BufferRef m_particlesWithMissingTargetCell;
754  agxData::BufferRef m_cellBlockOverlapPairs;
755  agxData::ValueRef m_particleBound;
756  agxData::ValueRef m_collisionGroupSet;
757  agxData::ValueRef m_defaultRadius;
758  agxData::ValueRef m_defaultMass;
759  agxData::ValueRef m_defaultMaterial;
760 
761  MaterialRef m_material;
762  TaskRef m_gravityTask;
763  bool m_initialized;
764  bool m_dirtyBound;
765 
766  agx::TaskRef m_updateBoundTask;
767 
768  agxCollide::GeometryHashVector m_disabledCollisionsHash;
769  agxCollide::SpaceRef m_space;
770 
771  MaterialUuidBufferListenerRef m_uuidMaterialListenerRef;
772  UpdateRenderingListenerRef m_updateRenderingListenerRef;
773 
774  agxData::ValueObserver m_invMassValue;
775  void massChanged( agxData::Value* massValue );
776  agxData::Value::Event::CallbackType m_massChangedCallback;
777  };
778 
779  /* Implementation */
780  AGX_FORCE_INLINE Task* ParticleSystem::getUpdateTask() { return m_updateTask; }
781 
782  AGX_FORCE_INLINE const agx::Physics::ParticlePtrArray ParticleSystem::getParticles() const
783  {
784  return m_particleStorage->getInstances<Physics::ParticlePtr>();
785  }
786 
787  AGX_FORCE_INLINE agx::Physics::ParticlePtrArray ParticleSystem::getParticles()
788  {
789  return m_particleStorage->getInstances<Physics::ParticlePtr>();
790  }
791 
792  AGX_FORCE_INLINE agxData::EntityStorage* ParticleSystem::getParticleStorage() { return m_particleStorage; }
793  AGX_FORCE_INLINE const agxData::EntityStorage* ParticleSystem::getParticleStorage() const { return m_particleStorage; }
794  AGX_FORCE_INLINE agxData::EntityStorage* ParticleSystem::getParticleGeometryContactStorage() { return m_particleGeometryContactStorage; }
795  AGX_FORCE_INLINE agxData::EntityStorage* ParticleSystem::getGeometryParticleContactListStorage() { return m_geometryParticleContactListStorage; }
796  AGX_FORCE_INLINE agxData::EntityStorage* ParticleSystem::getParticlePairContactStorage() { return m_particlePairContactStorage; }
797 
798  AGX_FORCE_INLINE const agxCollide::GeometryHashVector& ParticleSystem::getDisabledCollisions() const { return m_disabledCollisionsHash; }
799  // AGX_FORCE_INLINE bool ParticleSystem::hasCollisionGroup( agx::UInt32 id ) const { return m_collisionGroups.contains(id); }
800  inline agx::Physics::CollisionGroupSetPtr ParticleSystem::getCollisionGroupSet() const { return m_collisionGroupSet->get<Physics::CollisionGroupSetPtr>(); }
801 
802  // Real
803  AGX_FORCE_INLINE void ParticleSystem::addCustomBufferReal( const agx::String& buffername ) { addCustomBufferT<agx::Real>( buffername ); }
804  AGX_FORCE_INLINE void ParticleSystem::setCustomBufferValueReal( agx::Index id, const agx::String& buffername, agx::Real val ) { setCustomBufferValueT<agx::Real>( id, buffername, val ); }
805  AGX_FORCE_INLINE agx::Real ParticleSystem::getCustomBufferValueReal( agx::Index id, const agx::String& buffername ) { return getCustomBufferValueT<agx::Real>( id, buffername ); }
806 
807  // Int
808  AGX_FORCE_INLINE void ParticleSystem::addCustomBufferInt( const agx::String& buffername ) { addCustomBufferT<agx::Int>( buffername ); }
809  AGX_FORCE_INLINE void ParticleSystem::setCustomBufferValueInt( agx::Index id, const agx::String& buffername, agx::Int val ) { setCustomBufferValueT<agx::Int>( id, buffername, val ); }
810  AGX_FORCE_INLINE agx::Int ParticleSystem::getCustomBufferValueInt( agx::Index id, const agx::String& buffername ) { return getCustomBufferValueT<agx::Int>( id, buffername ); }
811 
812  // Real32
813  AGX_FORCE_INLINE void ParticleSystem::addCustomBufferReal32( const agx::String& buffername ) { addCustomBufferT<agx::Real32>( buffername ); }
814  AGX_FORCE_INLINE void ParticleSystem::setCustomBufferValueReal32( agx::Index id, const agx::String& buffername, agx::Real32 val ) { setCustomBufferValueT<agx::Real32>( id, buffername, val ); }
815  AGX_FORCE_INLINE agx::Real32 ParticleSystem::getCustomBufferValueReal32( agx::Index id, const agx::String& buffername ) { return getCustomBufferValueT<agx::Real32>( id, buffername ); }
816 
817  // Vec3
818  AGX_FORCE_INLINE void ParticleSystem::addCustomBufferVec3( const agx::String& buffername ) { addCustomBufferT<agx::Vec3>( buffername ); }
819  AGX_FORCE_INLINE void ParticleSystem::setCustomBufferValueVec3( agx::Index id, const agx::String& buffername, agx::Vec3 val ) { setCustomBufferValueT<agx::Vec3>( id, buffername, val ); }
820  AGX_FORCE_INLINE agx::Vec3 ParticleSystem::getCustomBufferValueVec3( agx::Index id, const agx::String& buffername ) { return getCustomBufferValueT<agx::Vec3>( id, buffername ); }
821 }
822 
823 // AGX_PARTICLESYSTEM_H
824 #endif
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
Definition: Serializable.h:207
#define AGX_TYPE_BINDING(_Type, _Name)
Definition: Type.h:179
#define AGXPHYSICS_EXPORT
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition: agx/Vector.h:34
The geometry representation used by the collision detection engine.
Definition: Geometry.h:93
This class contains all Geometries and performs Broad Phase and Narrow Phase collision detection to c...
Definition: Space.h:82
Type-specific Array used for fast access into the data held by a Buffer.
Definition: Array.h:107
Abstract representation of a data buffer.
Definition: Buffer.h:56
Data storage for a collection of entity instances of a specified EntityModel.
Definition: EntityStorage.h:73
Abstract representation of a value.
Definition: Value.h:43
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:127
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:45
A component is an object containing other objects, enabling hierarchical structuring.
Definition: Component.h:39
Representation of the CPU.
Definition: Device.h:180
An agx::Device is an abstract representation of a device on which data can be stored and processed.
Definition: Device.h:58
friend class DistributionTable
Definition: Emitter.h:324
T CallbackType
Definition: Event.h:37
Main material class which acts as a holder of a Surface Material and a Bulk material.
Definition: Material.h:388
A model is an abstract representation of the class of an agx::Object.
Definition: Model.h:41
Representation of a name string.
Definition: Name.h:33
MaterialUuidBufferListener(ParticleSystem *system, agxSDK::Simulation *simulation)
virtual void updateCallback(agxData::Buffer *buffer) override
virtual void updateCallback(agxData::Buffer *buffer, agx::Index index) override
void setSimulation(agxSDK::Simulation *sim)
virtual void updateCallback(agxData::Buffer *buffer, agxData::Array< agx::Index > indexSet) override
virtual void updateCallback(agxData::Buffer *buffer, agx::IndexRange range) override
virtual void updateCallback(agxData::Buffer *buffer) override
virtual void updateCallback(agxData::Buffer *buffer, agx::Index index) override
virtual void updateCallback(agxData::Buffer *buffer, agxData::Array< agx::Index > indexSet) override
UpdateRenderingListener(ParticleSystem *system, agxSDK::Simulation *simulation)
void setSimulation(agxSDK::Simulation *sim)
virtual void updateCallback(agxData::Buffer *buffer, agx::IndexRange range) override
A basic particle system that contains all the storages and buffers required for basic operation and a...
agx::Real getTotalParticleParticleContactForces()
void clearAllParticles()
Utility method for clearing all particles in the particle system.
agx::Index getParticleIdFromIndex(agx::Index index) const
Return the particle id for the specified particle entity array index.
size_t getNumParticleParticleContacts()
Returns the number of particle-particle contacts.
agx::Physics::ParticlePtrVector spawnParticlesInGeometryHCP(agxCollide::Geometry *geometry, agx::Emitter::DistributionTable *sourceTable, const agx::Vec3 &spacing, agx::Real jitterFactor=agx::Real(0))
Spawns particles In a specified geometry from a distribution table using a Hexagonal-Close-Packing (H...
agx::Vector< agx::Physics::ParticleGeometryContactPtr > getParticleGeometryContacts()
Returns the current ParticleGeometryContacts in the simulation.
void detach()
Unbinds relevant buffer pointers from objects after removing the particle system into the simulation.
virtual agx::Vec3 getSingleParticleForce(agx::Index particleId)
Get particle velocity with specified id.
virtual agx::Vec3 getSingleParticleVelocity(agx::Index particleId)
Get particle velocity with specified id.
virtual bool setUpdateTask(Task *updateTask)
Set the task that will be executed whenever it is time to step the simulation.
void setSpace(agxCollide::Space *space)
void destroyParticles(agxData::EntityRange particles)
Destroy a range of particles.
virtual void setParticleMass(Real mass, bool updateExistingParticles=false)
Set particle mass.
virtual void setSingleParticleRadius(agx::Index particleId, agx::Real radius)
Set particle radius with specified id.
agx::Physics::ParticlePtrVector spawnParticlesInBound(const agx::Bound3 &bound, Real radius, const agx::Vec3 &spacing, agx::Real jitterFactor=agx::Real(0))
Spawns particles in a specified bound.
virtual agx::Real getSingleParticleRadius(agx::Index particleId)
Get particle radius with specified id.
void removeCollisionGroupParticle(agx::UInt32 id, agx::Physics::ParticlePtr ptr)
Remove a group id from the vector of group ids.
virtual agx::Vec3 getSingleParticlePosition(agx::Index particleId)
Get particle position with specified id.
agx::Real getTotalParticleGeometryContactForces()
agx::Physics::ParticlePtrVector spawnParticlesInBoundHCP(const agx::Bound3 &bound, Real radius, const agx::Vec3 &spacing, agx::Real jitterFactor=agx::Real(0))
Spawns particles In a specified bound using a Hexagonal-Close-Packing (HCP) lattice.
agx::Real calculateTotalParticleMass() const
Calculates the total particle mass in the particle system.
void attach()
Binds relevant buffer pointers to objects after inserting the particle system into the simulation.
virtual void setSingleParticleMass(agx::Index particleId, agx::Real mass)
Set particle radius with specified id.
void addCollisionGroupParticle(agx::UInt32 id, agx::Physics::ParticlePtr ptr)
Add the specified id to a vector of group id, this make the specific particle part of the group id.
static Model * ClassModel()
Physics::ParticlePtr getParticle(agx::Index particleId)
Returns a particle from the particle system given a particle id.
size_t getNumActiveParticleGeometryContacts()
Returns the number of ACTIVE particle-geometry contacts, after the last conducted contact filtering.
bool hasCollisionGroupParticle(agx::UInt32 id, agx::Physics::ParticlePtr ptr) const
This is performing a linear search among the group id for this particle.
agx::Physics::ParticlePtrVector spawnParticlesInBound(const agx::Bound3 &bound, agx::Emitter::DistributionTable *sourceTable, const agx::Vec3 &spacing, agx::Real jitterFactor=agx::Real(0))
Spawns particles In a specified bound from a distribution table.
size_t getNumParticleGeometryContacts()
Returns the number of particle-geometry contacts.
void removeCollisionGroup(agx::UInt32 id, bool updateExistingParticles=true)
Remove a group id from the vector of group ids.
size_t getNumParticles() const
agx::Physics::ParticleGeometryContactPtr createParticleGeometryContact(agx::Physics::ParticlePtr particle, agx::Physics::GeometryPtr geometry)
virtual agx::Vec4f getSingleParticleColor(agx::Index particleId)
Get particle color with specified id.
void addCollisionGroupParticle(const agx::Name &id, agx::Physics::ParticlePtr ptr)
bool hasCollisionGroup(const agx::Name &id) const
void destroyParticles(const agxData::EntityPtrVector &particles)
void removeCollisionGroup(const agx::Name &id, bool updateExistingParticles=true)
void addCollisionGroup(agx::UInt32 id, bool updateExistingParticles=true)
Add the specified id to a vector of group id, this will make a all newly created particles part of th...
void addCollisionGroup(const agx::Name &id, bool updateExistingParticles=true)
Real getParticleMass() const
agxData::EntityStorageRef m_particleStorage
void updateShouldRender()
Update the shouldRender variable in particles given renders states such as clipping and filtering.
void removeCollisionGroupParticle(const agx::Name &id, agx::Physics::ParticlePtr ptr)
agx::Physics::ParticlePtrVector spawnParticlesInGeometry(agxCollide::Geometry *geometry, Real radius, const agx::Vec3 &spacing, agx::Real jitterFactor=agx::Real(0))
Spawns particles In a specified geometry.
void commitColorBuffer()
Executes the "commit" command on the buffer so that particle rendering can be updated properly.
void setMaterial(Material *material, bool updateExistingParticles=false)
Set the default particle material.
bool hasCollisionGroup(agx::UInt32 id) const
This is performing a linear search among the group id for this particle.
bool isParticlePairContactValid(Physics::ParticlePairContactPtr contact)
void setEnableCollisions(const agxCollide::Geometry *geometry, bool flag)
Specify whether otherGeometry is allowed to collide with this geometry.
Material * getMaterial()
Real getParticleRadius() const
void destroyParticles(const Physics::ParticlePtrVector &particles)
Destroy a list of particles.
const agx::Bound3 & getParticleBound()
void removeParticle(Physics::ParticlePtr particle)
Tag a particle for removal at the end of the time step.
virtual void setSingleParticleForce(agx::Index particleId, const agx::Vec3 &force)
Set particle force with specified id.
void setParticleRadius(Real radius, bool updateExistingParticles=false)
Set the default particle radius of created particles, with option of updating existing particles.
const Material * getMaterial() const
bool isParticleGeometryContactValid(Physics::ParticleGeometryContactPtr contact)
virtual void setSingleParticleVelocity(agx::Index particleId, const agx::Vec3 &velocity)
Set particle velocity with specified id.
void evaluateParticleDefaultMass()
This should be called if the density of the bulk material is changed, so the particle default mass is...
void applyAirForceDragSimple(agx::Real cd, agx::Real cr)
Apply air drag to the particles according to formula: cd * velocity^2 + cr * velocity.
void commitAllBuffers()
Executes the "commit" command all buffers in the particle system.
virtual void addNotification(agxSDK::Simulation *simulation)
Triggers when particlesystem is added to the simulation.
bool getEnableCollisions(const agxCollide::Geometry *geometry) const
agx::Physics::ParticlePairContactPtr createParticlePairContact(agx::Physics::ParticlePtr p1, agx::Physics::ParticlePtr p2)
agx::Physics::ParticlePtrVector spawnParticlesInGeometry(agxCollide::Geometry *geometry, agx::Emitter::DistributionTable *sourceTable, const agx::Vec3 &spacing, agx::Real jitterFactor=agx::Real(0))
Spawns particles In a specified geometry from a distribution table.
bool particleExistsWithId(agx::Index id)
Check if there is a particle with a specified id.
void colorParticlesWithLevelsInBound(const agx::Bound3 &bound, const agx::Vec4fVector &colors)
Colors particles with different levels in the vertical z-direction inside a specified bound.
agxData::EntityRange spawnParticles(const agx::Vec3Vector &positions)
Spawn particles with defined positions.
Physics::ParticlePtr createParticle()
Create a new particle in the particle system.
virtual void destroySingleParticle(agx::Index particleId)
Destroy particle with specified id.
bool hasCollisionGroupParticle(const agx::Name &id, agx::Physics::ParticlePtr ptr) const
Vec3 sumForceMagnitudes(RigidBody *body)
Sums force magnitudes from particle system onto rigid body.
agxData::EntityRange createParticles(size_t numParticles)
Create a set of particles in the particle system.
virtual agx::Real getSingleParticleMass(agx::Index particleId)
Get particle radius with specified id.
void _setGravityTask(Task *task)
bool hasCustomBuffer(const agx::String &buffername, const agx::String &formatName)
Returns true if the particle system has a buffer with the specified name and format.
size_t getNumActiveParticleParticleContacts()
Returns the number of ACTIVE particle-particle contacts, after the last conducted contact filtering.
virtual void setSingleParticleColor(agx::Index particleId, const agx::Vec4f &color)
Set particle color with specified id.
bool isValid(Physics::ParticlePtr particle) const
agx::Physics::ParticlePtrVector spawnParticlesInGeometryHCP(agxCollide::Geometry *geometry, Real radius, const agx::Vec3 &spacing, agx::Real jitterFactor=agx::Real(0))
Spawns particles In a specified geometry using a Hexagonal-Close-Packing (HCP) lattice.
agx::Real calculateTotalParticleVolume() const
agx::Vector< agx::Physics::ParticlePairContactPtr > getParticleParticleContacts()
Returns the current ParticleParticle contacts in the simulation.
void destroyParticle(Physics::ParticlePtr particle)
Destroy a particle.
agx::Physics::ParticlePtrVector spawnParticlesInBoundHCP(const agx::Bound3 &bound, agx::Emitter::DistributionTable *sourceTable, const agx::Vec3 &spacing, agx::Real jitterFactor=agx::Real(0))
Spawns particles in a specified bound from a distribution table using a Hexagonal-Close-Packing (HCP)...
Pointer to a entity instance of type Physics.CollisionGroupSet.
Pointer to a entity instance of type Physics.Geometry.
Pointer to a entity instance of type Physics.ParticleGeometryContact.
Pointer to a entity instance of type Physics.ParticlePairContact.
Pointer to a entity instance of type Physics.Particle.
Base class providing referencing counted objects.
Definition: Referenced.h:114
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:55
This class is a combined container which has the find complexity of a HashTable, deterministic iterat...
Definition: SetVector.h:38
A std::pair, with both elements of the same type, and symmetric so (a, b) == (b, a)
Definition: SymmetricPair.h:32
A representation of a generic task.
Definition: Task.h:58
A class holding 4 dimensional vectors and providing basic arithmetic.
Definition: Vec4Template.h:35
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:97
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:96
#define AGX_FORCE_INLINE
Definition: macros.h:58
This namespace consists of a set of classes for handling geometric intersection tests including boole...
Contains classes for low level data storage for AGX.
Definition: Container.h:23
agx::SymmetricPair< agx::Physics::ParticlePtr > ParticlePair
The agxIO namespace contains classes for reading, writing and finding files.
Definition: Material.h:42
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:31
agx::VectorPOD< ParticlePtr > ParticlePtrVector
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
agx::SetVector< agx::ref_ptr< agx::ParticleSystem > > ParticleSystemRefSetVector
uint32_t UInt32
Definition: Integer.h:40
int32_t Int
Definition: Integer.h:35
double Real
Definition: Real.h:42
float Real32
Definition: Real.h:44
void AGXPHYSICS_EXPORT init()
Initialize agx.
UInt32 Index
Definition: Integer.h:52