author | alfadur |
Fri, 09 Nov 2018 01:05:34 +0300 | |
changeset 14199 | a4c17cfaa4c9 |
parent 14165 | 165e43c3ed59 |
child 14200 | abbb74b9cb62 |
permissions | -rw-r--r-- |
14199 | 1 |
mod common; |
2 |
mod physics; |
|
3 |
mod grid; |
|
4 |
mod collision; |
|
14165 | 5 |
|
14199 | 6 |
use fpnum::FPNum; |
14165 | 7 |
use land2d::Land2D; |
14080
c6745a1c827a
start a physics engine to try out this data oriented thing everyone seems to be talking about
alfadur
parents:
diff
changeset
|
8 |
|
14199 | 9 |
use crate::{ |
10 |
common::GearId, |
|
11 |
physics::{ |
|
12 |
PhysicsProcessor, |
|
13 |
PhysicsData |
|
14 |
}, |
|
15 |
collision::{ |
|
16 |
CollisionProcessor, |
|
17 |
CollisionData, |
|
18 |
ContactData |
|
14080
c6745a1c827a
start a physics engine to try out this data oriented thing everyone seems to be talking about
alfadur
parents:
diff
changeset
|
19 |
} |
14199 | 20 |
}; |
14080
c6745a1c827a
start a physics engine to try out this data oriented thing everyone seems to be talking about
alfadur
parents:
diff
changeset
|
21 |
|
c6745a1c827a
start a physics engine to try out this data oriented thing everyone seems to be talking about
alfadur
parents:
diff
changeset
|
22 |
pub struct JoinedData { |
14199 | 23 |
gear_id: GearId, |
14080
c6745a1c827a
start a physics engine to try out this data oriented thing everyone seems to be talking about
alfadur
parents:
diff
changeset
|
24 |
physics: PhysicsData, |
c6745a1c827a
start a physics engine to try out this data oriented thing everyone seems to be talking about
alfadur
parents:
diff
changeset
|
25 |
collision: CollisionData, |
c6745a1c827a
start a physics engine to try out this data oriented thing everyone seems to be talking about
alfadur
parents:
diff
changeset
|
26 |
contact: ContactData |
c6745a1c827a
start a physics engine to try out this data oriented thing everyone seems to be talking about
alfadur
parents:
diff
changeset
|
27 |
} |
c6745a1c827a
start a physics engine to try out this data oriented thing everyone seems to be talking about
alfadur
parents:
diff
changeset
|
28 |
|
c6745a1c827a
start a physics engine to try out this data oriented thing everyone seems to be talking about
alfadur
parents:
diff
changeset
|
29 |
pub struct World { |
14199 | 30 |
physics: PhysicsProcessor, |
31 |
collision: CollisionProcessor, |
|
14080
c6745a1c827a
start a physics engine to try out this data oriented thing everyone seems to be talking about
alfadur
parents:
diff
changeset
|
32 |
} |
c6745a1c827a
start a physics engine to try out this data oriented thing everyone seems to be talking about
alfadur
parents:
diff
changeset
|
33 |
|
c6745a1c827a
start a physics engine to try out this data oriented thing everyone seems to be talking about
alfadur
parents:
diff
changeset
|
34 |
impl World { |
14165 | 35 |
pub fn step(&mut self, time_step: FPNum, land: &Land2D<u32>) { |
14199 | 36 |
let updates = self.physics.process(time_step); |
37 |
self.collision.process(land, &updates); |
|
14165 | 38 |
} |
39 |
||
14080
c6745a1c827a
start a physics engine to try out this data oriented thing everyone seems to be talking about
alfadur
parents:
diff
changeset
|
40 |
pub fn add_gear(&mut self, data: JoinedData) { |
14199 | 41 |
self.physics.push(data.gear_id, data.physics); |
42 |
self.collision.push(data.gear_id, data.physics, data.collision); |
|
14080
c6745a1c827a
start a physics engine to try out this data oriented thing everyone seems to be talking about
alfadur
parents:
diff
changeset
|
43 |
} |
c6745a1c827a
start a physics engine to try out this data oriented thing everyone seems to be talking about
alfadur
parents:
diff
changeset
|
44 |
} |
c6745a1c827a
start a physics engine to try out this data oriented thing everyone seems to be talking about
alfadur
parents:
diff
changeset
|
45 |
|
c6745a1c827a
start a physics engine to try out this data oriented thing everyone seems to be talking about
alfadur
parents:
diff
changeset
|
46 |
#[cfg(test)] |
c6745a1c827a
start a physics engine to try out this data oriented thing everyone seems to be talking about
alfadur
parents:
diff
changeset
|
47 |
mod tests { |
c6745a1c827a
start a physics engine to try out this data oriented thing everyone seems to be talking about
alfadur
parents:
diff
changeset
|
48 |
|
c6745a1c827a
start a physics engine to try out this data oriented thing everyone seems to be talking about
alfadur
parents:
diff
changeset
|
49 |
} |