From eb34cce7465c5eed68477a5f6d3c2ac04f91abbc Mon Sep 17 00:00:00 2001 From: Quaternions Date: Wed, 21 Feb 2024 04:12:08 -0800 Subject: [PATCH] flyin --- src/physics.rs | 13 +++++++++++++ src/physics_worker.rs | 2 ++ src/window.rs | 1 + 3 files changed, 16 insertions(+) diff --git a/src/physics.rs b/src/physics.rs index 0af0b19..4b962be 100644 --- a/src/physics.rs +++ b/src/physics.rs @@ -46,6 +46,7 @@ pub enum PhysicsInputInstruction { //Idle: there were no input events, but the simulation is safe to advance to this timestep //for interpolation / networking / playback reasons, most playback heads will always want //to be 1 instruction ahead to generate the next state for interpolation. + PracticeFly, } #[derive(Clone,Copy,Debug,Default,Hash)] @@ -1484,6 +1485,18 @@ fn run_teleport_behaviour(wormhole:&Option,models state.move_state=MoveState::Air; //b_refresh_walk_target will figure out gravity and stuff }, + PhysicsInputInstruction::PracticeFly=>{ + match &state.move_state{ + MoveState::Fly=>{ + state.move_state=MoveState::Air; + state.body.acceleration=state.style.gravity; + }, + _=>{ + state.move_state=MoveState::Fly; + state.body.acceleration=Planar64Vec3::ZERO; + }, + } + }, PhysicsInputInstruction::Idle=>{b_refresh_walk_target=false;},//literally idle! } if b_refresh_walk_target{ diff --git a/src/physics_worker.rs b/src/physics_worker.rs index 37196e1..1f0e970 100644 --- a/src/physics_worker.rs +++ b/src/physics_worker.rs @@ -13,6 +13,7 @@ pub enum InputInstruction{ Jump(bool), Zoom(bool), Reset, + PracticeFly, } pub enum Instruction{ Input(InputInstruction), @@ -62,6 +63,7 @@ pub enum Instruction{ &InputInstruction::Jump(s)=>Some(PhysicsInputInstruction::SetJump(s)), &InputInstruction::Zoom(s)=>Some(PhysicsInputInstruction::SetZoom(s)), InputInstruction::Reset=>Some(PhysicsInputInstruction::Reset), + InputInstruction::PracticeFly=>Some(PhysicsInputInstruction::PracticeFly), }, Instruction::GenerateModels(_)=>Some(PhysicsInputInstruction::Idle), Instruction::ClearModels=>Some(PhysicsInputInstruction::Idle), diff --git a/src/window.rs b/src/window.rs index 3421469..08ed102 100644 --- a/src/window.rs +++ b/src/window.rs @@ -108,6 +108,7 @@ impl WindowContext<'_>{ "q"=>Some(InputInstruction::MoveDown(s)), "z"=>Some(InputInstruction::Zoom(s)), "r"=>if s{Some(InputInstruction::Reset)}else{None}, + "f"=>if s{Some(InputInstruction::PracticeFly)}else{None}, _=>None, }, _=>None,