pub struct ParticlePool {
pub slots: Vec<GpuParticle>,
/* private fields */
}Expand description
Fixed-capacity particle pool with a free list for O(1) emit/recycle.
Fields§
§slots: Vec<GpuParticle>All particle slots.
Implementations§
Source§impl ParticlePool
impl ParticlePool
Sourcepub fn alive_count(&self) -> usize
pub fn alive_count(&self) -> usize
Number of currently alive particles.
Sourcepub fn free_count(&self) -> usize
pub fn free_count(&self) -> usize
Number of free slots.
Sourcepub fn emit(&mut self, particle: GpuParticle) -> Option<usize>
pub fn emit(&mut self, particle: GpuParticle) -> Option<usize>
Emit a particle from the pool. Returns the slot index, or None if
the pool is full.
Sourcepub fn recycle_dead(&mut self)
pub fn recycle_dead(&mut self)
Recycle all dead particles back to the free list.
Sourcepub fn alive_iter(&self) -> impl Iterator<Item = &GpuParticle>
pub fn alive_iter(&self) -> impl Iterator<Item = &GpuParticle>
Iterate over all alive particles (immutable).
Sourcepub fn alive_iter_mut(&mut self) -> impl Iterator<Item = &mut GpuParticle>
pub fn alive_iter_mut(&mut self) -> impl Iterator<Item = &mut GpuParticle>
Iterate over all alive particles (mutable).
Auto Trait Implementations§
impl Freeze for ParticlePool
impl RefUnwindSafe for ParticlePool
impl Send for ParticlePool
impl Sync for ParticlePool
impl Unpin for ParticlePool
impl UnsafeUnpin for ParticlePool
impl UnwindSafe for ParticlePool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more