AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
ParticleSystem.h
Go to the documentation of this file.
1/*
2Copyright 2007-2024. 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
161 agx::Physics::ParticlePtrVector spawnParticlesInBound( const agx::Bound3& bound, Real radius, const agx::Vec3& spacing, agx::Real jitterFactor = agx::Real( 0 ) );
162
172
181 agx::Physics::ParticlePtrVector spawnParticlesInBoundHCP( const agx::Bound3& bound, Real radius, const agx::Vec3& spacing, agx::Real jitterFactor = agx::Real( 0 ) );
182
192
201
210
220
230
237
241 size_t getNumParticles() const;
242
247
252
261 void setParticleRadius( Real radius, bool updateExistingParticles = false );
262
271 virtual void setParticleMass( Real mass, bool updateExistingParticles = false );
272
281 void setMaterial( Material* material, bool updateExistingParticles = false );
282
290
295 const Material* getMaterial() const;
296
301
305 agxData::EntityStorage* getParticleStorage();
306
310 const agxData::EntityStorage* getParticleStorage() const;
311
315 agxData::EntityStorage* getParticlePairContactStorage();
316
320 agxData::EntityStorage* getGeometryParticleContactListStorage();
321
325 agxData::EntityStorage* getParticleGeometryContactStorage();
326
331
336
341
346
351
356
362
363 // Returns the total contact forces between the particles in the system
365
366 // Returns the total particle-geometry contact forces in the system.
368
369 // Calculates the total particle volume in the particle system
371
374
376
380 void setEnableCollisions( const agxCollide::Geometry* geometry, bool flag );
381
385 bool getEnableCollisions( const agxCollide::Geometry* geometry ) const;
386
390 const agxCollide::GeometryHashVector& getDisabledCollisions() const;
391
392
401 // bool canCollide( const agxCollide::Geometry* geometry ) const;
402
411 void addCollisionGroup( agx::UInt32 id, bool updateExistingParticles = true );
412 void addCollisionGroup( const agx::Name& id, bool updateExistingParticles = true );
413
418 void removeCollisionGroup( agx::UInt32 id, bool updateExistingParticles = true );
419 void removeCollisionGroup( const agx::Name& id, bool updateExistingParticles = true );
420
431
438
447
455 bool hasCollisionGroup( const agx::Name& id ) const;
456
460 agx::Physics::CollisionGroupSetPtr getCollisionGroupSet() const;
461
463
467 bool hasCustomBuffer( const agx::String& buffername, const agx::String& formatName );
468
474 void addCustomBufferReal( const agx::String& buffername );
475
482 void setCustomBufferValueReal( agx::Index id, const agx::String& buffername, agx::Real val );
483
490 agx::Real getCustomBufferValueReal( agx::Index id, const agx::String& buffername );
491
497 void addCustomBufferInt( const agx::String& buffername );
498
505 void setCustomBufferValueInt( agx::Index id, const agx::String& buffername, agx::Int val );
506
513 agx::Int getCustomBufferValueInt( agx::Index id, const agx::String& buffername );
514
520 void addCustomBufferReal32( const agx::String& buffername );
521
528 void setCustomBufferValueReal32( agx::Index id, const agx::String& buffername, agx::Real32 val );
529
536 agx::Real32 getCustomBufferValueReal32( agx::Index id, const agx::String& buffername );
537
543 void addCustomBufferVec3( const agx::String& buffername );
544
551 void setCustomBufferValueVec3( agx::Index id, const agx::String& buffername, agx::Vec3 val );
552
559 agx::Vec3 getCustomBufferValueVec3( agx::Index id, const agx::String& buffername );
560
563
565 virtual void destroySingleParticle( agx::Index particleId );
566
568 virtual void setSingleParticleRadius( agx::Index particleId, agx::Real radius );
569
572
574 virtual void setSingleParticleMass( agx::Index particleId, agx::Real mass );
575
578
580 virtual void setSingleParticleColor( agx::Index particleId, const agx::Vec4f& color );
581
584
586 virtual void setSingleParticleVelocity( agx::Index particleId, const agx::Vec3& velocity );
587
590
593
595 virtual void setSingleParticleForce( agx::Index particleId, const agx::Vec3& force );
596
599
602
605
613
618
624
629
635
639 void attach();
640
645 void detach();
646
647 // private
648 void _setGravityTask( Task* task );
651
653
654 agx::Vector<agx::Physics::ParticlePtr> createParticlesFromImage( agxIO::Image* image, agx::Real particleRadius, const agx::Vec3& center, agx::Real radiusJitter );
655
657 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 ) );
658 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 ) );
659 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 ) );
660 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 ) );
661
662 template<typename T>
663 void addCustomBufferT( const agx::String& name );
664
665 template<typename T>
666 void setCustomBufferValueT( agx::Index id, const agx::String& buffername, const T valueT );
667
668 template<typename T>
669 T getCustomBufferValueT( agx::Index id, const agx::String& buffername );
670
671 agxSDK::Simulation* getSimulation() const;
672
673 agx::Physics::ParticlePtrVector convertRangeToParticlePtrVector( agxData::EntityRange& entityRange );
674
676
678
679 protected:
680 ParticleSystem( const String& model, Device* device = CpuDevice::instance() );
681 ParticleSystem(); // Only used for restoring from serialization
682
683 virtual ~ParticleSystem();
684
685 void init( bool createMaterial = true );
686 void setCollisionGroupSet( agx::Physics::CollisionGroupSetPtr );
687 void invalidLicenseCallback();
688 TaskGroupRef m_updateTask;
689 void setRadiusOnParticles( agxData::EntityRange& entityRange, agx::Real radius );
690
691 protected:
699 class AGXPHYSICS_EXPORT MaterialUuidBufferListener : public agxData::Buffer::EventListener, public agx::Referenced
700 {
701 public:
705 virtual void updateCallback( agxData::Buffer* buffer ) override;
706 virtual void updateCallback( agxData::Buffer* buffer, agx::Index index ) override;
707 virtual void updateCallback( agxData::Buffer* buffer, agx::IndexRange range ) override;
708 virtual void updateCallback( agxData::Buffer* buffer, agxData::Array< agx::Index > indexSet ) override;
709
710 protected:
713 // Variables
715 private:
717 agxSDK::Simulation* m_simulation;
718 };
719
726 class AGXPHYSICS_EXPORT UpdateRenderingListener : public agxData::Buffer::EventListener, public agx::Referenced
727 {
728 public:
732 virtual void updateCallback( agxData::Buffer* buffer ) override;
733 virtual void updateCallback( agxData::Buffer* buffer, agx::Index index ) override;
734 virtual void updateCallback( agxData::Buffer* buffer, agx::IndexRange range ) override;
735 virtual void updateCallback( agxData::Buffer* buffer, agxData::Array< agx::Index > indexSet ) override;
736
737 protected:
740 // Variables
742 private:
744 agxSDK::Simulation* m_simulation;
745 };
746
747 protected:
749 private:
750 agxData::EntityStorageRef m_particleCellStorage;
751 agxData::EntityStorageRef m_cellBlockStorage;
752 agxData::EntityStorageRef m_particleZoneStorage;
753 agxData::EntityStorageRef m_collisionParticleStorage;
754 agxData::EntityStorageRef m_particleGeometryContactStorage;
755 agxData::EntityStorageRef m_particlePairContactStorage;
756 agxData::EntityStorageRef m_geometryParticleContactListStorage;
757
758 agxData::BufferRef m_materialUuidBuffer;
759 agxData::BufferRef m_stateBuffer;
760 agxData::BufferRef m_cellBlockPermutation;
761 agxData::BufferRef m_deadCellBlocks;
762 agxData::BufferRef m_particlesWithMissingTargetCell;
763 agxData::BufferRef m_cellBlockOverlapPairs;
764 agxData::ValueRef m_particleBound;
765 agxData::ValueRef m_collisionGroupSet;
766 agxData::ValueRef m_defaultRadius;
767 agxData::ValueRef m_defaultMass;
768 agxData::ValueRef m_defaultMaterial;
769
770 MaterialRef m_material;
771 TaskRef m_gravityTask;
772 bool m_initialized;
773 bool m_dirtyBound;
774
775 agx::TaskRef m_updateBoundTask;
776
777 agxCollide::GeometryHashVector m_disabledCollisionsHash;
778 agxCollide::SpaceRef m_space;
779
780 MaterialUuidBufferListenerRef m_uuidMaterialListenerRef;
781 UpdateRenderingListenerRef m_updateRenderingListenerRef;
782
783 agxData::ValueObserver m_invMassValue;
784 void massChanged( agxData::Value* massValue );
785 agxData::Value::Event::CallbackType m_massChangedCallback;
786 };
787
788 /* Implementation */
789 AGX_FORCE_INLINE Task* ParticleSystem::getUpdateTask() { return m_updateTask; }
790
791 AGX_FORCE_INLINE const agx::Physics::ParticlePtrArray ParticleSystem::getParticles() const
792 {
793 return m_particleStorage->getInstances<Physics::ParticlePtr>();
794 }
795
797 {
798 return m_particleStorage->getInstances<Physics::ParticlePtr>();
799 }
800
801 AGX_FORCE_INLINE agxData::EntityStorage* ParticleSystem::getParticleStorage() { return m_particleStorage; }
802 AGX_FORCE_INLINE const agxData::EntityStorage* ParticleSystem::getParticleStorage() const { return m_particleStorage; }
803 AGX_FORCE_INLINE agxData::EntityStorage* ParticleSystem::getParticleGeometryContactStorage() { return m_particleGeometryContactStorage; }
804 AGX_FORCE_INLINE agxData::EntityStorage* ParticleSystem::getGeometryParticleContactListStorage() { return m_geometryParticleContactListStorage; }
805 AGX_FORCE_INLINE agxData::EntityStorage* ParticleSystem::getParticlePairContactStorage() { return m_particlePairContactStorage; }
806
807 AGX_FORCE_INLINE const agxCollide::GeometryHashVector& ParticleSystem::getDisabledCollisions() const { return m_disabledCollisionsHash; }
808 // AGX_FORCE_INLINE bool ParticleSystem::hasCollisionGroup( agx::UInt32 id ) const { return m_collisionGroups.contains(id); }
809 inline agx::Physics::CollisionGroupSetPtr ParticleSystem::getCollisionGroupSet() const { return m_collisionGroupSet->get<Physics::CollisionGroupSetPtr>(); }
810
811 // Real
812 AGX_FORCE_INLINE void ParticleSystem::addCustomBufferReal( const agx::String& buffername ) { addCustomBufferT<agx::Real>( buffername ); }
813 AGX_FORCE_INLINE void ParticleSystem::setCustomBufferValueReal( agx::Index id, const agx::String& buffername, agx::Real val ) { setCustomBufferValueT<agx::Real>( id, buffername, val ); }
814 AGX_FORCE_INLINE agx::Real ParticleSystem::getCustomBufferValueReal( agx::Index id, const agx::String& buffername ) { return getCustomBufferValueT<agx::Real>( id, buffername ); }
815
816 // Int
817 AGX_FORCE_INLINE void ParticleSystem::addCustomBufferInt( const agx::String& buffername ) { addCustomBufferT<agx::Int>( buffername ); }
818 AGX_FORCE_INLINE void ParticleSystem::setCustomBufferValueInt( agx::Index id, const agx::String& buffername, agx::Int val ) { setCustomBufferValueT<agx::Int>( id, buffername, val ); }
819 AGX_FORCE_INLINE agx::Int ParticleSystem::getCustomBufferValueInt( agx::Index id, const agx::String& buffername ) { return getCustomBufferValueT<agx::Int>( id, buffername ); }
820
821 // Real32
822 AGX_FORCE_INLINE void ParticleSystem::addCustomBufferReal32( const agx::String& buffername ) { addCustomBufferT<agx::Real32>( buffername ); }
823 AGX_FORCE_INLINE void ParticleSystem::setCustomBufferValueReal32( agx::Index id, const agx::String& buffername, agx::Real32 val ) { setCustomBufferValueT<agx::Real32>( id, buffername, val ); }
824 AGX_FORCE_INLINE agx::Real32 ParticleSystem::getCustomBufferValueReal32( agx::Index id, const agx::String& buffername ) { return getCustomBufferValueT<agx::Real32>( id, buffername ); }
825
826 // Vec3
827 AGX_FORCE_INLINE void ParticleSystem::addCustomBufferVec3( const agx::String& buffername ) { addCustomBufferT<agx::Vec3>( buffername ); }
828 AGX_FORCE_INLINE void ParticleSystem::setCustomBufferValueVec3( agx::Index id, const agx::String& buffername, agx::Vec3 val ) { setCustomBufferValueT<agx::Vec3>( id, buffername, val ); }
829 AGX_FORCE_INLINE agx::Vec3 ParticleSystem::getCustomBufferValueVec3( agx::Index id, const agx::String& buffername ) { return getCustomBufferValueT<agx::Vec3>( id, buffername ); }
830}
831
832// AGX_PARTICLESYSTEM_H
833#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...
#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:82
Abstract representation of a data buffer.
Definition Buffer.h:56
Data storage for a collection of entity instances of a specified EntityModel.
Only use as member allocated variable.
Definition Value.h:285
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:126
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
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:388
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:376
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.
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:52
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)
A representation of a generic task.
Definition Task.h:58
A class holding 4 dimensional vectors and providing basic arithmetic.
Templated vector class.
Definition agx/Vector.h:53
Smart pointer for observed objects, that automatically set pointers to them to null when they deleted...
#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
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:42
float Real32
Definition Real.h:44
int64_t Int
Definition Integer.h:28
UInt32 Index
Definition Integer.h:44