rust/hwphysics/src/physics.rs
changeset 15382 6ad92b6ac43c
parent 15381 52844baced17
child 15383 701ad89a9f2a
equal deleted inserted replaced
15381:52844baced17 15382:6ad92b6ac43c
    66         let fp_step = time_step.to_fixed();
    66         let fp_step = time_step.to_fixed();
    67         self.position_updates.clear();
    67         self.position_updates.clear();
    68 
    68 
    69         data.iter_id(
    69         data.iter_id(
    70             |gear_id, (pos, vel): (&mut PositionData, &mut VelocityData)| {
    70             |gear_id, (pos, vel): (&mut PositionData, &mut VelocityData)| {
    71                 if !vel.0.is_zero() {
    71                 let old_pos = pos.0;
    72                     let old_pos = pos.0;
    72                 vel.0 -= self.gravity * fp_step;
    73                     vel.0 -= self.gravity * fp_step;
    73                 pos.0 += vel.0 * fp_step;
    74                     pos.0 += vel.0 * fp_step;
    74                 self.position_updates.push(gear_id, &old_pos, &pos.0)
    75                     self.position_updates.push(gear_id, &old_pos, &pos.0)
       
    76                 }
       
    77             },
    75             },
    78         );
    76         );
    79 
    77 
    80         &self.position_updates
    78         &self.position_updates
    81     }
    79     }