forked from StrafesNET/strafe-client
floor(x+1)==floor(x)+1
This commit is contained in:
parent
72c91558e7
commit
4eda90e178
@ -843,7 +843,7 @@ impl Body{
|
|||||||
self.velocity=self.extrapolated_velocity(time);
|
self.velocity=self.extrapolated_velocity(time);
|
||||||
self.time=time;
|
self.time=time;
|
||||||
}
|
}
|
||||||
pub fn extrapolated_position_ratio_dt<Num,Den,N1,D1,N2,N3,D2,N4,N5,N6,T1>(&self,dt:integer::Ratio<Num,Den>)->Planar64Vec3
|
pub fn extrapolated_position_ratio_dt<Num,Den,N1,D1,N2,N3,D2,N4,T1>(&self,dt:integer::Ratio<Num,Den>)->Planar64Vec3
|
||||||
where
|
where
|
||||||
// Why?
|
// Why?
|
||||||
// All of this can be removed with const generics because the type can be specified as
|
// All of this can be removed with const generics because the type can be specified as
|
||||||
@ -858,29 +858,27 @@ impl Body{
|
|||||||
Num:core::ops::Mul<N3,Output=N4>,
|
Num:core::ops::Mul<N3,Output=N4>,
|
||||||
Den:core::ops::Mul<D1,Output=D2>,
|
Den:core::ops::Mul<D1,Output=D2>,
|
||||||
D2:Copy,
|
D2:Copy,
|
||||||
Planar64:core::ops::Mul<D2,Output=N5>,
|
Planar64:core::ops::Mul<D2,Output=N4>,
|
||||||
N4:core::ops::Add<N5,Output=N6>,
|
N4:integer::Divide<D2,Output=T1>,
|
||||||
N6:integer::Divide<D2,Output=T1>,
|
|
||||||
T1:integer::Fix<Planar64>,
|
T1:integer::Fix<Planar64>,
|
||||||
{
|
{
|
||||||
// a*dt^2/2 + v*dt + p
|
// a*dt^2/2 + v*dt + p
|
||||||
// (a*dt/2+v)*dt+p
|
// (a*dt/2+v)*dt+p
|
||||||
((self.acceleration.map(|elem|dt*elem/2)+self.velocity).map(|elem|dt.mul_ratio(elem))+self.position)
|
(self.acceleration.map(|elem|dt*elem/2)+self.velocity).map(|elem|dt.mul_ratio(elem))
|
||||||
.map(|elem|elem.divide().fix())
|
.map(|elem|elem.divide().fix())+self.position
|
||||||
}
|
}
|
||||||
pub fn extrapolated_velocity_ratio_dt<Num,Den,N1,N2,N3,T1>(&self,dt:integer::Ratio<Num,Den>)->Planar64Vec3
|
pub fn extrapolated_velocity_ratio_dt<Num,Den,N1,T1>(&self,dt:integer::Ratio<Num,Den>)->Planar64Vec3
|
||||||
where
|
where
|
||||||
Num:Copy,
|
Num:Copy,
|
||||||
Den:Copy,
|
Den:Copy,
|
||||||
Num:core::ops::Mul<Planar64,Output=N1>,
|
Num:core::ops::Mul<Planar64,Output=N1>,
|
||||||
Planar64:core::ops::Mul<Den,Output=N2>,
|
Planar64:core::ops::Mul<Den,Output=N1>,
|
||||||
N1:core::ops::Add<N2,Output=N3>,
|
N1:integer::Divide<Den,Output=T1>,
|
||||||
N3:integer::Divide<Den,Output=T1>,
|
|
||||||
T1:integer::Fix<Planar64>,
|
T1:integer::Fix<Planar64>,
|
||||||
{
|
{
|
||||||
// a*dt + v
|
// a*dt + v
|
||||||
(self.acceleration.map(|elem|dt*elem)+self.velocity)
|
self.acceleration.map(|elem|dt*elem)
|
||||||
.map(|elem|elem.divide().fix())
|
.map(|elem|elem.divide().fix())+self.velocity
|
||||||
}
|
}
|
||||||
pub fn advance_time_ratio_dt(&mut self,dt:model_physics::GigaTime){
|
pub fn advance_time_ratio_dt(&mut self,dt:model_physics::GigaTime){
|
||||||
self.position=self.extrapolated_position_ratio_dt(dt);
|
self.position=self.extrapolated_position_ratio_dt(dt);
|
||||||
|
Loading…
Reference in New Issue
Block a user