pub struct ParticleSystem<const N: usize> { /* private fields */ }Expand description
Fixed-capacity particle system.
N is the maximum number of simultaneously live particles. Slots are
reused in-place so spawning never allocates.
Implementations§
Source§impl<const N: usize> ParticleSystem<N>
impl<const N: usize> ParticleSystem<N>
Sourcepub fn spawn(&mut self, s: ParticleSpawn) -> bool
pub fn spawn(&mut self, s: ParticleSpawn) -> bool
Spawn a particle. Returns true on success, false if the pool is
at capacity (N particles already live).
Sourcepub fn update(&mut self, dt: f32, gravity: Vector3<f32>)
pub fn update(&mut self, dt: f32, gravity: Vector3<f32>)
Advance all particles by dt seconds.
gravity is applied uniformly to every particle’s velocity. Pass
Vector3::zeros() to disable gravity for this system.
Sourcepub fn active_count(&self) -> usize
pub fn active_count(&self) -> usize
Number of currently live particles.
Sourcepub fn iter_active(&self) -> impl Iterator<Item = &Particle>
pub fn iter_active(&self) -> impl Iterator<Item = &Particle>
Iterate over live particles (read-only).
Sourcepub fn record<const MAX: usize>(
&self,
engine: &K3dengine,
commands: &mut CommandBuffer<MAX>,
) -> usize
pub fn record<const MAX: usize>( &self, engine: &K3dengine, commands: &mut CommandBuffer<MAX>, ) -> usize
Record all live particles as camera-facing billboard quads into
commands.
Each particle emits two
DrawPrimitive::ColoredTriangleWithDepth
commands. Billboard orientation uses world-up (0, 1, 0), which is
correct for all but extreme pitch angles.
Returns the number of particles successfully projected and emitted. Particles that project behind the camera or outside the frustum are silently skipped.
Trait Implementations§
Auto Trait Implementations§
impl<const N: usize> Freeze for ParticleSystem<N>
impl<const N: usize> RefUnwindSafe for ParticleSystem<N>
impl<const N: usize> Send for ParticleSystem<N>
impl<const N: usize> Sync for ParticleSystem<N>
impl<const N: usize> Unpin for ParticleSystem<N>
impl<const N: usize> UnsafeUnpin for ParticleSystem<N>
impl<const N: usize> UnwindSafe for ParticleSystem<N>
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
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.