# HG changeset patch # User alfadur # Date 1563997799 -10800 # Node ID 775d7efa4e5c94d5623f8c66d54c49e8989d9605 # Parent 38ad9c57152342bb4e5a294f8397420b75b91be2 save full shifts to position updates diff -r 38ad9c571523 -r 775d7efa4e5c rust/hwphysics/src/physics.rs --- a/rust/hwphysics/src/physics.rs Tue Jul 23 20:22:27 2019 +0300 +++ b/rust/hwphysics/src/physics.rs Wed Jul 24 22:49:59 2019 +0300 @@ -78,20 +78,20 @@ pub struct PositionUpdates { pub gear_ids: Vec, - pub positions: Vec, + pub shifts: Vec<(FPPoint, FPPoint)>, } impl PositionUpdates { pub fn new(capacity: usize) -> Self { Self { gear_ids: Vec::with_capacity(capacity), - positions: Vec::with_capacity(capacity), + shifts: Vec::with_capacity(capacity), } } - pub fn push(&mut self, gear_id: GearId, position: &FPPoint) { + pub fn push(&mut self, gear_id: GearId, old_position: &FPPoint, new_position: &FPPoint) { self.gear_ids.push(gear_id); - self.positions.push(*position); + self.shifts.push((*old_position, *new_position)); } } @@ -107,9 +107,10 @@ pub fn process(&mut self, time_step: FPNum) -> &PositionUpdates { for (gear_id, (pos, vel)) in self.dynamic_physics.iter_pos_update() { + let old_pos = *pos; *pos += *vel * time_step; if !vel.is_zero() { - self.position_updates.push(gear_id, pos) + self.position_updates.push(gear_id, &old_pos, pos) } else { self.physics_cleanup.push(gear_id) }