From 3a0b3900ec6c674fc0145254942056d3e7e5d230 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Mon, 18 Sep 2023 16:04:18 -0700 Subject: [PATCH] fix falling --- src/body.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/body.rs b/src/body.rs index 8cb2a45..00fa85f 100644 --- a/src/body.rs +++ b/src/body.rs @@ -290,8 +290,13 @@ impl Body { let dt=(time-self.time) as f64/1_000_000_000f64; self.position+self.velocity*(dt as f32)+self.acceleration*((0.5*dt*dt) as f32) } + pub fn extrapolated_velocity(&self,time: TIME)->glam::Vec3{ + let dt=(time-self.time) as f64/1_000_000_000f64; + self.velocity+self.acceleration*(dt as f32) + } pub fn advance_time(&mut self, time: TIME){ self.position=self.extrapolated_position(time); + self.velocity=self.extrapolated_velocity(time); self.time=time; } }