pub struct GpuParticleSystem {Show 13 fields
pub max_particles: u32,
pub alive_count_approx: u32,
pub current_read: u32,
pub corruption: f32,
pub force_fields: Vec<GpuForceField>,
pub pending_emits: Vec<GpuEmitterConfig>,
pub initialized: bool,
pub distribution: EngineDistribution,
pub depth_layers: Vec<f32>,
pub damping: f32,
pub gravity: Vec3,
pub wind: Vec3,
pub turbulence: f32,
}Expand description
The main GPU particle system.
Manages double-buffered SSBOs, compute shader dispatches, and indirect rendering. All particle simulation happens on the GPU — the CPU only uploads uniform parameters (force fields, corruption, time).
Fields§
§max_particles: u32Maximum number of particles the system supports.
alive_count_approx: u32Currently alive particle count (approximate — GPU-authoritative).
current_read: u32Which buffer is the current read source (A=0, B=1).
corruption: f32Corruption parameter (0.0 = normal, affects engine behaviors).
force_fields: Vec<GpuForceField>Active force fields.
pending_emits: Vec<GpuEmitterConfig>Pending emitter configs for this frame.
initialized: boolWhether the system has been initialized with initial particles.
distribution: EngineDistributionPer-engine particle counts for initial seeding.
depth_layers: Vec<f32>Depth layer assignments: how many layers and their Z offsets.
damping: f32Global damping factor.
gravity: Vec3Gravity vector.
wind: Vec3Wind vector.
turbulence: f32Turbulence strength.
Implementations§
Source§impl GpuParticleSystem
impl GpuParticleSystem
Sourcepub fn chaos_field() -> Self
pub fn chaos_field() -> Self
Create a chaos field system with default 50,000 particles across 3 depth layers.
Sourcepub fn chaos_field_large() -> Self
pub fn chaos_field_large() -> Self
Create a large chaos field with 131,072 particles.
Sourcepub fn generate_initial_particles(&self, bounds: Vec3) -> Vec<GpuParticle>
pub fn generate_initial_particles(&self, bounds: Vec3) -> Vec<GpuParticle>
Generate initial particle data for CPU upload.
This creates a buffer of max_particles particles distributed according
to self.distribution, positioned randomly within a bounding volume.
Sourcepub fn add_force_field(&mut self, field: GpuForceField)
pub fn add_force_field(&mut self, field: GpuForceField)
Add a force field for this frame.
Sourcepub fn add_impact_field(&mut self, position: Vec3, strength: f32, radius: f32)
pub fn add_impact_field(&mut self, position: Vec3, strength: f32, radius: f32)
Add a temporary impact force field (e.g., from a combat hit).
Sourcepub fn add_vortex_field(&mut self, position: Vec3, strength: f32, radius: f32)
pub fn add_vortex_field(&mut self, position: Vec3, strength: f32, radius: f32)
Add a vortex force field.
Sourcepub fn add_repulsion_field(
&mut self,
position: Vec3,
strength: f32,
radius: f32,
)
pub fn add_repulsion_field( &mut self, position: Vec3, strength: f32, radius: f32, )
Add a repulsion field (explosion shockwave).
Sourcepub fn emit(&mut self, config: GpuEmitterConfig)
pub fn emit(&mut self, config: GpuEmitterConfig)
Queue particles for emission this frame.
Sourcepub fn emit_burst(
&mut self,
origin: Vec3,
count: u32,
engine_type: u32,
color: Vec4,
)
pub fn emit_burst( &mut self, origin: Vec3, count: u32, engine_type: u32, color: Vec4, )
Queue a burst of particles with a specific engine type.
Sourcepub fn clear_frame_state(&mut self)
pub fn clear_frame_state(&mut self)
Clear all force fields. Call at the start of each frame.
Sourcepub fn swap_buffers(&mut self)
pub fn swap_buffers(&mut self)
Swap read/write buffers after compute dispatch.
Sourcepub fn update_dispatch_params(&self) -> GpuParticleDispatchParams
pub fn update_dispatch_params(&self) -> GpuParticleDispatchParams
Get the compute dispatch parameters for the update pass.
Sourcepub fn indirect_draw_params(&self) -> GpuIndirectDrawParams
pub fn indirect_draw_params(&self) -> GpuIndirectDrawParams
Get the indirect draw parameters.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GpuParticleSystem
impl RefUnwindSafe for GpuParticleSystem
impl Send for GpuParticleSystem
impl Sync for GpuParticleSystem
impl Unpin for GpuParticleSystem
impl UnsafeUnpin for GpuParticleSystem
impl UnwindSafe for GpuParticleSystem
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.