AGX Dynamics 2.42.1.1
Loading...
Searching...
No Matches
ParticleSystem.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx 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>
29#include <agx/Task.h>
30#include <agxCollide/Geometry.h>
31#include <agxCollide/Space.h>
32#include <typeinfo>
33#include <agx/Logger.h>
34
35namespace agxData
36{
38}
39
40namespace agxIO
41{
42 class Image;
43}
44
45namespace agxSDK
46{
47 class Simulation;
48}
49
51
52namespace 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
112
117
127
131 bool isValid( Physics::ParticlePtr particle ) const;
132
137
142
143#if (!defined SWIG ) || ( defined SWIGCSHARP || defined SWIGJAVA)
147 const agx::Physics::ParticlePtrArray getParticles() const;
148 agx::Physics::ParticlePtrArray getParticles();
149#endif
150
153
162 agx::Physics::ParticlePtrVector spawnParticlesInBound( const agx::Bound3& bound, Real radius, const agx::Vec3& spacing, agx::Real jitterFactor = agx::Real( 0 ) );
163
173
182 agx::Physics::ParticlePtrVector spawnParticlesInBoundHCP( const agx::Bound3& bound, Real radius, const agx::Vec3& spacing, agx::Real jitterFactor = agx::Real( 0 ) );
183
193
203
213
223
233
240
244 size_t getNumParticles() const;
245
250
255
264 void setParticleRadius( Real radius, bool updateExistingParticles = false );
265
274 virtual void setParticleMass( Real mass, bool updateExistingParticles = false );
275
284 void setMaterial( Material* material, bool updateExistingParticles = false );
285
293
298 const Material* getMaterial() const;
299
304
308 agxData::EntityStorage* getParticleStorage();
309
313 const agxData::EntityStorage* getParticleStorage() const;
314
318 agxData::EntityStorage* getParticlePairContactStorage();
319
323 agxData::EntityStorage* getGeometryParticleContactListStorage();
324
328 agxData::EntityStorage* getParticleGeometryContactStorage();
329
334
339
344
349
354
359
365
366 // Returns the total contact forces between the particles in the system
368
369 // Returns the total particle-geometry contact forces in the system.
371
372 // Calculates the total particle volume in the particle system
374
377
380
382
386 void setEnableCollisions( const agxCollide::Geometry* geometry, bool flag );
387
391 bool getEnableCollisions( const agxCollide::Geometry* geometry ) const;
392
396 const agxCollide::GeometryHashVector& getDisabledCollisions() const;
397
398
407 void addCollisionGroup( agx::UInt32 id, bool updateExistingParticles = true );
408 void addCollisionGroup( const agx::Name& id, bool updateExistingParticles = true );
409
414 void removeCollisionGroup( agx::UInt32 id, bool updateExistingParticles = true );
415 void removeCollisionGroup( const agx::Name& id, bool updateExistingParticles = true );
416
427
434
443
451 bool hasCollisionGroup( const agx::Name& id ) const;
452
456 agx::Physics::CollisionGroupSetPtr getCollisionGroupSet() const;
457
459
463 bool hasCustomBuffer( const agx::String& buffername, const agx::String& formatName );
464
470 void addCustomBufferReal( const agx::String& buffername );
471
478 void setCustomBufferValueReal( agx::Index id, const agx::String& buffername, agx::Real val );
479
486 agx::Real getCustomBufferValueReal( agx::Index id, const agx::String& buffername );
487
493 void addCustomBufferInt( const agx::String& buffername );
494
501 void setCustomBufferValueInt( agx::Index id, const agx::String& buffername, agx::Int val );
502
509 agx::Int getCustomBufferValueInt( agx::Index id, const agx::String& buffername );
510
516 void addCustomBufferReal32( const agx::String& buffername );
517
524 void setCustomBufferValueReal32( agx::Index id, const agx::String& buffername, agx::Real32 val );
525
532 agx::Real32 getCustomBufferValueReal32( agx::Index id, const agx::String& buffername );
533
539 void addCustomBufferVec3( const agx::String& buffername );
540
547 void setCustomBufferValueVec3( agx::Index id, const agx::String& buffername, agx::Vec3 val );
548
555 agx::Vec3 getCustomBufferValueVec3( agx::Index id, const agx::String& buffername );
556
559
561 virtual void destroySingleParticle( agx::Index particleId );
562
564 virtual void setSingleParticleRadius( agx::Index particleId, agx::Real radius );
565
568
570 virtual void setSingleParticleMass( agx::Index particleId, agx::Real mass );
571
574
576 virtual void setSingleParticleColor( agx::Index particleId, const agx::Vec4f& color );
577
580
582 virtual void setSingleParticleVelocity( agx::Index particleId, const agx::Vec3& velocity );
583
586
589
591 virtual void setSingleParticleForce( agx::Index particleId, const agx::Vec3& force );
592
595
598
601
609
614
620
625
631
635 void attach();
636
641 void detach();
642
643 // private
644 void _setGravityTask( Task* task );
647
648
649
651
652 agx::Vector<agx::Physics::ParticlePtr> createParticlesFromImage( agxIO::Image* image, agx::Real particleRadius, const agx::Vec3& center, agx::Real radiusJitter );
653
655 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 ) );
656 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 ) );
657 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 ) );
658 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 ) );
659
660 template<typename T>
661 void addCustomBufferT( const agx::String& name );
662
663 template<typename T>
664 void setCustomBufferValueT( agx::Index id, const agx::String& buffername, const T valueT );
665
666 template<typename T>
667 T getCustomBufferValueT( agx::Index id, const agx::String& buffername );
668
669 agxSDK::Simulation* getSimulation() const;
670
671 agx::Physics::ParticlePtrVector convertRangeToParticlePtrVector( agxData::EntityRange& entityRange );
672
674
676
677 protected:
678 ParticleSystem( const String& model, Device* device = CpuDevice::instance() );
679 ParticleSystem(); // Only used for restoring from serialization
680
681 virtual ~ParticleSystem();
682
683 void init( bool createMaterial = true );
684 void setCollisionGroupSet( agx::Physics::CollisionGroupSetPtr );
685 void invalidLicenseCallback();
686 TaskGroupRef m_updateTask;
687 void setRadiusOnParticles( agxData::EntityRange& entityRange, agx::Real radius );
688
689 protected:
697 class AGXPHYSICS_EXPORT MaterialUuidBufferListener : public agxData::Buffer::EventListener, public agx::Referenced
698 {
699 public:
703 virtual void updateCallback( agxData::Buffer* buffer ) override;
704 virtual void updateCallback( agxData::Buffer* buffer, agx::Index index ) override;
705 virtual void updateCallback( agxData::Buffer* buffer, agx::IndexRange range ) override;
706 virtual void updateCallback( agxData::Buffer* buffer, agxData::Array< agx::Index > indexSet ) override;
707
708 protected:
711 // Variables
713 private:
715 agxSDK::Simulation* m_simulation;
716 };
717
724 class AGXPHYSICS_EXPORT UpdateRenderingListener : public agxData::Buffer::EventListener, public agx::Referenced
725 {
726 public:
730 virtual void updateCallback( agxData::Buffer* buffer ) override;
731 virtual void updateCallback( agxData::Buffer* buffer, agx::Index index ) override;
732 virtual void updateCallback( agxData::Buffer* buffer, agx::IndexRange range ) override;
733 virtual void updateCallback( agxData::Buffer* buffer, agxData::Array< agx::Index > indexSet ) override;
734
735 protected:
738 // Variables
740 private:
742 agxSDK::Simulation* m_simulation;
743 };
744
745 protected:
747 private:
748 agxData::EntityStorageRef m_particleCellStorage;
749 agxData::EntityStorageRef m_cellBlockStorage;
750 agxData::EntityStorageRef m_particleZoneStorage;
751 agxData::EntityStorageRef m_collisionParticleStorage;
752 agxData::EntityStorageRef m_particleGeometryContactStorage;
753 agxData::EntityStorageRef m_particlePairContactStorage;
754 agxData::EntityStorageRef m_geometryParticleContactListStorage;
755
756 agxData::BufferRef m_materialUuidBuffer;
757 agxData::BufferRef m_stateBuffer;
758 agxData::BufferRef m_cellBlockPermutation;
759 agxData::BufferRef m_deadCellBlocks;
760 agxData::BufferRef m_particlesWithMissingTargetCell;
761 agxData::BufferRef m_cellBlockOverlapPairs;
762 agxData::ValueRef m_particleBound;
763 agxData::ValueRef m_collisionGroupSet;
764 agxData::ValueRef m_defaultRadius;
765 agxData::ValueRef m_defaultMass;
766 agxData::ValueRef m_defaultMaterial;
767
768 MaterialRef m_material;
769 TaskRef m_gravityTask;
770 bool m_initialized;
771 bool m_dirtyBound;
772
773 agx::TaskRef m_updateBoundTask;
774
775 agxCollide::GeometryHashVector m_disabledCollisionsHash;
776 agxCollide::SpaceRef m_space;
777
778 MaterialUuidBufferListenerRef m_uuidMaterialListenerRef;
779 UpdateRenderingListenerRef m_updateRenderingListenerRef;
780
781 agxData::ValueObserver m_invMassValue;
782 void massChanged( agxData::Value* massValue );
783 agxData::Value::Event::CallbackType m_massChangedCallback;
784 };
785
786 /* Implementation */
787 AGX_FORCE_INLINE Task* ParticleSystem::getUpdateTask() { return m_updateTask; }
788
789 AGX_FORCE_INLINE const agx::Physics::ParticlePtrArray ParticleSystem::getParticles() const
790 {
791 return m_particleStorage->getInstances<Physics::ParticlePtr>();
792 }
793
795 {
796 return m_particleStorage->getInstances<Physics::ParticlePtr>();
797 }
798
799 AGX_FORCE_INLINE agxData::EntityStorage* ParticleSystem::getParticleStorage() { return m_particleStorage; }
800 AGX_FORCE_INLINE const agxData::EntityStorage* ParticleSystem::getParticleStorage() const { return m_particleStorage; }
801 AGX_FORCE_INLINE agxData::EntityStorage* ParticleSystem::getParticleGeometryContactStorage() { return m_particleGeometryContactStorage; }
802 AGX_FORCE_INLINE agxData::EntityStorage* ParticleSystem::getGeometryParticleContactListStorage() { return m_geometryParticleContactListStorage; }
803 AGX_FORCE_INLINE agxData::EntityStorage* ParticleSystem::getParticlePairContactStorage() { return m_particlePairContactStorage; }
804
805 AGX_FORCE_INLINE const agxCollide::GeometryHashVector& ParticleSystem::getDisabledCollisions() const { return m_disabledCollisionsHash; }
806 // AGX_FORCE_INLINE bool ParticleSystem::hasCollisionGroup( agx::UInt32 id ) const { return m_collisionGroups.contains(id); }
807 inline agx::Physics::CollisionGroupSetPtr ParticleSystem::getCollisionGroupSet() const { return m_collisionGroupSet->get<Physics::CollisionGroupSetPtr>(); }
808
809 // Real
810 AGX_FORCE_INLINE void ParticleSystem::addCustomBufferReal( const agx::String& buffername ) { addCustomBufferT<agx::Real>( buffername ); }
811 AGX_FORCE_INLINE void ParticleSystem::setCustomBufferValueReal( agx::Index id, const agx::String& buffername, agx::Real val ) { setCustomBufferValueT<agx::Real>( id, buffername, val ); }
812 AGX_FORCE_INLINE agx::Real ParticleSystem::getCustomBufferValueReal( agx::Index id, const agx::String& buffername ) { return getCustomBufferValueT<agx::Real>( id, buffername ); }
813
814 // Int
815 AGX_FORCE_INLINE void ParticleSystem::addCustomBufferInt( const agx::String& buffername ) { addCustomBufferT<agx::Int>( buffername ); }
816 AGX_FORCE_INLINE void ParticleSystem::setCustomBufferValueInt( agx::Index id, const agx::String& buffername, agx::Int val ) { setCustomBufferValueT<agx::Int>( id, buffername, val ); }
817 AGX_FORCE_INLINE agx::Int ParticleSystem::getCustomBufferValueInt( agx::Index id, const agx::String& buffername ) { return getCustomBufferValueT<agx::Int>( id, buffername ); }
818
819 // Real32
820 AGX_FORCE_INLINE void ParticleSystem::addCustomBufferReal32( const agx::String& buffername ) { addCustomBufferT<agx::Real32>( buffername ); }
821 AGX_FORCE_INLINE void ParticleSystem::setCustomBufferValueReal32( agx::Index id, const agx::String& buffername, agx::Real32 val ) { setCustomBufferValueT<agx::Real32>( id, buffername, val ); }
822 AGX_FORCE_INLINE agx::Real32 ParticleSystem::getCustomBufferValueReal32( agx::Index id, const agx::String& buffername ) { return getCustomBufferValueT<agx::Real32>( id, buffername ); }
823
824 // Vec3
825 AGX_FORCE_INLINE void ParticleSystem::addCustomBufferVec3( const agx::String& buffername ) { addCustomBufferT<agx::Vec3>( buffername ); }
826 AGX_FORCE_INLINE void ParticleSystem::setCustomBufferValueVec3( agx::Index id, const agx::String& buffername, agx::Vec3 val ) { setCustomBufferValueT<agx::Vec3>( id, buffername, val ); }
827 AGX_FORCE_INLINE agx::Vec3 ParticleSystem::getCustomBufferValueVec3( agx::Index id, const agx::String& buffername ) { return getCustomBufferValueT<agx::Vec3>( id, buffername ); }
828}
829
830// AGX_PARTICLESYSTEM_H
831#endif
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
#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:92
This class contains all Geometries and performs Broad Phase and Narrow Phase collision detection to c...
Definition: Space.h:86
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:49
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:131
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:44
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:409
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:378
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...
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.
agx::Vector< agx::Physics::ParticleGeometryContactPtr > getParticleGeometryContacts()
Returns the current ParticleGeometryContacts in 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.
Physics::ParticlePtr getParticle(agx::Index particleId)
Returns a particle from the particle system given a particle id.
agx::Vector< agx::Physics::ParticlePairContactPtr > getParticleParticleContacts()
Returns the current ParticleParticle contacts in the simulation.
size_t getNumActiveParticleGeometryContacts()
Returns the number of ACTIVE particle-geometry contacts, after the last conducted contact filtering.
bool removeParticle(Physics::ParticlePtr particle)
Tag a particle for removal at the end of the time step.
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.
static Model * ClassModel()
agx::Physics::ParticlePtrVector removeParticlesOutsideBound(const agx::Bound3 &bound)
Removes and returns particles in the specified particle system outside the given 3D bound.
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.
Real getParticleRadius() const
void destroyParticles(const Physics::ParticlePtrVector &particles)
Destroy a list of particles.
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.
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.
agx::Real calculateMeanRadius() const
Returns the calculated mean radius of all the particles. Will return 0 if the system contains no part...
virtual void destroySingleParticle(agx::Index particleId)
Destroy particle with specified id.
bool hasCollisionGroupParticle(const agx::Name &id, agx::Physics::ParticlePtr ptr) const
const agx::Bound3 & getParticleBound()
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.
const Material * getMaterial() const
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
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)...
Material * getMaterial()
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:120
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:49
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:57
A class holding 4 dimensional vectors and providing basic arithmetic.
Definition: Vec4Template.h:35
Templated vector class.
Definition: agx/Vector.h:53
Smart pointer for observed objects, that automatically set pointers to them to null when they deleted...
Definition: observer_ptr.h:61
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:89
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:88
#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
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
uint32_t UInt32
Definition: Integer.h:32
double Real
Definition: Real.h:41
float Real32
Definition: Real.h:43
int64_t Int
Definition: Integer.h:28
UInt32 Index
Definition: Integer.h:44