use super::*;
#[derive(Clone, Copy, Data, Debug, New, PartialEq)]
pub struct SphSolidCollider {
#[get(type(copy))]
pub(crate) shape: SphColliderShape,
#[get(type(copy))]
pub(crate) friction: f32,
#[get(type(copy))]
pub(crate) restitution: f32,
#[get(type(copy))]
pub(crate) enabled: bool,
}
#[derive(Clone, Copy, Data, Debug, New, PartialEq)]
pub struct SphFluidEmitter {
#[get(type(copy))]
pub(crate) position: Vec3,
#[get(type(copy))]
pub(crate) velocity: Vec3,
#[get(type(copy))]
pub(crate) radius: f32,
#[get(type(copy))]
pub(crate) rate_per_sec: f32,
#[get(type(copy))]
pub(crate) accumulator: f32,
#[get(type(copy))]
pub(crate) enabled: bool,
}
#[derive(Clone, Copy, Data, Debug, New, PartialEq)]
pub struct SphFluidDrain {
#[get(type(copy))]
pub(crate) position: Vec3,
#[get(type(copy))]
pub(crate) radius: f32,
#[get(type(copy))]
pub(crate) enabled: bool,
}
#[derive(Clone, Copy, Data, Debug, PartialEq)]
pub struct SphSolverConfig {
#[get(type(copy))]
pub(crate) domain_mode: FluidDomainMode,
#[get(type(copy))]
pub(crate) domain_min: Vec3,
#[get(type(copy))]
pub(crate) domain_max: Vec3,
#[get(type(copy))]
pub(crate) smoothing_radius: f32,
#[get(type(copy))]
pub(crate) rest_density: f32,
#[get(type(copy))]
pub(crate) particle_mass: f32,
#[get(type(copy))]
pub(crate) gravity: Vec3,
#[get(type(copy))]
pub(crate) substeps: u32,
#[get(type(copy))]
pub(crate) solver_iterations: u32,
#[get(type(copy))]
pub(crate) cfm_epsilon: f32,
#[get(type(copy))]
pub(crate) scorr_k: f32,
#[get(type(copy))]
pub(crate) scorr_dq_ratio: f32,
#[get(type(copy))]
pub(crate) scorr_n: u32,
#[get(type(copy))]
pub(crate) xsph_viscosity: f32,
#[get(type(copy))]
pub(crate) vorticity_epsilon: f32,
#[get(type(copy))]
pub(crate) surface_tension_cohesion: f32,
#[get(type(copy))]
pub(crate) surface_tension_curvature: f32,
#[get(type(copy))]
pub(crate) max_particles: usize,
#[get(type(copy))]
pub(crate) hash_table_size: usize,
#[get(type(copy))]
pub(crate) max_speed: f32,
#[get(type(copy))]
pub(crate) seed: u64,
}
#[derive(Clone, Copy, Data, Debug, Default, New, PartialEq)]
pub struct SphParticle {
#[get(type(copy))]
pub(crate) position: Vec3,
#[get(type(copy))]
pub(crate) velocity: Vec3,
#[get(type(copy))]
pub(crate) density: f32,
#[get(type(copy))]
pub(crate) color_normal: Vec3,
}
#[derive(Clone, Copy, Data, Debug, Default, New, PartialEq)]
pub struct SphSolverStats {
#[get(type(copy))]
pub(crate) particle_count: usize,
#[get(type(copy))]
pub(crate) mean_density: f32,
#[get(type(copy))]
pub(crate) max_density: f32,
#[get(type(copy))]
pub(crate) mean_compression_error: f32,
#[get(type(copy))]
pub(crate) kinetic_energy: f32,
#[get(type(copy))]
pub(crate) total_mass: f32,
#[get(type(copy))]
pub(crate) step_count: u64,
}
#[derive(Clone, Data, Debug, Default, PartialEq)]
pub(crate) struct SphScratchBuffers {
pub(crate) predicted_positions: Vec<Vec3>,
pub(crate) lambdas: Vec<f32>,
pub(crate) delta_positions: Vec<Vec3>,
pub(crate) vorticities: Vec<Vec3>,
pub(crate) xsph_deltas: Vec<Vec3>,
pub(crate) tension_deltas: Vec<Vec3>,
pub(crate) cell_counts: Vec<u32>,
pub(crate) cell_offsets: Vec<u32>,
pub(crate) cell_cursors: Vec<u32>,
pub(crate) particle_hashes: Vec<u32>,
pub(crate) sorted_indices: Vec<u32>,
pub(crate) neighbor_counts: Vec<u16>,
pub(crate) neighbor_indices: Vec<u32>,
}
#[derive(Clone, Copy, Data, Debug, Default, New, PartialEq)]
pub(crate) struct SphKernelConstants {
#[get(type(copy))]
pub(crate) h: f32,
#[get(type(copy))]
pub(crate) h2: f32,
#[get(type(copy))]
pub(crate) poly6_coeff: f32,
#[get(type(copy))]
pub(crate) spiky_grad_coeff: f32,
#[get(type(copy))]
pub(crate) poly6_grad_coeff: f32,
#[get(type(copy))]
pub(crate) akinci_cohesion_coeff: f32,
#[get(type(copy))]
pub(crate) w_dq_inv: f32,
}
#[derive(Clone, Data, Debug, PartialEq)]
pub struct SphLiquidSolver3D {
#[get(type(copy))]
pub(crate) config: SphSolverConfig,
pub(crate) particles: Vec<SphParticle>,
pub(crate) colliders: Vec<SphSolidCollider>,
pub(crate) emitters: Vec<SphFluidEmitter>,
pub(crate) drains: Vec<SphFluidDrain>,
pub(crate) scratch: SphScratchBuffers,
#[get(type(copy))]
pub(crate) rng_state: u64,
#[get(type(copy))]
pub(crate) step_count: u64,
#[get(type(copy))]
pub(crate) sim_time_secs: f32,
}