Skip to main content

dynamis_model/
config.rs

1#[derive(Clone, Copy, Debug, PartialEq, Eq)]
2pub enum MaterialCombine {
3    Multiply,
4    Min,
5    Max,
6    Average,
7}
8
9pub struct PhysicsConfig {
10    pub gravity: [f32; 3],
11    pub damping: f32,
12    pub angular_damping: f32,
13    pub solve_iterations: u32,
14    pub relaxation: f32,
15    pub slop: f32,
16    pub restitution_threshold: f32,
17    pub max_velocity: f32,
18    pub max_angular_velocity: f32,
19    pub broadphase_cell_size: f32,
20    pub sleep_velocity: f32,
21    pub sleep_angular_velocity: f32,
22    pub sleep_time: f32,
23    pub wake_velocity: f32,
24    pub friction_combine: MaterialCombine,
25    pub restitution_combine: MaterialCombine,
26}
27
28impl Default for PhysicsConfig {
29    fn default() -> Self {
30        Self {
31            gravity: [0.0, -9.81, 0.0],
32            damping: 0.05,
33            angular_damping: 0.05,
34            solve_iterations: 12,
35            relaxation: 0.4,
36            slop: 0.005,
37            restitution_threshold: 1.0,
38            max_velocity: 200.0,
39            max_angular_velocity: 400.0,
40            broadphase_cell_size: 2.0,
41            sleep_velocity: 0.2,
42            sleep_angular_velocity: 0.5,
43            sleep_time: 0.5,
44            wake_velocity: 0.4,
45            friction_combine: MaterialCombine::Multiply,
46            restitution_combine: MaterialCombine::Max,
47        }
48    }
49}