b2ParticleSystem

Struct b2ParticleSystem 

Source
pub struct b2ParticleSystem { /* private fields */ }

Implementations§

Source§

impl b2ParticleSystem

Source

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.

Source

pub fn GetDensity(self: &b2ParticleSystem) -> f32

Get the particle density.

Source

pub fn SetGravityScale(self: Pin<&mut b2ParticleSystem>, gravityScale: f32)

Change the particle gravity scale. Adjusts the effect of the global gravity vector on particles.

Source

pub fn GetGravityScale(self: &b2ParticleSystem) -> f32

Get the particle gravity scale.

Source

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.

Source

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).

Source

pub fn GetNext(self: Pin<&mut b2ParticleSystem>) -> *mut b2ParticleSystem

Get the next particle-system in the world’s particle-system list.

Source

pub fn GetNext1(self: &b2ParticleSystem) -> *const b2ParticleSystem

Source

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

Source

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

Source

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

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

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

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.

Source

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

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

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

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

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

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

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

pub fn GetParticleGroupList1(&self) -> *const b2ParticleGroup

Source

pub fn GetParticleGroupCount(&self) -> c_int

Get the number of particle groups.

Source

pub fn GetParticleCount(&self) -> c_int

Get the number of particles.

Source

pub fn GetMaxParticleCount(&self) -> c_int

Get the maximum number of particles.

Source

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

pub fn GetAllParticleFlags(&self) -> c_uint

Get all existing particle flags.

Source

pub fn GetAllGroupFlags(&self) -> c_uint

Get all existing particle group flags.

Source

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.

Source

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().

Source

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

pub fn GetDamping(&self) -> f32

Get damping for particles

Source

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

pub fn GetStaticPressureIterations(&self) -> c_int

Get the number of iterations for static pressure of particles.

Source

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.

Source

pub fn GetRadius(&self) -> f32

Get the particle radius.

Source

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.

Source

pub fn GetPositionBuffer1(&self) -> *const b2Vec2

Source

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.

Source

pub fn GetVelocityBuffer1(&self) -> *const b2Vec2

Source

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

pub fn GetColorBuffer1(&self) -> *const b2ParticleColor

Source

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.

Source

pub fn GetWeightBuffer1(&self) -> *const f32

Source

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

pub fn SetParticleFlags(self: Pin<&mut Self>, index: c_int, flags: c_uint)

Set flags for a particle. See the b2ParticleFlag enum.

Source

pub fn GetParticleFlags(self: Pin<&mut Self>, index: c_int) -> c_uint

Get flags for a particle. See the b2ParticleFlag enum.

Source

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

pub unsafe fn SetPositionBuffer( self: Pin<&mut Self>, buffer: *mut b2Vec2, capacity: c_int, )

Source

pub unsafe fn SetVelocityBuffer( self: Pin<&mut Self>, buffer: *mut b2Vec2, capacity: c_int, )

Source

pub unsafe fn SetColorBuffer( self: Pin<&mut Self>, buffer: *mut b2ParticleColor, capacity: c_int, )

Source

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

pub fn GetContactCount(&self) -> c_int

Source

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

pub fn GetBodyContactCount(&self) -> c_int

Source

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

pub fn GetPairCount(&self) -> c_int

Source

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

pub fn GetTriadCount(&self) -> c_int

Source

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

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

pub fn GetStuckCandidateCount(&self) -> c_int

Get the number of stuck particle candidates from the last step.

Source

pub fn ComputeCollisionEnergy(&self) -> f32

Compute the kinetic energy that can be lost by damping force

Source

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

pub fn GetStrictContactCheck(&self) -> bool

Get the status of the strict contact check.

Source

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.

Source

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.

Source

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

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

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.

Source

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

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

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

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).

Source

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

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

Trait Implementations§

Source§

impl ExternType for b2ParticleSystem

Source§

type Id = (b, _2, P, a, r, t, i, c, l, e, S, y, s, t, e, m)

A type-level representation of the type’s C++ namespace and type name. Read more
Source§

type Kind = Opaque

Source§

impl MakeCppStorage for b2ParticleSystem

Source§

unsafe fn allocate_uninitialized_cpp_storage() -> *mut b2ParticleSystem

Allocates heap space for this type in C++ and return a pointer to that space, but do not initialize that space (i.e. do not yet call a constructor). Read more
Source§

unsafe fn free_uninitialized_cpp_storage(arg0: *mut b2ParticleSystem)

Frees a C++ allocation which has not yet had a constructor called. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.