fix falling

This commit is contained in:
Quaternions 2023-09-18 16:04:18 -07:00
parent 765ed42b9d
commit 3a0b3900ec

View File

@ -290,8 +290,13 @@ impl Body {
let dt=(time-self.time) as f64/1_000_000_000f64; 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) 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){ pub fn advance_time(&mut self, time: TIME){
self.position=self.extrapolated_position(time); self.position=self.extrapolated_position(time);
self.velocity=self.extrapolated_velocity(time);
self.time=time; self.time=time;
} }
} }