equal
deleted
inserted
replaced
1 use crate::common::{GearData, GearDataProcessor, GearId}; |
1 use crate::common::{GearData, GearDataProcessor, GearId, Millis}; |
2 use fpnum::*; |
2 use fpnum::*; |
3 use integral_geometry::{GridIndex, Point, Size}; |
3 use integral_geometry::{GridIndex, Point, Size}; |
4 |
4 |
5 #[derive(PartialEq, Eq, Clone, Copy, Debug)] |
5 #[derive(PartialEq, Eq, Clone, Copy, Debug)] |
6 pub struct PhysicsData { |
6 pub struct PhysicsData { |
131 physics_cleanup: Vec::new(), |
131 physics_cleanup: Vec::new(), |
132 position_updates: PositionUpdates::new(0), |
132 position_updates: PositionUpdates::new(0), |
133 } |
133 } |
134 } |
134 } |
135 |
135 |
136 pub fn process(&mut self, time_step: FPNum) -> &PositionUpdates { |
136 pub fn process(&mut self, time_step: Millis) -> &PositionUpdates { |
|
137 let fp_step = time_step.to_fixed(); |
137 self.position_updates.clear(); |
138 self.position_updates.clear(); |
138 for (gear_id, (pos, vel)) in self.dynamic_physics.iter_pos_update() { |
139 for (gear_id, (pos, vel)) in self.dynamic_physics.iter_pos_update() { |
139 let old_pos = *pos; |
140 let old_pos = *pos; |
140 *pos += *vel * time_step; |
141 *pos += *vel * fp_step; |
141 if !vel.is_zero() { |
142 if !vel.is_zero() { |
142 self.position_updates.push(gear_id, &old_pos, pos) |
143 self.position_updates.push(gear_id, &old_pos, pos) |
143 } else { |
144 } else { |
144 self.physics_cleanup.push(gear_id) |
145 self.physics_cleanup.push(gear_id) |
145 } |
146 } |