rust/hwphysics/src/physics.rs
changeset 15392 b387a51705ac
parent 15383 701ad89a9f2a
child 15393 0ef770a40e75
equal deleted inserted replaced
15391:7a3d70c364fd 15392:b387a51705ac
    63     }
    63     }
    64 
    64 
    65     pub fn process_single_tick(&mut self, data: &mut GearDataManager) -> &PositionUpdates {
    65     pub fn process_single_tick(&mut self, data: &mut GearDataManager) -> &PositionUpdates {
    66         self.position_updates.clear();
    66         self.position_updates.clear();
    67 
    67 
    68         data.iter_id(
    68         data.iter().run_id(
    69             |gear_id, (pos, vel): (&mut PositionData, &mut VelocityData)| {
    69             |gear_id, (pos, vel): (&mut PositionData, &mut VelocityData)| {
    70                 let old_pos = pos.0;
    70                 let old_pos = pos.0;
    71                 vel.0 -= self.gravity;
    71                 vel.0 -= self.gravity;
    72                 pos.0 += vel.0;
    72                 pos.0 += vel.0;
    73                 self.position_updates.push(gear_id, &old_pos, &pos.0)
    73                 self.position_updates.push(gear_id, &old_pos, &pos.0)
    83         time_step: Millis,
    83         time_step: Millis,
    84     ) -> &PositionUpdates {
    84     ) -> &PositionUpdates {
    85         let fp_step = time_step.to_fixed();
    85         let fp_step = time_step.to_fixed();
    86         self.position_updates.clear();
    86         self.position_updates.clear();
    87 
    87 
    88         data.iter_id(
    88         data.iter().run_id(
    89             |gear_id, (pos, vel): (&mut PositionData, &mut VelocityData)| {
    89             |gear_id, (pos, vel): (&mut PositionData, &mut VelocityData)| {
    90                 let old_pos = pos.0;
    90                 let old_pos = pos.0;
    91                 vel.0 -= self.gravity * fp_step;
    91                 vel.0 -= self.gravity * fp_step;
    92                 pos.0 += vel.0 * fp_step;
    92                 pos.0 += vel.0 * fp_step;
    93                 self.position_updates.push(gear_id, &old_pos, &pos.0)
    93                 self.position_updates.push(gear_id, &old_pos, &pos.0)