Struct libliquidfun_sys::box2d::ffi::b2ParticleSystem
source · #[repr(C, align(8))]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.
source§impl b2ParticleSystem
impl b2ParticleSystem
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.
source§impl b2ParticleSystem
impl b2ParticleSystem
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()).
source§impl b2ParticleSystem
impl b2ParticleSystem
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.
source§impl b2ParticleSystem
impl b2ParticleSystem
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.
source§impl b2ParticleSystem
impl b2ParticleSystem
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.
source§impl b2ParticleSystem
impl b2ParticleSystem
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.
source§impl b2ParticleSystem
impl b2ParticleSystem
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.
source§impl b2ParticleSystem
impl b2ParticleSystem
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.
source§impl b2ParticleSystem
impl b2ParticleSystem
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.
source§impl b2ParticleSystem
impl b2ParticleSystem
pub fn GetParticleGroupList1(&self) -> *const b2ParticleGroup
source§impl b2ParticleSystem
impl b2ParticleSystem
sourcepub fn GetParticleGroupCount(&self) -> c_int
pub fn GetParticleGroupCount(&self) -> c_int
Get the number of particle groups.
source§impl b2ParticleSystem
impl b2ParticleSystem
sourcepub fn GetParticleCount(&self) -> c_int
pub fn GetParticleCount(&self) -> c_int
Get the number of particles.
source§impl b2ParticleSystem
impl b2ParticleSystem
sourcepub fn GetMaxParticleCount(&self) -> c_int
pub fn GetMaxParticleCount(&self) -> c_int
Get the maximum number of particles.
source§impl b2ParticleSystem
impl b2ParticleSystem
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.
source§impl b2ParticleSystem
impl b2ParticleSystem
sourcepub fn GetAllParticleFlags(&self) -> c_uint
pub fn GetAllParticleFlags(&self) -> c_uint
Get all existing particle flags.
source§impl b2ParticleSystem
impl b2ParticleSystem
sourcepub fn GetAllGroupFlags(&self) -> c_uint
pub fn GetAllGroupFlags(&self) -> c_uint
Get all existing particle group flags.
source§impl b2ParticleSystem
impl b2ParticleSystem
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.
source§impl b2ParticleSystem
impl b2ParticleSystem
sourcepub fn GetDamping(&self) -> f32
pub fn GetDamping(&self) -> f32
Get damping for particles
source§impl b2ParticleSystem
impl b2ParticleSystem
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
source§impl b2ParticleSystem
impl b2ParticleSystem
sourcepub fn GetStaticPressureIterations(&self) -> c_int
pub fn GetStaticPressureIterations(&self) -> c_int
Get the number of iterations for static pressure of particles.
source§impl b2ParticleSystem
impl b2ParticleSystem
pub fn GetPositionBuffer1(&self) -> *const b2Vec2
source§impl b2ParticleSystem
impl b2ParticleSystem
pub fn GetVelocityBuffer1(&self) -> *const b2Vec2
source§impl b2ParticleSystem
impl b2ParticleSystem
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.
source§impl b2ParticleSystem
impl b2ParticleSystem
pub fn GetColorBuffer1(&self) -> *const b2ParticleColor
source§impl b2ParticleSystem
impl b2ParticleSystem
pub fn GetWeightBuffer1(&self) -> *const f32
source§impl b2ParticleSystem
impl b2ParticleSystem
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.
source§impl b2ParticleSystem
impl b2ParticleSystem
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.
source§impl b2ParticleSystem
impl b2ParticleSystem
pub unsafe fn SetColorBuffer( self: Pin<&mut Self>, buffer: *mut b2ParticleColor, capacity: c_int )
source§impl b2ParticleSystem
impl b2ParticleSystem
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.
source§impl b2ParticleSystem
impl b2ParticleSystem
pub fn GetContactCount(&self) -> c_int
source§impl b2ParticleSystem
impl b2ParticleSystem
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.
source§impl b2ParticleSystem
impl b2ParticleSystem
pub fn GetBodyContactCount(&self) -> c_int
source§impl b2ParticleSystem
impl b2ParticleSystem
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.
source§impl b2ParticleSystem
impl b2ParticleSystem
pub fn GetPairCount(&self) -> c_int
source§impl b2ParticleSystem
impl b2ParticleSystem
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.
source§impl b2ParticleSystem
impl b2ParticleSystem
pub fn GetTriadCount(&self) -> c_int
source§impl b2ParticleSystem
impl b2ParticleSystem
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.
source§impl b2ParticleSystem
impl b2ParticleSystem
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
source§impl b2ParticleSystem
impl b2ParticleSystem
sourcepub fn GetStuckCandidateCount(&self) -> c_int
pub fn GetStuckCandidateCount(&self) -> c_int
Get the number of stuck particle candidates from the last step.
source§impl b2ParticleSystem
impl b2ParticleSystem
sourcepub fn ComputeCollisionEnergy(&self) -> f32
pub fn ComputeCollisionEnergy(&self) -> f32
Compute the kinetic energy that can be lost by damping force
source§impl b2ParticleSystem
impl b2ParticleSystem
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.
source§impl b2ParticleSystem
impl b2ParticleSystem
sourcepub fn GetStrictContactCheck(&self) -> bool
pub fn GetStrictContactCheck(&self) -> bool
Get the status of the strict contact check.
source§impl b2ParticleSystem
impl b2ParticleSystem
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.
source§impl b2ParticleSystem
impl b2ParticleSystem
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.
source§impl b2ParticleSystem
impl b2ParticleSystem
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.
source§impl b2ParticleSystem
impl b2ParticleSystem
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.
source§impl b2ParticleSystem
impl b2ParticleSystem
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.
source§impl b2ParticleSystem
impl b2ParticleSystem
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.
source§impl b2ParticleSystem
impl b2ParticleSystem
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