From b96eb701ab2031dceb27853d28c6630d62a300e8 Mon Sep 17 00:00:00 2001 From: hut Date: Fri, 29 Mar 2024 01:31:02 +0100 Subject: [PATCH] cleanup --- src/camera.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/camera.rs b/src/camera.rs index 0924829..03d2ce1 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -109,13 +109,13 @@ fn run_camera_controller( let mut engine = if let Ok(engine) = q_engine.get_single_mut() { engine } else { player_engine }; // Apply movement update - let acceleration: Vec3; + let acceleration_camera: Vec3; if axis_input != Vec3::ZERO { - acceleration = axis_input.normalize(); + acceleration_camera = axis_input.normalize(); engine.current_warmup = (engine.current_warmup + dt / engine.warmup_seconds).clamp(0.0, 1.0); play_thruster_sound = !settings.mute_sfx; } else { - acceleration = Vec3::ZERO; + acceleration_camera = Vec3::ZERO; engine.current_warmup = (engine.current_warmup - dt / engine.warmup_seconds).clamp(0.0, 1.0); } @@ -126,12 +126,13 @@ fn run_camera_controller( }); let right = *transform.right() * engine.thrust_sideways * engine.current_warmup; let up = *transform.up() * engine.thrust_sideways * engine.current_warmup; + let acceleration_global + = acceleration_camera.x * right + + acceleration_camera.y * up + + acceleration_camera.z * forward; let speed_multiplier = 30.0; - actor.v += speed_multiplier * dt * - ( acceleration.x * right - + acceleration.y * up - + acceleration.z * forward); + actor.v += speed_multiplier * dt * acceleration_global; // Handle mouse input let mut mouse_delta = Vec2::ZERO;