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 position_iterations: u32,
15 pub relaxation: f32,
16 pub slop: f32,
17 pub restitution_threshold: f32,
18 pub max_velocity: f32,
19 pub max_angular_velocity: f32,
20 pub broadphase_cell_size: f32,
21 pub sleep_velocity: f32,
22 pub sleep_angular_velocity: f32,
23 pub sleep_time: f32,
24 pub wake_velocity: f32,
25 pub friction_combine: MaterialCombine,
26 pub restitution_combine: MaterialCombine,
27}
28
29impl Default for PhysicsConfig {
30 fn default() -> Self {
31 Self {
32 gravity: [0.0, -9.81, 0.0],
33 damping: 0.05,
34 angular_damping: 0.05,
35 solve_iterations: 12,
36 position_iterations: 6,
37 relaxation: 0.8,
38 slop: 0.005,
39 restitution_threshold: 1.0,
40 max_velocity: 200.0,
41 max_angular_velocity: 400.0,
42 broadphase_cell_size: 2.0,
43 sleep_velocity: 0.2,
44 sleep_angular_velocity: 0.5,
45 sleep_time: 0.5,
46 wake_velocity: 0.4,
47 friction_combine: MaterialCombine::Multiply,
48 restitution_combine: MaterialCombine::Max,
49 }
50 }
51}