equal
deleted
inserted
replaced
99 .iter() |
99 .iter() |
100 .cloned() |
100 .cloned() |
101 .zip(self.shifts.iter()) |
101 .zip(self.shifts.iter()) |
102 .map(|(id, (from, to))| (id, from, to)) |
102 .map(|(id, (from, to))| (id, from, to)) |
103 } |
103 } |
|
104 |
|
105 pub fn clear(&mut self) { |
|
106 self.gear_ids.clear(); |
|
107 self.shifts.clear(); |
|
108 } |
104 } |
109 } |
105 |
110 |
106 impl PhysicsProcessor { |
111 impl PhysicsProcessor { |
107 pub fn new() -> Self { |
112 pub fn new() -> Self { |
108 PhysicsProcessor { |
113 PhysicsProcessor { |
112 position_updates: PositionUpdates::new(0), |
117 position_updates: PositionUpdates::new(0), |
113 } |
118 } |
114 } |
119 } |
115 |
120 |
116 pub fn process(&mut self, time_step: FPNum) -> &PositionUpdates { |
121 pub fn process(&mut self, time_step: FPNum) -> &PositionUpdates { |
|
122 self.position_updates.clear(); |
117 for (gear_id, (pos, vel)) in self.dynamic_physics.iter_pos_update() { |
123 for (gear_id, (pos, vel)) in self.dynamic_physics.iter_pos_update() { |
118 let old_pos = *pos; |
124 let old_pos = *pos; |
119 *pos += *vel * time_step; |
125 *pos += *vel * time_step; |
120 if !vel.is_zero() { |
126 if !vel.is_zero() { |
121 self.position_updates.push(gear_id, &old_pos, pos) |
127 self.position_updates.push(gear_id, &old_pos, pos) |