From 3cef44c4b2d908ef449c2eb9037f91224051c8f6 Mon Sep 17 00:00:00 2001 From: yuni Date: Sun, 17 Nov 2024 00:14:45 +0100 Subject: [PATCH] WIP crisper camera controls (implement matching velocity) --- src/actor.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/actor.rs b/src/actor.rs index 7b6cc83..551bf39 100644 --- a/src/actor.rs +++ b/src/actor.rs @@ -823,14 +823,20 @@ fn handle_wants_acceleration( if let (Some(mut engine), Some(accel)) = (engine, accel) { let mut delta_v = DVec3::ZERO; let boost = engine.current_boost_factor; + engine.currently_matching_velocity = false; if accel.brake { if let Some(target_v) = closest_map.get(&entity) { - **v = *target_v; - thruster_on = true; + delta_v = *target_v - v.0; + if delta_v.length_squared() > 0.003 { + engine.currently_matching_velocity = true; + thruster_on = true; + } } - } else if accel.direction != DVec3::ZERO { - delta_v = (trans.rotation * accel.direction.as_vec3()).as_dvec3(); + } + + if accel.direction != DVec3::ZERO { + delta_v += (trans.rotation * accel.direction.as_vec3()).as_dvec3(); } if delta_v.length_squared() > 0.003 { @@ -853,7 +859,7 @@ fn handle_wants_acceleration( * engine.current_boost_factor; // Apply acceleration to velocity - **v += delta_v * engine_factor * dt as f64; + **v += delta_v.normalize() * engine_factor * dt as f64; // Visual effect if engine.engine_type == EngineType::Monopropellant {