#![allow(
// We don't use syntax sugar where it's not necessary.
clippy::match_like_matches_macro,
// Redundant matching is more explicit.
clippy::redundant_pattern_matching,
// Explicit lifetimes are often easier to reason about.
clippy::needless_lifetimes,
// No need for defaults in the internal types.
clippy::new_without_default,
// Matches are good and extendable, no need to make an exception here.
clippy::single_match,
// Push commands are more regular than macros.
clippy::vec_init_then_push,
// This is the land of unsafe.
clippy::missing_safety_doc,
)]
#![warn(
trivial_numeric_casts,
unused_extern_crates,
//TODO: re-enable. Currently doesn't like "mem::size_of" on newer Rust
//unused_qualifications,
// We don't match on a reference, unless required.
clippy::pattern_type_mismatch,
)]
mod system;
pub use system::{ParticlePipeline, ParticleSystem, PipelineDesc};
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
pub enum EmitterShape {
Point,
Sphere { radius: f32 },
}
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
pub struct Emitter {
pub rate: f32,
pub burst_count: u32,
pub shape: EmitterShape,
#[serde(default = "default_cone_angle")]
pub cone_angle: f32,
}
fn default_cone_angle() -> f32 {
std::f32::consts::PI
}
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
pub enum ColorConfig {
Solid([u8; 4]),
Palette(Vec<[u8; 4]>),
}
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
pub struct ParticleConfig {
pub life: [f32; 2],
pub speed: [f32; 2],
pub scale: [f32; 2],
pub color: ColorConfig,
}
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
pub struct ParticleEffect {
pub capacity: u32,
pub emitter: Emitter,
pub particle: ParticleConfig,
}
impl ParticleEffect {
pub fn load(source: &str) -> Result<Self, ron::error::SpannedError> {
ron::from_str(source)
}
}
#[repr(C)]
#[derive(Clone, Copy, bytemuck::Zeroable, bytemuck::Pod)]
pub struct CameraParams {
pub view_proj: [f32; 16],
pub camera_right: [f32; 4],
pub camera_up: [f32; 4],
}