From 2e0a4571af587f28ba5ea580f177a225d0d352e2 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Thu, 26 Nov 2026 20:09:41 +0400 Subject: fix(audio): attach the engine loop to the player's missile Prepare velocity-driven Op2 sounds with the projectile's CTL attachment. Move their source with the active flight and stop it when the flight ends or its slot is reused. Keep launch as a separate one-shot. The GOG phase function confirms the missile's 0 to 1 phase range. In the stock Firing Line window the engine loop began at the tail and stopped on terrain contact. --- apps/fparkan-game/src/main.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'apps/fparkan-game/src/main.rs') diff --git a/apps/fparkan-game/src/main.rs b/apps/fparkan-game/src/main.rs index 8005faa7..b00605ab 100644 --- a/apps/fparkan-game/src/main.rs +++ b/apps/fparkan-game/src/main.rs @@ -22,6 +22,7 @@ mod player_collision; mod player_fire; mod player_footsteps; mod projectile_render; +mod projectile_sound; mod projectile_trail; mod shield_effects; mod shot_sound; @@ -10598,9 +10599,7 @@ impl StaticVulkanApp { let Some(flight) = instance.flight else { continue; }; - let forward = flight.direction; - let right = normalize3(cross3(forward, [0.0, 0.0, 1.0])).unwrap_or([1.0, 0.0, 0.0]); - let up = cross3(right, forward); + let [right, forward, up] = projectile_render::flight_basis(flight.direction); let rotate = |[x, y, z]: [f32; 3]| { add3(add3(scale3(right, x), scale3(forward, y)), scale3(up, z)) }; @@ -11669,6 +11668,11 @@ impl StaticVulkanApp { audio .update_listener(camera.position, camera.forward, camera.up) .map_err(|error| format!("update audio listener: {error}"))?; + projectile_sound::update( + audio, + &mut self.projectile_draws, + self.control_sound_slots.len(), + )?; for (id, sound) in self.control_sound_slots.iter_mut().enumerate() { let slot = &mut sound.effect; if self -- cgit v1.2.3