wip
This commit is contained in:
parent
3bb280a787
commit
40799945ce
@ -38,10 +38,11 @@ impl Booster{
|
|||||||
pub fn boost(&self,velocity:Planar64Vec3)->Planar64Vec3{
|
pub fn boost(&self,velocity:Planar64Vec3)->Planar64Vec3{
|
||||||
match self{
|
match self{
|
||||||
&Booster::Velocity(boost_velocity)=>velocity+boost_velocity,
|
&Booster::Velocity(boost_velocity)=>velocity+boost_velocity,
|
||||||
&Booster::Energy{direction,energy}=>{
|
&Booster::Energy{..}=>{
|
||||||
let d=direction.dot(velocity);
|
todo!()
|
||||||
|
//let d=direction.dot(velocity);
|
||||||
//TODO: think about negative
|
//TODO: think about negative
|
||||||
velocity+direction.with_length((d*d+energy).sqrt()-d)
|
//velocity+direction.with_length((d*d+energy).sqrt()-d)
|
||||||
},
|
},
|
||||||
Booster::AirTime(_)=>todo!(),
|
Booster::AirTime(_)=>todo!(),
|
||||||
Booster::Height(_)=>todo!(),
|
Booster::Height(_)=>todo!(),
|
||||||
|
@ -69,15 +69,15 @@ impl JumpImpulse{
|
|||||||
&JumpImpulse::Height(height)=>{
|
&JumpImpulse::Height(height)=>{
|
||||||
//height==-v.y*v.y/(2*g.y);
|
//height==-v.y*v.y/(2*g.y);
|
||||||
//use energy to determine max height
|
//use energy to determine max height
|
||||||
let g=gravity.length();
|
let g=gravity.wide_length();
|
||||||
let v_g=gravity.dot(velocity)/g;
|
let v_g=gravity.wide_dot(velocity);
|
||||||
//do it backwards
|
//do it backwards
|
||||||
velocity-gravity.with_length((v_g*v_g+height*g*2).sqrt()+v_g)
|
velocity-gravity.with_length(((v_g*v_g+g*height.widen()*2).sqrt()+v_g)/g)
|
||||||
},
|
},
|
||||||
&JumpImpulse::Linear(jump_speed)=>velocity+jump_dir.with_length(jump_speed),
|
&JumpImpulse::Linear(jump_speed)=>velocity+jump_dir.with_length(jump_speed),
|
||||||
&JumpImpulse::Energy(energy)=>{
|
&JumpImpulse::Energy(energy)=>{
|
||||||
//calculate energy
|
//calculate energy
|
||||||
let e=gravity.dot(velocity);
|
//let e=gravity.dot(velocity);
|
||||||
//add
|
//add
|
||||||
//you get the idea
|
//you get the idea
|
||||||
todo!()
|
todo!()
|
||||||
@ -315,15 +315,16 @@ impl WalkSettings{
|
|||||||
if control_dir==Planar64Vec3::ZERO{
|
if control_dir==Planar64Vec3::ZERO{
|
||||||
return control_dir;
|
return control_dir;
|
||||||
}
|
}
|
||||||
let n=normal.length();
|
|
||||||
let m=control_dir.length();
|
let m=control_dir.length();
|
||||||
let d=normal.dot(control_dir)/m;
|
let n=normal.length();
|
||||||
if d<n{
|
let nm=n.wide_mul(m);
|
||||||
|
let d=normal.wide_dot(control_dir);
|
||||||
|
if d<nm{
|
||||||
let cr=normal.cross(control_dir);
|
let cr=normal.cross(control_dir);
|
||||||
if cr==Planar64Vec3::ZERO{
|
if cr==Planar64Vec3::ZERO{
|
||||||
Planar64Vec3::ZERO
|
Planar64Vec3::ZERO
|
||||||
}else{
|
}else{
|
||||||
cr.cross(normal)*(self.accelerate.topspeed/(n*(n*n-d*d).sqrt()*m))
|
(cr.wide_cross(normal).wide_mul(self.accelerate.topspeed)/(n.wide_mul((nm*nm-d*d).sqrt()))).narrow()
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
Planar64Vec3::ZERO
|
Planar64Vec3::ZERO
|
||||||
|
Loading…
Reference in New Issue
Block a user