rust/hwphysics/src/physics.rs
changeset 15383 701ad89a9f2a
parent 15382 6ad92b6ac43c
child 15392 b387a51705ac
--- a/rust/hwphysics/src/physics.rs	Thu Aug 29 00:08:03 2019 +0300
+++ b/rust/hwphysics/src/physics.rs	Thu Aug 29 00:20:41 2019 +0300
@@ -57,12 +57,31 @@
 
     pub fn new() -> Self {
         Self {
-            gravity: fp!(100),
+            gravity: fp!(1 / 10),
             position_updates: PositionUpdates::new(64),
         }
     }
 
-    pub fn process(&mut self, data: &mut GearDataManager, time_step: Millis) -> &PositionUpdates {
+    pub fn process_single_tick(&mut self, data: &mut GearDataManager) -> &PositionUpdates {
+        self.position_updates.clear();
+
+        data.iter_id(
+            |gear_id, (pos, vel): (&mut PositionData, &mut VelocityData)| {
+                let old_pos = pos.0;
+                vel.0 -= self.gravity;
+                pos.0 += vel.0;
+                self.position_updates.push(gear_id, &old_pos, &pos.0)
+            },
+        );
+
+        &self.position_updates
+    }
+
+    pub fn process_multiple_ticks(
+        &mut self,
+        data: &mut GearDataManager,
+        time_step: Millis,
+    ) -> &PositionUpdates {
         let fp_step = time_step.to_fixed();
         self.position_updates.clear();