euv_core/game/physics/
struct.rs1use super::*;
2
3#[derive(Clone, Copy, Data, Debug, New, PartialEq)]
5pub struct PhysicsConfig {
6 #[get(type(copy))]
8 pub(crate) gravity: Point,
9 #[get(type(copy))]
11 pub(crate) cell_size: f32,
12 #[get(type(copy))]
14 pub(crate) position_correction: f32,
15 #[get(skip)]
17 pub(crate) arena_bounds: Option<Rect>,
18}
19
20#[derive(Clone, Copy, Data, Debug, New, PartialEq)]
22pub struct CollisionEvent {
23 #[get(type(copy))]
25 pub(crate) entity_a: EntityId,
26 #[get(type(copy))]
28 pub(crate) entity_b: EntityId,
29 #[get(type(copy))]
31 pub(crate) normal: Point,
32 #[get(type(copy))]
34 pub(crate) penetration: f32,
35 #[get(type(copy))]
37 pub(crate) is_trigger: bool,
38}
39
40#[derive(Clone, Copy, Data, Debug, PartialEq)]
42pub struct RaycastQuery2D {
43 #[get(type(copy))]
45 pub(crate) origin: Point,
46 #[get(type(copy))]
48 pub(crate) direction: Point,
49 #[get(type(copy))]
51 pub(crate) max_distance: f32,
52 #[get(type(copy))]
54 pub(crate) layer_mask: u32,
55}
56
57#[derive(Clone, Copy, Data, Debug, New, PartialEq)]
59pub struct RaycastHit {
60 #[get(type(copy))]
62 pub(crate) entity: EntityId,
63 #[get(type(copy))]
65 pub(crate) point: Point,
66 #[get(type(copy))]
68 pub(crate) normal: Point,
69 #[get(type(copy))]
71 pub(crate) distance: f32,
72}
73
74#[derive(Clone, Copy, Data, Debug, Default, Eq, Hash, New, PartialEq)]
76pub struct PhysicsStepStats {
77 #[get(type(copy))]
79 pub(crate) bodies_integrated: usize,
80 #[get(type(copy))]
82 pub(crate) broad_phase_pairs: usize,
83 #[get(type(copy))]
85 pub(crate) collisions_detected: usize,
86}
87
88#[derive(Clone, Data, Debug)]
90pub struct PhysicsWorld2D {
91 #[get(type(copy))]
93 pub(crate) config: PhysicsConfig,
94 #[get(pub(crate))]
96 #[get_mut(pub(crate))]
97 #[set(pub(crate))]
98 pub(crate) grid: HashMap<(i32, i32), Vec<usize>>,
99 #[get(pub(crate))]
101 #[get_mut(pub(crate))]
102 #[set(pub(crate))]
103 pub(crate) seen_pairs: HashSet<(usize, usize)>,
104 #[get(type(copy))]
106 pub(crate) last_stats: PhysicsStepStats,
107}