From 86999574d1d8fb0f482ac58b2f854b7e1fc6d2aa Mon Sep 17 00:00:00 2001 From: yuni Date: Sat, 16 Nov 2024 23:12:47 +0100 Subject: [PATCH] WIP crisper camera controls (fix scaling of engine parameters) --- src/actor.rs | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/src/actor.rs b/src/actor.rs index 847ca85..9ef3051 100644 --- a/src/actor.rs +++ b/src/actor.rs @@ -728,16 +728,19 @@ fn handle_wants_acceleration( settings: Res, jupiter_pos: Res, q_audiosinks: Query<(&audio::Sfx, &AudioSink)>, - mut q_actor: Query<( - Entity, - &Transform, - &Position, - &mut LinearVelocity, - Option<&mut Engine>, - Option<&WantsAcceleration>, - Option<&hud::IsTargeted>, - Option<&PlayerCamera>, - ), Without>, + mut q_actor: Query< + ( + Entity, + &Transform, + &Position, + &mut LinearVelocity, + Option<&mut Engine>, + Option<&WantsAcceleration>, + Option<&hud::IsTargeted>, + Option<&PlayerCamera>, + ), + Without, + >, mut ew_effect: EventWriter, ) { let dt = time.delta_seconds(); @@ -818,19 +821,20 @@ fn handle_wants_acceleration( (engine.current_warmup + dt / engine.warmup_seconds).clamp(0.0, 1.0); // Adjust acceleration to what the engine can actually provide - let forward_factor = engine.current_warmup - * (if accel.direction.z > 0.0 { - engine.thrust_forward - } else { - engine.thrust_back - }); - let right_factor = engine.thrust_sideways * engine.current_warmup; - let up_factor = engine.thrust_sideways * engine.current_warmup; - let factor = - DVec3::new(right_factor as f64, up_factor as f64, forward_factor as f64); + let factor_forward = if accel.direction.z > 0.0 { + engine.thrust_forward + } else { + engine.thrust_back + }; + let factor_right = engine.thrust_sideways; + let factor_up = engine.thrust_sideways; + let engine_factor = Vec3::new(factor_forward, factor_up, factor_right).as_dvec3() + * engine.current_warmup as f64 + * ENGINE_SPEED_FACTOR as f64 + * engine.current_boost_factor; // Apply acceleration to velocity - **v += delta_v * factor; + **v += delta_v * engine_factor * dt as f64; // Visual effect if engine.engine_type == EngineType::Monopropellant {