From efdb4c97bee0aee4d27a4fd64f6805366a0f6c80 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Fri, 16 Feb 2024 21:07:56 -0800 Subject: [PATCH] edit jumped_velocity garbage --- src/physics.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/physics.rs b/src/physics.rs index d73a695..ada6453 100644 --- a/src/physics.rs +++ b/src/physics.rs @@ -1196,11 +1196,6 @@ fn get_walk_state(move_state:&MoveState)->Option<&WalkState>{ } } -fn jumped_velocity(models:&PhysicsModels,style:&StyleModifiers,hitbox_mesh:&HitboxMesh,jump_dir:Planar64Vec3,v:&mut Planar64Vec3){ - //bro what even is this function - *v=*v+jump_dir*(style.jump.get_jump_deltav()/jump_dir.length()); -} - fn contact_normal(models:&PhysicsModels,hitbox_mesh:&HitboxMesh,contact:&ContactCollision)->Planar64Vec3{ let model_mesh=models.mesh(contact.convex_mesh_id); let minkowski=model_physics::MinkowskiMesh::minkowski_sum(model_mesh,hitbox_mesh.transformed_mesh()); @@ -1406,10 +1401,13 @@ fn run_teleport_behaviour(wormhole:&Option,models None=>(), } let calc_move=if state.style.get_control(Controls::Jump,state.input_state.controls){ - if let Some(walk_state)=get_walk_state(&state.move_state){ - jumped_velocity(&data.models,&state.style,&data.hitbox_mesh,walk_state.jump_direction.direction(&data.models,&data.hitbox_mesh,&walk_state.contact),&mut v); - set_velocity_cull(&mut state.body,&mut state.touching,&data.models,&data.hitbox_mesh,v) - }else{false} + state.style.jump.is_some_and(|jump_settings|{ + get_walk_state(&state.move_state).is_some_and(|walk_state|{ + let jump_dir=walk_state.jump_direction.direction(&data.models,&data.hitbox_mesh,&walk_state.contact); + v=jump_settings.jumped_velocity(&state.style,jump_dir,v); + set_velocity_cull(&mut state.body,&mut state.touching,&data.models,&data.hitbox_mesh,v) + }) + }) }else{false}; match &general.trajectory{ Some(trajectory)=>{ @@ -1512,10 +1510,12 @@ fn run_teleport_behaviour(wormhole:&Option,models PhysicsInputInstruction::SetJump(s)=>{ state.input_state.set_control(Controls::Jump,s); if let Some(walk_state)=get_walk_state(&state.move_state){ - let mut v=state.body.velocity; - jumped_velocity(&data.models,&state.style,&data.hitbox_mesh,walk_state.jump_direction.direction(&data.models,&data.hitbox_mesh,&walk_state.contact),&mut v); - if set_velocity_cull(&mut state.body,&mut state.touching,&data.models,&data.hitbox_mesh,v){ - (state.move_state,state.body.acceleration)=state.touching.get_move_state(&state.body,&data.models,&state.style,&data.hitbox_mesh,&state.camera,&state.input_state,state.time); + if let Some(jump_settings)=&state.style.jump{ + let jump_dir=walk_state.jump_direction.direction(&data.models,&data.hitbox_mesh,&walk_state.contact); + let jumped_velocity=jump_settings.jumped_velocity(&state.style,jump_dir,state.body.velocity); + if set_velocity_cull(&mut state.body,&mut state.touching,&data.models,&data.hitbox_mesh,jumped_velocity){ + (state.move_state,state.body.acceleration)=state.touching.get_move_state(&state.body,&data.models,&state.style,&data.hitbox_mesh,&state.camera,&state.input_state,state.time); + } } } b_refresh_walk_target=false;