class CrShader::Compute::ParticleSimulationEngine

Overview

Pure Core Engine for CPU/GPU Particle Simulation & Buffer Management

Defined in:

crshader/compute/particle_simulation_core.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(capacity : Int32 = 1024, local_size_x : Int32 = 64, integrator : IntegratorMode = IntegratorMode::SemiImplicitEuler, bounds : DomainBounds = DomainBounds.new) #

Class Method Detail

def self.hash11(p : Float32) : Float32 #

Deterministic hash for procedural seeding (matches std/particles GPU hash)


Instance Method Detail

def attractors : Array(ForceAttractor) #

def attractors=(attractors : Array(ForceAttractor)) #

def bounds : DomainBounds #

def bounds=(bounds : DomainBounds) #

def buffer_byte_size : Int32 #

Total byte size of the std430 storage buffer


def capacity : Int32 #

def integrator : IntegratorMode #

def integrator=(integrator : IntegratorMode) #

def local_size_x : Int32 #

def pack_buffer! : Bytes #

Packs all ParticleState structs into the contiguous std430 byte buffer


def particles : Slice(ParticleState) #

def push_constants : SimulationPushConstants #

def push_constants=(push_constants : SimulationPushConstants) #

def raw_buffer : Bytes #

def seed_radial(origin_x : Float32 = 0.0_f32, origin_y : Float32 = 5.0_f32, origin_z : Float32 = 0.0_f32, spread : Float32 = 2.0_f32, base_speed : Float32 = 3.0_f32, lifetime : Float32 = 4.0_f32) : Void #

Seeds particles within a radial or box emitter volume


def step_cpu(dt : Float32) : Void #

Reference CPU step matching the GPU compute shader physics kernel


def unpack_buffer!(bytes : Bytes = @raw_buffer) : Slice(ParticleState) #

Unpacks the contiguous std430 byte buffer back into ParticleState structs


def workgroup_count_x : Int32 #

Number of 1D compute workgroups needed to cover capacity