This commit is contained in:
Quaternions 2024-08-27 16:52:57 -07:00
parent 3bb280a787
commit 40799945ce
2 changed files with 13 additions and 11 deletions

View File

@ -38,10 +38,11 @@ impl Booster{
pub fn boost(&self,velocity:Planar64Vec3)->Planar64Vec3{
match self{
&Booster::Velocity(boost_velocity)=>velocity+boost_velocity,
&Booster::Energy{direction,energy}=>{
let d=direction.dot(velocity);
&Booster::Energy{..}=>{
todo!()
//let d=direction.dot(velocity);
//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::Height(_)=>todo!(),

View File

@ -69,15 +69,15 @@ impl JumpImpulse{
&JumpImpulse::Height(height)=>{
//height==-v.y*v.y/(2*g.y);
//use energy to determine max height
let g=gravity.length();
let v_g=gravity.dot(velocity)/g;
let g=gravity.wide_length();
let v_g=gravity.wide_dot(velocity);
//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::Energy(energy)=>{
//calculate energy
let e=gravity.dot(velocity);
//let e=gravity.dot(velocity);
//add
//you get the idea
todo!()
@ -315,15 +315,16 @@ impl WalkSettings{
if control_dir==Planar64Vec3::ZERO{
return control_dir;
}
let n=normal.length();
let m=control_dir.length();
let d=normal.dot(control_dir)/m;
if d<n{
let n=normal.length();
let nm=n.wide_mul(m);
let d=normal.wide_dot(control_dir);
if d<nm{
let cr=normal.cross(control_dir);
if cr==Planar64Vec3::ZERO{
Planar64Vec3::ZERO
}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{
Planar64Vec3::ZERO