pub struct b2ParticleSystem { /* private fields */ }Implementations§
Source§impl b2ParticleSystem
impl b2ParticleSystem
Sourcepub fn SetDensity(self: Pin<&mut b2ParticleSystem>, density: f32)
pub fn SetDensity(self: Pin<&mut b2ParticleSystem>, density: f32)
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.
Sourcepub fn GetDensity(self: &b2ParticleSystem) -> f32
pub fn GetDensity(self: &b2ParticleSystem) -> f32
Get the particle density.
Sourcepub fn SetGravityScale(self: Pin<&mut b2ParticleSystem>, gravityScale: f32)
pub fn SetGravityScale(self: Pin<&mut b2ParticleSystem>, gravityScale: f32)
Change the particle gravity scale. Adjusts the effect of the global gravity vector on particles.
Sourcepub fn GetGravityScale(self: &b2ParticleSystem) -> f32
pub fn GetGravityScale(self: &b2ParticleSystem) -> f32
Get the particle gravity scale.
Sourcepub fn ApplyLinearImpulse(
self: Pin<&mut b2ParticleSystem>,
firstIndex: c_int,
lastIndex: c_int,
impulse: &b2Vec2,
)
pub fn ApplyLinearImpulse( self: Pin<&mut b2ParticleSystem>, firstIndex: c_int, lastIndex: c_int, impulse: &b2Vec2, )
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). @param firstIndex the first particle to be modified. @param lastIndex the last particle to be modified. @param impulse the world impulse vector, usually in N-seconds or kg-m/s.
Sourcepub fn ApplyForce(
self: Pin<&mut b2ParticleSystem>,
firstIndex: c_int,
lastIndex: c_int,
force: &b2Vec2,
)
pub fn ApplyForce( self: Pin<&mut b2ParticleSystem>, firstIndex: c_int, lastIndex: c_int, force: &b2Vec2, )
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. @param firstIndex the first particle to be modified. @param lastIndex the last particle to be modified. @param force the world force vector, usually in Newtons (N).
Sourcepub fn GetNext(self: Pin<&mut b2ParticleSystem>) -> *mut b2ParticleSystem
pub fn GetNext(self: Pin<&mut b2ParticleSystem>) -> *mut b2ParticleSystem
Get the next particle-system in the world’s particle-system list.
pub fn GetNext1(self: &b2ParticleSystem) -> *const b2ParticleSystem
Sourcepub unsafe fn RayCast(
self: &b2ParticleSystem,
callback: *mut b2RayCastCallback,
point1: &b2Vec2,
point2: &b2Vec2,
)
pub unsafe fn RayCast( self: &b2ParticleSystem, callback: *mut b2RayCastCallback, point1: &b2Vec2, point2: &b2Vec2, )
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. @param callback a user implemented callback class. @param point1 the ray starting point @param point2 the ray ending point
Sourcepub unsafe fn ComputeAABB(self: &b2ParticleSystem, aabb: *mut b2AABB)
pub unsafe fn ComputeAABB(self: &b2ParticleSystem, aabb: *mut b2AABB)
Compute the axis-aligned bounding box for all particles contained within this particle system. @param aabb Returns the axis-aligned bounding box of the system.
Source§impl b2ParticleSystem
impl b2ParticleSystem
Sourcepub fn CreateParticle(self: Pin<&mut Self>, def: &b2ParticleDef) -> c_int
pub fn CreateParticle(self: Pin<&mut Self>, def: &b2ParticleDef) -> c_int
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. @return the index of the particle.
Sourcepub fn GetParticleHandleFromIndex(
self: Pin<&mut Self>,
index: c_int,
) -> *const b2ParticleHandle
pub fn GetParticleHandleFromIndex( self: Pin<&mut Self>, index: c_int, ) -> *const b2ParticleHandle
Retrieve a handle to the particle at the specified index. Please see #b2ParticleHandle for why you might want a handle.
Sourcepub fn DestroyParticle(self: Pin<&mut Self>, index: c_int)
pub fn DestroyParticle(self: Pin<&mut Self>, index: c_int)
Destroy a particle. The particle is removed after the next simulation step (see b2World::Step()).
Sourcepub fn DestroyParticle1(
self: Pin<&mut Self>,
index: c_int,
callDestructionListener: bool,
)
pub fn DestroyParticle1( self: Pin<&mut Self>, index: c_int, callDestructionListener: bool, )
Destroy a particle. The particle is removed after the next step. @param Index of the particle to destroy. @param Whether to call the destruction listener just before the particle is destroyed.
Sourcepub fn DestroyOldestParticle(
self: Pin<&mut Self>,
index: c_int,
callDestructionListener: bool,
)
pub fn DestroyOldestParticle( self: Pin<&mut Self>, index: c_int, callDestructionListener: bool, )
Destroy the Nth oldest particle in the system. The particle is removed after the next b2World::Step(). @param 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. @param Whether to call the destruction listener just before the particle is destroyed.
Sourcepub fn DestroyParticlesInShape(
self: Pin<&mut Self>,
shape: &b2Shape,
xf: &b2Transform,
) -> c_int
pub fn DestroyParticlesInShape( self: Pin<&mut Self>, shape: &b2Shape, xf: &b2Transform, ) -> c_int
Destroy particles inside a shape without enabling the destruction callback for destroyed particles. This function is locked during callbacks. For more information see DestroyParticleInShape(const b2Shape&, const b2Transform&,bool). @param Shape which encloses particles that should be destroyed. @param Transform applied to the shape. @warning This function is locked during callbacks. @return Number of particles destroyed.
Sourcepub fn DestroyParticlesInShape1(
self: Pin<&mut Self>,
shape: &b2Shape,
xf: &b2Transform,
callDestructionListener: bool,
) -> c_int
pub fn DestroyParticlesInShape1( self: Pin<&mut Self>, shape: &b2Shape, xf: &b2Transform, callDestructionListener: bool, ) -> c_int
Destroy particles inside a shape. 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. @param Shape which encloses particles that should be destroyed. @param Transform applied to the shape. @param Whether to call the world b2DestructionListener for each particle destroyed. @warning This function is locked during callbacks. @return Number of particles destroyed.
Sourcepub fn CreateParticleGroup(
self: Pin<&mut Self>,
def: &b2ParticleGroupDef,
) -> *mut b2ParticleGroup
pub fn CreateParticleGroup( self: Pin<&mut Self>, def: &b2ParticleGroupDef, ) -> *mut b2ParticleGroup
Create a particle group whose properties have been defined. No reference to the definition is retained. @warning This function is locked during callbacks.
Sourcepub unsafe fn JoinParticleGroups(
self: Pin<&mut Self>,
groupA: *mut b2ParticleGroup,
groupB: *mut b2ParticleGroup,
)
pub unsafe fn JoinParticleGroups( self: Pin<&mut Self>, groupA: *mut b2ParticleGroup, groupB: *mut b2ParticleGroup, )
Join two particle groups. @param the first group. Expands to encompass the second group. @param the second group. It is destroyed. @warning This function is locked during callbacks.
Sourcepub unsafe fn SplitParticleGroup(
self: Pin<&mut Self>,
group: *mut b2ParticleGroup,
)
pub unsafe fn SplitParticleGroup( self: Pin<&mut Self>, group: *mut b2ParticleGroup, )
Split particle group into multiple disconnected groups. @param the group to be split. @warning This function is locked during callbacks.
Sourcepub fn GetParticleGroupList(self: Pin<&mut Self>) -> *mut b2ParticleGroup
pub fn GetParticleGroupList(self: Pin<&mut Self>) -> *mut b2ParticleGroup
Get the world particle group list. With the returned group, use b2ParticleGroup::GetNext to get the next group in the world list. A nullptr group indicates the end of the list. @return the head of the world particle group list.
pub fn GetParticleGroupList1(&self) -> *const b2ParticleGroup
Sourcepub fn GetParticleGroupCount(&self) -> c_int
pub fn GetParticleGroupCount(&self) -> c_int
Get the number of particle groups.
Sourcepub fn GetParticleCount(&self) -> c_int
pub fn GetParticleCount(&self) -> c_int
Get the number of particles.
Sourcepub fn GetMaxParticleCount(&self) -> c_int
pub fn GetMaxParticleCount(&self) -> c_int
Get the maximum number of particles.
Sourcepub fn SetMaxParticleCount(self: Pin<&mut Self>, count: c_int)
pub fn SetMaxParticleCount(self: Pin<&mut Self>, count: c_int)
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.
Sourcepub fn GetAllParticleFlags(&self) -> c_uint
pub fn GetAllParticleFlags(&self) -> c_uint
Get all existing particle flags.
Sourcepub fn GetAllGroupFlags(&self) -> c_uint
pub fn GetAllGroupFlags(&self) -> c_uint
Get all existing particle group flags.
Sourcepub fn SetPaused(self: Pin<&mut Self>, paused: bool)
pub fn SetPaused(self: Pin<&mut Self>, paused: bool)
Pause or unpause the particle system. When paused, b2World::Step() skips over this particle system. All b2ParticleSystem function calls still work. @param paused is true to pause, false to un-pause.
Sourcepub fn GetPaused(&self) -> bool
pub fn GetPaused(&self) -> bool
@return true if the particle system is being updated in b2World::Step(). Initially, true, then, the last value passed into SetPaused().
Sourcepub fn SetDamping(self: Pin<&mut Self>, damping: f32)
pub fn SetDamping(self: Pin<&mut Self>, damping: f32)
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.
Sourcepub fn GetDamping(&self) -> f32
pub fn GetDamping(&self) -> f32
Get damping for particles
Sourcepub fn SetStaticPressureIterations(self: Pin<&mut Self>, iterations: c_int)
pub fn SetStaticPressureIterations(self: Pin<&mut Self>, iterations: c_int)
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
Sourcepub fn GetStaticPressureIterations(&self) -> c_int
pub fn GetStaticPressureIterations(&self) -> c_int
Get the number of iterations for static pressure of particles.
Sourcepub fn SetRadius(self: Pin<&mut Self>, radius: f32)
pub fn SetRadius(self: Pin<&mut Self>, radius: f32)
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.
Sourcepub fn GetPositionBuffer(self: Pin<&mut Self>) -> *mut b2Vec2
pub fn GetPositionBuffer(self: Pin<&mut Self>) -> *mut b2Vec2
Get the position of each particle Array is length GetParticleCount() @return the pointer to the head of the particle positions array.
pub fn GetPositionBuffer1(&self) -> *const b2Vec2
Sourcepub fn GetVelocityBuffer(self: Pin<&mut Self>) -> *mut b2Vec2
pub fn GetVelocityBuffer(self: Pin<&mut Self>) -> *mut b2Vec2
Get the velocity of each particle Array is length GetParticleCount() @return the pointer to the head of the particle velocities array.
pub fn GetVelocityBuffer1(&self) -> *const b2Vec2
Sourcepub fn GetColorBuffer(self: Pin<&mut Self>) -> *mut b2ParticleColor
pub fn GetColorBuffer(self: Pin<&mut Self>) -> *mut b2ParticleColor
Get the color of each particle Array is length GetParticleCount() @return the pointer to the head of the particle colors array.
pub fn GetColorBuffer1(&self) -> *const b2ParticleColor
Sourcepub fn GetWeightBuffer(self: Pin<&mut Self>) -> *mut f32
pub fn GetWeightBuffer(self: Pin<&mut Self>) -> *mut f32
Get the weight of each particle Array is length GetParticleCount() @return the pointer to the head of the particle positions array.
pub fn GetWeightBuffer1(&self) -> *const f32
Sourcepub fn GetFlagsBuffer(&self) -> *const c_uint
pub fn GetFlagsBuffer(&self) -> *const c_uint
Get the flags for each particle. See the b2ParticleFlag enum. Array is length GetParticleCount() @return the pointer to the head of the particle-flags array.
Sourcepub fn SetParticleFlags(self: Pin<&mut Self>, index: c_int, flags: c_uint)
pub fn SetParticleFlags(self: Pin<&mut Self>, index: c_int, flags: c_uint)
Set flags for a particle. See the b2ParticleFlag enum.
Sourcepub fn GetParticleFlags(self: Pin<&mut Self>, index: c_int) -> c_uint
pub fn GetParticleFlags(self: Pin<&mut Self>, index: c_int) -> c_uint
Get flags for a particle. See the b2ParticleFlag enum.
Sourcepub unsafe fn SetFlagsBuffer(
self: Pin<&mut Self>,
buffer: *mut c_uint,
capacity: c_int,
)
pub unsafe fn SetFlagsBuffer( self: Pin<&mut Self>, buffer: *mut c_uint, capacity: c_int, )
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.
@param buffer is a pointer to a block of memory. @param size is the number of values in the block.
pub unsafe fn SetPositionBuffer( self: Pin<&mut Self>, buffer: *mut b2Vec2, capacity: c_int, )
pub unsafe fn SetVelocityBuffer( self: Pin<&mut Self>, buffer: *mut b2Vec2, capacity: c_int, )
pub unsafe fn SetColorBuffer( self: Pin<&mut Self>, buffer: *mut b2ParticleColor, capacity: c_int, )
Sourcepub fn GetContacts(&self) -> *const b2ParticleContact
pub fn GetContacts(&self) -> *const b2ParticleContact
Get contacts between particles Contact data can be used for many reasons, for example to trigger rendering or audio effects.
pub fn GetContactCount(&self) -> c_int
Sourcepub fn GetBodyContacts(&self) -> *const b2ParticleBodyContact
pub fn GetBodyContacts(&self) -> *const b2ParticleBodyContact
Get contacts between particles and bodies Contact data can be used for many reasons, for example to trigger rendering or audio effects.
pub fn GetBodyContactCount(&self) -> c_int
Sourcepub fn GetPairs(&self) -> *const b2ParticlePair
pub fn GetPairs(&self) -> *const b2ParticlePair
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.
pub fn GetPairCount(&self) -> c_int
Sourcepub fn GetTriads(&self) -> *const b2ParticleTriad
pub fn GetTriads(&self) -> *const b2ParticleTriad
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.
pub fn GetTriadCount(&self) -> c_int
Sourcepub fn SetStuckThreshold(self: Pin<&mut Self>, iterations: c_int)
pub fn SetStuckThreshold(self: Pin<&mut Self>, iterations: c_int)
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.
Sourcepub fn GetStuckCandidates(&self) -> *const c_int
pub fn GetStuckCandidates(&self) -> *const c_int
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
Sourcepub fn GetStuckCandidateCount(&self) -> c_int
pub fn GetStuckCandidateCount(&self) -> c_int
Get the number of stuck particle candidates from the last step.
Sourcepub fn ComputeCollisionEnergy(&self) -> f32
pub fn ComputeCollisionEnergy(&self) -> f32
Compute the kinetic energy that can be lost by damping force
Sourcepub fn SetStrictContactCheck(self: Pin<&mut Self>, enabled: bool)
pub fn SetStrictContactCheck(self: Pin<&mut Self>, enabled: bool)
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.
Sourcepub fn GetStrictContactCheck(&self) -> bool
pub fn GetStrictContactCheck(&self) -> bool
Get the status of the strict contact check.
Sourcepub fn SetParticleLifetime(self: Pin<&mut Self>, index: c_int, lifetime: f32)
pub fn SetParticleLifetime(self: Pin<&mut Self>, index: c_int, lifetime: f32)
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.
Sourcepub fn GetParticleLifetime(self: Pin<&mut Self>, index: c_int) -> f32
pub fn GetParticleLifetime(self: Pin<&mut Self>, index: c_int) -> f32
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.
Sourcepub fn SetDestructionByAge(self: Pin<&mut Self>, enable: bool)
pub fn SetDestructionByAge(self: Pin<&mut Self>, enable: bool)
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.
Sourcepub fn GetDestructionByAge(&self) -> bool
pub fn GetDestructionByAge(&self) -> bool
Get whether the oldest particle will be destroyed in CreateParticle() when the maximum number of particles are present in the system.
Sourcepub fn GetExpirationTimeBuffer(self: Pin<&mut Self>) -> *const c_int
pub fn GetExpirationTimeBuffer(self: Pin<&mut Self>) -> *const c_int
Get the array of particle expiration times indexed by particle index. GetParticleCount() items are in the returned array.
Sourcepub fn ExpirationTimeToLifetime(&self, expirationTime: c_int) -> f32
pub fn ExpirationTimeToLifetime(&self, expirationTime: c_int) -> f32
Convert a expiration time value in returned by GetExpirationTimeBuffer() to a time in seconds relative to the current simulation time.
Sourcepub fn GetIndexByExpirationTimeBuffer(self: Pin<&mut Self>) -> *const c_int
pub fn GetIndexByExpirationTimeBuffer(self: Pin<&mut Self>) -> *const c_int
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.
Sourcepub fn ParticleApplyLinearImpulse(
self: Pin<&mut Self>,
index: c_int,
impulse: &b2Vec2,
)
pub fn ParticleApplyLinearImpulse( self: Pin<&mut Self>, index: c_int, impulse: &b2Vec2, )
Apply an impulse to one particle. This immediately modifies the velocity. Similar to b2Body::ApplyLinearImpulse. @param index the particle that will be modified. @param impulse the world impulse vector, usually in N-seconds or kg-m/s.
Sourcepub fn ParticleApplyForce(self: Pin<&mut Self>, index: c_int, force: &b2Vec2)
pub fn ParticleApplyForce(self: Pin<&mut Self>, index: c_int, force: &b2Vec2)
Apply a force to the center of a particle. @param index the particle that will be modified. @param force the world force vector, usually in Newtons (N).
Sourcepub unsafe fn QueryAABB(&self, callback: *mut b2QueryCallback, aabb: &b2AABB)
pub unsafe fn QueryAABB(&self, callback: *mut b2QueryCallback, aabb: &b2AABB)
Query the particle system for all particles that potentially overlap the provided AABB. b2QueryCallback::ShouldQueryParticleSystem is ignored. @param callback a user implemented callback class. @param aabb the query box.
Sourcepub unsafe fn QueryShapeAABB(
&self,
callback: *mut b2QueryCallback,
shape: &b2Shape,
xf: &b2Transform,
)
pub unsafe fn QueryShapeAABB( &self, callback: *mut b2QueryCallback, shape: &b2Shape, xf: &b2Transform, )
Query the particle system for all particles that potentially overlap the provided shape’s AABB. Calls QueryAABB internally. b2QueryCallback::ShouldQueryParticleSystem is ignored. @param callback a user implemented callback class. @param shape the query shape @param xf the transform of the AABB