pub struct ParticleEmitterRecord {Show 15 fields
pub texture_slot: usize,
pub position: [f32; 3],
pub direction: [f32; 3],
pub spread_cos: f32,
pub speed_min: f32,
pub speed_max: f32,
pub lifetime_min: f32,
pub lifetime_max: f32,
pub gravity: [f32; 3],
pub spawn_rate: f32,
pub max_particles: u32,
pub size_start: f32,
pub size_end: f32,
pub color_start: [f32; 4],
pub color_end: [f32; 4],
}Expand description
Resolved per-emitter state threaded into the backend at init. The backend
allocates one GPU particle pool of max_particles slots per record and
drives its compute + render passes from these fields each frame.
Fields§
§texture_slot: usizeIndex of the albedo texture in the renderer’s bindless / per-frame
texture pool. 0 means “no texture authored”: the renderer’s white
fallback at slot 0 is sampled and the colour gradient still shows.
position: [f32; 3]World-space spawn origin.
direction: [f32; 3]Mean emission direction, unit-length. The compute kernel samples a
new particle’s initial velocity from the cone of half-angle
spread_cos around this vector.
spread_cos: f32Cosine of the cone half-angle. 1.0 = straight jet, -1.0 = full
sphere. Pre-computed so the kernel does not call cos() per spawn.
speed_min: f32Inclusive lower bound on the initial particle speed (m/s).
speed_max: f32Inclusive upper bound on the initial particle speed (m/s).
lifetime_min: f32Inclusive lower bound on the particle lifetime (seconds).
lifetime_max: f32Inclusive upper bound on the particle lifetime (seconds).
gravity: [f32; 3]Constant acceleration applied each frame, in m/s².
spawn_rate: f32Particles spawned per second.
max_particles: u32Pool size in slots. Live + dead particles share this fixed pool.
size_start: f32World-space billboard side length at age = 0 (m).
size_end: f32World-space billboard side length at age = lifetime (m).
color_start: [f32; 4]Linear-space RGBA at age = 0.
color_end: [f32; 4]Linear-space RGBA at age = lifetime.
Implementations§
Source§impl ParticleEmitterRecord
impl ParticleEmitterRecord
Sourcepub fn aabb(&self) -> ([f32; 3], [f32; 3])
pub fn aabb(&self) -> ([f32; 3], [f32; 3])
Conservative world-space AABB enclosing every particle this emitter could spawn over its full lifetime. Used by the per-frame frustum-cull skip so an off-screen emitter pays no render cost; the compute kernel still ticks so the pool keeps evolving while the camera looks away.
The bound is a sphere centred on the emission point and is intentionally
loose: it ignores the cone-spread restriction (spread_cos) so the
same AABB also covers full-sphere emitters, and it sums the worst-case
ballistic terms: speed_max * lifetime_max (straight-line reach),
0.5 * |gravity| * lifetime_max² (gravity drift), and a
max(size_start, size_end) * sqrt(2) / 2 half-diagonal for the
camera-facing billboard quad. A tighter cone-aware bound is a future
refinement; this version is correct (never false-cull) and cheap.
Sourcepub fn params(
&self,
dt: f32,
spawn_budget: u32,
random_seed: u32,
) -> ParticleParams
pub fn params( &self, dt: f32, spawn_budget: u32, random_seed: u32, ) -> ParticleParams
Build the per-frame compute + render uniform from this record’s static fields and the dynamic spawn / time state the runtime carries.
dt is the elapsed seconds since the previous compute dispatch (the
integration step); spawn_budget is floor(spawn_accumulator), the
integer count of fresh particles the kernel may emit this frame; and
random_seed is the per-frame seed the kernel mixes with the thread
id to drive its cheap on-GPU RNG.
Trait Implementations§
Source§impl Clone for ParticleEmitterRecord
impl Clone for ParticleEmitterRecord
Source§fn clone(&self) -> ParticleEmitterRecord
fn clone(&self) -> ParticleEmitterRecord
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for ParticleEmitterRecord
Source§impl Debug for ParticleEmitterRecord
impl Debug for ParticleEmitterRecord
Source§impl PartialEq for ParticleEmitterRecord
impl PartialEq for ParticleEmitterRecord
impl StructuralPartialEq for ParticleEmitterRecord
Auto Trait Implementations§
impl Freeze for ParticleEmitterRecord
impl RefUnwindSafe for ParticleEmitterRecord
impl Send for ParticleEmitterRecord
impl Sync for ParticleEmitterRecord
impl Unpin for ParticleEmitterRecord
impl UnsafeUnpin for ParticleEmitterRecord
impl UnwindSafe for ParticleEmitterRecord
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
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> ⓘ
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