equal
deleted
inserted
replaced
1 pub mod collision; |
1 pub mod collision; |
2 pub mod common; |
2 pub mod common; |
3 mod grid; |
3 mod grid; |
4 pub mod physics; |
4 pub mod physics; |
|
5 pub mod time; |
5 |
6 |
6 use fpnum::FPNum; |
7 use fpnum::FPNum; |
7 use integral_geometry::Size; |
8 use integral_geometry::Size; |
8 use land2d::Land2D; |
9 use land2d::Land2D; |
9 |
10 |
10 use crate::{ |
11 use crate::{ |
11 collision::{CollisionData, CollisionProcessor, ContactData}, |
12 collision::{CollisionData, CollisionProcessor, ContactData}, |
12 common::{GearData, GearDataAggregator, GearDataProcessor, GearId}, |
13 common::{GearData, GearDataAggregator, GearDataProcessor, GearId}, |
13 physics::{PhysicsData, PhysicsProcessor}, |
14 physics::{PhysicsData, PhysicsProcessor}, |
|
15 time::TimeProcessor, |
14 }; |
16 }; |
15 |
17 |
16 pub struct JoinedData { |
18 pub struct JoinedData { |
17 gear_id: GearId, |
19 gear_id: GearId, |
18 physics: PhysicsData, |
20 physics: PhysicsData, |
21 } |
23 } |
22 |
24 |
23 pub struct World { |
25 pub struct World { |
24 physics: PhysicsProcessor, |
26 physics: PhysicsProcessor, |
25 collision: CollisionProcessor, |
27 collision: CollisionProcessor, |
|
28 time: TimeProcessor, |
26 } |
29 } |
27 |
30 |
28 macro_rules! processor_map { |
31 macro_rules! processor_map { |
29 ( $data_type: ident => $field: ident ) => { |
32 ( $data_type: ident => $field: ident ) => { |
30 impl GearDataAggregator<$data_type> for World { |
33 impl GearDataAggregator<$data_type> for World { |
41 impl World { |
44 impl World { |
42 pub fn new(world_size: Size) -> Self { |
45 pub fn new(world_size: Size) -> Self { |
43 Self { |
46 Self { |
44 physics: PhysicsProcessor::new(), |
47 physics: PhysicsProcessor::new(), |
45 collision: CollisionProcessor::new(world_size), |
48 collision: CollisionProcessor::new(world_size), |
|
49 time: TimeProcessor::new(), |
46 } |
50 } |
47 } |
51 } |
48 |
52 |
49 pub fn step(&mut self, time_step: FPNum, land: &Land2D<u32>) { |
53 pub fn step(&mut self, time_step: FPNum, land: &Land2D<u32>) { |
50 let updates = self.physics.process(time_step); |
54 let updates = self.physics.process(time_step); |
51 let collision = self.collision.process(land, &updates); |
55 let collision = self.collision.process(land, &updates); |
|
56 let events = self.time.process(time_step); |
52 } |
57 } |
53 |
58 |
54 pub fn add_gear_data<T>(&mut self, gear_id: GearId, data: T) |
59 pub fn add_gear_data<T>(&mut self, gear_id: GearId, data: T) |
55 where |
60 where |
56 T: GearData, |
61 T: GearData, |