this.m_accumulationBuffer is used in many functions as a temporary buffer for scalar values.
When any particle groups have the flag b2_solidParticleGroup, this.m_depthBuffer is first allocated and populated in ComputeDepth() and used in SolveSolid(). It will be reallocated on subsequent CreateParticle() calls.
Time each particle should be destroyed relative to the last time this.m_timeElapsed was initialized. Each unit of time corresponds to b2ParticleSystemDef::lifetimeGranularity seconds.
Whether the expiration time buffer has been modified and needs to be resorted.
Maps particle indicies to handles.
List of particle indices sorted by expiration time.
When any particles have the flag b2_staticPressureParticle, this.m_staticPressureBuffer is first allocated and used in SolveStaticPressure() and SolvePressure(). It will be reallocated on subsequent CreateParticle() calls.
Stuck particle detection parameters and record keeping
Time elapsed in 32:32 fixed point. Each non-fractional unit of time corresponds to b2ParticleSystemDef::lifetimeGranularity seconds.
this.m_weightBuffer is populated in ComputeWeight and used in ComputeDepth(), SolveStaticPressure() and SolvePressure().
All particle types that apply extra damping force with bodies
All particle types that do not produce dynamic pressure
All particle types that require creating pairs
All particle types that require creating triads
Distribute a force across several particles. The particles must not be wall particles. Note that the force is distributed across all the particles, so calling this function for indices 0..N is not the same as calling ParticleApplyForce(i, force) for i in 0..N.
the first particle to be modified.
the last particle to be modified.
the world force vector, usually in Newtons (N).
Apply an impulse to all particles between 'firstIndex' and 'lastIndex'. This immediately modifies the velocity. Note that the impulse is applied to the total mass of all particles. So, calling ParticleApplyLinearImpulse(0, impulse) and ParticleApplyLinearImpulse(1, impulse) will impart twice as much velocity as calling just ApplyLinearImpulse(0, 1, impulse).
the first particle to be modified.
the last particle to be modified.
the world impulse vector, usually in N-seconds or kg-m/s.
Compute the axis-aligned bounding box for all particles contained within this particle system.
Returns the axis-aligned bounding box of the system.
Compute the kinetic energy that can be lost by damping force
Create a particle whose properties have been defined.
No reference to the definition is retained. A simulation step must occur before it's possible to interact with a newly created particle. For example, DestroyParticleInShape() will not destroy a particle until b2World::Step() has been called. warning: This function is locked during callbacks.
Create a particle group whose properties have been defined.
No reference to the definition is retained. warning: This function is locked during callbacks.
Destroy the Nth oldest particle in the system.
The particle is removed after the next b2World::Step().
Index of the Nth oldest particle to destroy, 0 will destroy the oldest particle in the system, 1 will destroy the next oldest particle etc.
Whether to call the destruction listener just before the particle is destroyed.
Destroy a particle.
The particle is removed after the next simulation step (see b2World::Step()).
Index of the particle to destroy.
Whether to call the destruction listener just before the particle is destroyed.
Destroy particles inside a shape.
warning: This function is locked during callbacks. In addition, this function immediately destroys particles in the shape in constrast to DestroyParticle() which defers the destruction until the next simulation step.
Shape which encloses particles that should be destroyed.
Transform applied to the shape.
Whether to call the world b2DestructionListener for each particle destroyed.
Number of particles destroyed.
Convert a expiration time value in returned by GetExpirationTimeBuffer() to a time in seconds relative to the current simulation time.
Get all existing particle group flags.
Get all existing particle flags.
Get contacts between particles and bodies
Contact data can be used for many reasons, for example to trigger rendering or audio effects.
Get the color of each particle
Array is length GetParticleCount()
the pointer to the head of the particle colors array.
Get contacts between particles Contact data can be used for many reasons, for example to trigger rendering or audio effects.
Get damping for particles
Get the particle density.
Get whether the oldest particle will be destroyed in CreateParticle() when the maximum number of particles are present in the system.
Get the array of particle expiration times indexed by particle index.
GetParticleCount() items are in the returned array.
Get the world's contact filter if any particles with the b2_contactFilterParticle flag are present in the system.
Get the world's contact listener if any particles with the b2_fixtureContactListenerParticle flag are present in the system.
Get the flags for each particle. See the b2ParticleFlag enum.
Array is length GetParticleCount()
the pointer to the head of the particle-flags array.
Get the particle gravity scale.
Get the particle-group of each particle.
Array is length GetParticleCount()
the pointer to the head of the particle group array.
Get the array of particle indices ordered by reverse lifetime. The oldest particle indexes are at the end of the array with the newest at the start. Particles with infinite lifetimes (i.e expiration times less than or equal to 0) are placed at the start of the array. ExpirationTimeToLifetime(GetExpirationTimeBuffer()[index]) is equivalent to GetParticleLifetime(index).
GetParticleCount() items are in the returned array.
Get the maximum number of particles.
Get the next particle-system in the world's particle-system list.
Get array of particle pairs. The particles in a pair: (1) are contacting, (2) are in the same particle group, (3) are part of a rigid particle group, or are spring, elastic, or wall particles. (4) have at least one particle that is a spring or barrier particle (i.e. one of the types in k_pairFlags), (5) have at least one particle that returns true for ConnectionFilter::IsNecessary, (6) are not zombie particles.
Essentially, this is an array of spring or barrier particles that are interacting. The array is sorted by b2ParticlePair's indexA, and then indexB. There are no duplicate entries.
Get the world's contact filter if any particles with the b2_particleContactFilterParticle flag are present in the system.
Get the world's contact listener if any particles with the b2_particleContactListenerParticle flag are present in the system.
Get the number of particles.
Get flags for a particle. See the b2ParticleFlag enum.
Get the number of particle groups.
Get the world particle group list. With the returned group, use b2ParticleGroup::GetNext to get the next group in the world list.
A null group indicates the end of the list.
the head of the world particle group list.
Retrieve a handle to the particle at the specified index.
Please see #b2ParticleHandle for why you might want a handle.
Get the lifetime (in seconds) of a particle relative to the current time. A value > 0.0f is returned if the particle is scheduled to be destroyed in the future, values <= 0.0f indicate the particle has an infinite lifetime.
Initially, true, then, the last value passed into SetPaused().
true if the particle system is being updated in b2World::Step().
Get the position of each particle
Array is length GetParticleCount()
the pointer to the head of the particle positions array.
Get the time elapsed in b2ParticleSystemDef::lifetimeGranularity.
Get the particle radius.
Get the number of iterations for static pressure of particles.
Get the status of the strict contact check.
Get the number of stuck particle candidates from the last step.
Get potentially stuck particles from the last step; the user must decide if they are stuck or not, and if so, delete or move them
Get array of particle triads. The particles in a triad: (1) are in the same particle group, (2) are in a Voronoi triangle together, (3) are within b2_maxTriadDistance particle diameters of each other, (4) return true for ConnectionFilter::ShouldCreateTriad (5) have at least one particle of type elastic (i.e. one of the types in k_triadFlags), (6) are part of a rigid particle group, or are spring, elastic, or wall particles. (7) are not zombie particles.
Essentially, this is an array of elastic particles that are interacting. The array is sorted by b2ParticleTriad's indexA, then indexB, then indexC. There are no duplicate entries.
Get the user-specified data of each particle.
Array is length GetParticleCount()
the pointer to the head of the particle user-data array.
Get the velocity of each particle
Array is length GetParticleCount()
the pointer to the head of the particle velocities array.
Get the weight of each particle
Array is length GetParticleCount()
the pointer to the head of the particle positions array.
Join two particle groups.
warning: This function is locked during callbacks.
the first group. Expands to encompass the second group.
the second group. It is destroyed.
Convert a lifetime in seconds to an expiration time.
Apply a force to the center of a particle.
the particle that will be modified.
the world force vector, usually in Newtons (N).
Apply an impulse to one particle. This immediately modifies the velocity. Similar to b2Body::ApplyLinearImpulse.
the particle that will be modified.
impulse the world impulse vector, usually in N-seconds or kg-m/s.
Query the particle system for all particles that potentially overlap the provided AABB. b2QueryCallback::ShouldQueryParticleSystem is ignored.
a user implemented callback class.
the query box.
Query the particle system for all particles that potentially overlap the provided shape's AABB. Calls QueryAABB internally. b2QueryCallback::ShouldQueryParticleSystem is ignored.
a user implemented callback class.
the query shape
the transform of the AABB
Ray-cast the particle system for all particles in the path of the ray. Your callback controls whether you get the closest point, any point, or n-points. The ray-cast ignores particles that contain the starting point. b2RayCastCallback::ShouldQueryParticleSystem is ignored.
a user implemented callback class.
the ray starting point
the ray ending point
Reallocate a buffer
Reallocate a buffer
Reallocate a buffer
Reallocate the handle / index map and schedule the allocation of a new pool for handle allocation.
Damping is used to reduce the velocity of particles. The damping parameter can be larger than 1.0f but the damping effect becomes sensitive to the time step when the damping parameter is large.
Change the particle density.
Particle density affects the mass of the particles, which in turn affects how the particles interact with b2Bodies. Note that the density does not affect how the particles interact with each other.
Enable / disable destruction of particles in CreateParticle() when no more particles can be created due to a prior call to SetMaxParticleCount(). When this is enabled, the oldest particle is destroyed in CreateParticle() favoring the destruction of particles with a finite lifetime over particles with infinite lifetimes. This feature is enabled by default when particle lifetimes are tracked. Explicitly enabling this feature using this function enables particle lifetime tracking.
Set an external buffer for particle data.
Normally, the b2World's block allocator is used for particle data. However, sometimes you may have an OpenGL or Java buffer for particle data. To avoid data duplication, you may supply this external buffer. Note that, when b2World's block allocator is used, the particle data buffers can grow as required. However, when external buffers are used, the maximum number of particles is clamped to the size of the smallest external buffer.
a pointer to a block of memory.
Change the particle gravity scale. Adjusts the effect of the global gravity vector on particles.
Set the maximum number of particles.
A value of 0 means there is no maximum. The particle buffers can continue to grow while b2World's block allocator still has memory. Note: If you try to CreateParticle() with more than this count, b2_invalidParticleIndex is returned unless SetDestructionByAge() is used to enable the destruction of the oldest particles in the system.
Set flags for a particle. See the b2ParticleFlag enum.
Set the lifetime (in seconds) of a particle relative to the current time. A lifetime of less than or equal to 0.0f results in the particle living forever until it's manually destroyed by the application.
Pause or unpause the particle system. When paused, b2World::Step() skips over this particle system. All b2ParticleSystem function calls still work.
paused is true to pause, false to un-pause.
Change the particle radius.
You should set this only once, on world start. If you change the radius during execution, existing particles may explode, shrink, or behave unexpectedly.
Change the number of iterations when calculating the static pressure of particles. By default, 8 iterations. You can reduce the number of iterations down to 1 in some situations, but this may cause instabilities when many particles come together. If you see particles popping away from each other like popcorn, you may have to increase the number of iterations.
For a description of static pressure, see http://en.wikipedia.org/wiki/Static_pressure#Static_pressure_in_fluid_dynamics
Set strict Particle/Body contact check.
This is an option that will help ensure correct behavior if there are corners in the world model where Particle/Body contact is ambiguous. This option scales at n*log(n) of the number of Particle/Body contacts, so it is best to only enable if it is necessary for your geometry. Enable if you see strange particle behavior around b2Body intersections.
Set an optional threshold for the maximum number of consecutive particle iterations that a particle may contact multiple bodies before it is considered a candidate for being "stuck". Setting to zero or less disables.
Destroy all particles which have outlived their lifetimes set by SetParticleLifetime().
Split particle group into multiple disconnected groups.
warning: This function is locked during callbacks.
the group to be split.
Determine whether a particle index is valid.
Generated using TypeDoc
When any particles have the flag b2_tensileParticle, this.m_accumulation2Buffer is first allocated and used in SolveTensile() as a temporary buffer for vector values. It will be reallocated on subsequent CreateParticle() calls.