Skip to main content

ParticleEmitterRecord

Struct ParticleEmitterRecord 

Source
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: usize

Index 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: f32

Cosine 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: f32

Inclusive lower bound on the initial particle speed (m/s).

§speed_max: f32

Inclusive upper bound on the initial particle speed (m/s).

§lifetime_min: f32

Inclusive lower bound on the particle lifetime (seconds).

§lifetime_max: f32

Inclusive upper bound on the particle lifetime (seconds).

§gravity: [f32; 3]

Constant acceleration applied each frame, in m/s².

§spawn_rate: f32

Particles spawned per second.

§max_particles: u32

Pool size in slots. Live + dead particles share this fixed pool.

§size_start: f32

World-space billboard side length at age = 0 (m).

§size_end: f32

World-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

Source

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.

Source

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

Source§

fn clone(&self) -> ParticleEmitterRecord

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ParticleEmitterRecord

Source§

impl Debug for ParticleEmitterRecord

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for ParticleEmitterRecord

Source§

fn eq(&self, other: &ParticleEmitterRecord) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ParticleEmitterRecord

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more