author | alfadur |
Fri, 09 Nov 2018 01:05:34 +0300 | |
changeset 14178 | a4c17cfaa4c9 |
parent 14144 | 165e43c3ed59 |
child 14179 | abbb74b9cb62 |
permissions | -rw-r--r-- |
14178 | 1 |
mod common; |
2 |
mod physics; |
|
3 |
mod grid; |
|
4 |
mod collision; |
|
14144 | 5 |
|
14178 | 6 |
use fpnum::FPNum; |
14144 | 7 |
use land2d::Land2D; |
14059
c6745a1c827a
start a physics engine to try out this data oriented thing everyone seems to be talking about
alfadur
parents:
diff
changeset
|
8 |
|
14178 | 9 |
use crate::{ |
10 |
common::GearId, |
|
11 |
physics::{ |
|
12 |
PhysicsProcessor, |
|
13 |
PhysicsData |
|
14 |
}, |
|
15 |
collision::{ |
|
16 |
CollisionProcessor, |
|
17 |
CollisionData, |
|
18 |
ContactData |
|
14059
c6745a1c827a
start a physics engine to try out this data oriented thing everyone seems to be talking about
alfadur
parents:
diff
changeset
|
19 |
} |
14178 | 20 |
}; |
14059
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 { |
14178 | 23 |
gear_id: GearId, |
14059
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 { |
14178 | 30 |
physics: PhysicsProcessor, |
31 |
collision: CollisionProcessor, |
|
14059
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 { |
14144 | 35 |
pub fn step(&mut self, time_step: FPNum, land: &Land2D<u32>) { |
14178 | 36 |
let updates = self.physics.process(time_step); |
37 |
self.collision.process(land, &updates); |
|
14144 | 38 |
} |
39 |
||
14059
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) { |
14178 | 41 |
self.physics.push(data.gear_id, data.physics); |
42 |
self.collision.push(data.gear_id, data.physics, data.collision); |
|
14059
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 |
} |