This commit is contained in:
Quaternions 2024-09-11 14:29:45 -07:00
parent bd72b50db6
commit 5c059ed17d

View File

@ -70,11 +70,11 @@ impl JumpImpulse{
//height==-v.y*v.y/(2*g.y);
//use energy to determine max height
let gg=gravity.length_squared();
let g:Planar64=gg.sqrt().fix();
let g=gg.sqrt().fix_1();
let v_g=gravity.dot(velocity);
//do it backwards
let radicand=v_g*v_g+(g*height*2).fix::<Fixed<4,128>>();
velocity-(*gravity*(radicand.sqrt().fix::<Planar64>()+v_g)/gg).divide().map(|t|t.fix::<Planar64>())
let radicand=v_g*v_g+(g*height*2).fix_4();
velocity-(*gravity*(radicand.sqrt().fix_2()+v_g)/gg).divide().map(|t|t.fix_1())
},
&JumpImpulse::Linear(jump_speed)=>velocity+jump_dir.with_length(jump_speed),
&JumpImpulse::Energy(energy)=>{