From 1fd51e5bbcfb4d5590fbc1ded8308fc40f6158f4 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 2 Dec 2026 19:57:36 +0400 Subject: feat(ui): enable manual control from the bunker list Use the active Control camera record and its separate CPT origin and direction for the fixed turret. The original hand control opens the cockpit, its two weapon slots and aim tracks while leaving the operator at the command post. Verified from the stock Two Fortresses start against the GOG cockpit with Vulkan validation. The licensed tests cover the native camera pose, mounted weapon selection and stationary bunker and operator. --- crates/fparkan-runtime/src/player_motion.rs | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'crates/fparkan-runtime/src/player_motion.rs') diff --git a/crates/fparkan-runtime/src/player_motion.rs b/crates/fparkan-runtime/src/player_motion.rs index be910936..6733f921 100644 --- a/crates/fparkan-runtime/src/player_motion.rs +++ b/crates/fparkan-runtime/src/player_motion.rs @@ -72,6 +72,7 @@ pub struct PlayerMotionStep { flight_velocity: Option<[f32; 3]>, hero_walk_velocity: Option<[f32; 2]>, hero_look: Option, + turret: Option, max_floor_clearance: f32, previous_terrain_height: Option, terrain_height: Option, @@ -228,6 +229,7 @@ mod tests { flight_velocity: None, hero_walk_velocity: None, hero_look: None, + turret: None, max_floor_clearance: FLOOR_CLEARANCE, previous_terrain_height: None, terrain_height: Some(11.5), @@ -268,6 +270,7 @@ mod tests { flight_velocity: None, hero_walk_velocity: None, hero_look: None, + turret: None, max_floor_clearance: 1.25, previous_terrain_height: Some(10.0), terrain_height: Some(10.0), @@ -293,6 +296,7 @@ mod tests { flight_velocity: None, hero_walk_velocity: None, hero_look: None, + turret: None, max_floor_clearance: FLOOR_CLEARANCE, previous_terrain_height: None, terrain_height: None, @@ -429,6 +433,31 @@ fn plan_player_steps( let boarded = mission .boarding .filter(|boarding| boarding.cockpit.handle == cockpit.handle); + if let Some(aim) = boarded.and_then(|boarding| boarding.turret) { + if [input.mouse_x, input.mouse_y] == [0.0; 2] && !mission.hero_look.has_state() { + return Ok(None); + } + if ![input.mouse_x, input.mouse_y] + .into_iter() + .all(f32::is_finite) + { + return Err(EngineError::Movement("invalid gunner input".into())); + } + let (look, aim) = + crate::bunker_control::advance(engine, cockpit, input, mission.hero_look, aim); + let mut step = plan_motion( + &mission.terrain, + pose, + aim.elevation, + 0.0, + None, + [0.0; 2], + PlayerMotion::default(), + )?; + step.hero_look = Some(look); + step.turret = Some(aim); + return Ok(Some(step)); + } let driving = boarded.filter(|boarding| boarding.controls_chassis()); if boarded.is_some() && driving.is_none() { input.movement = [0.0; 2]; @@ -633,6 +662,9 @@ pub(super) fn commit_motion_state( if boarding.cockpit.handle != cockpit.handle { return; } + if let Some(aim) = step.turret { + boarding.turret = Some(aim); + } if let Some(velocity) = step.flight_velocity { boarding.flight_velocity = if blocked { [0.0; 3] } else { velocity }; } else if !blocked && step.sweep.is_some() { @@ -743,6 +775,7 @@ fn plan_motion( flight_velocity, hero_walk_velocity: None, hero_look: None, + turret: None, max_floor_clearance: FLOOR_CLEARANCE, previous_terrain_height, terrain_height, -- cgit v1.2.3