use crate::math_functions::PI;
#[derive(Debug, Clone, Copy, PartialEq, Default)]
pub struct Softness {
pub bias_rate: f32,
pub mass_scale: f32,
pub impulse_scale: f32,
}
pub fn make_soft(hertz: f32, zeta: f32, h: f32) -> Softness {
if hertz == 0.0 {
return Softness {
bias_rate: 0.0,
mass_scale: 0.0,
impulse_scale: 0.0,
};
}
let omega = 2.0 * PI * hertz;
let a1 = 2.0 * zeta + h * omega;
let a2 = h * omega * a1;
let a3 = 1.0 / (1.0 + a2);
Softness {
bias_rate: omega / a1,
mass_scale: a2 * a3,
impulse_scale: a3,
}
}
#[derive(Debug, Clone, Copy, PartialEq, Default)]
pub struct StepContext {
pub dt: f32,
pub inv_dt: f32,
pub h: f32,
pub inv_h: f32,
pub sub_step_count: i32,
pub contact_softness: Softness,
pub static_softness: Softness,
pub restitution_threshold: f32,
pub max_linear_velocity: f32,
pub contact_speed: f32,
pub enable_warm_starting: bool,
}
mod continuous;
mod integrate;
mod solve;
pub use solve::*;