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. --- apps/fparkan-game/src/main.rs | 84 +++++++++---------------------------------- 1 file changed, 17 insertions(+), 67 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 2dee309c..ca47614b 100644 --- a/apps/fparkan-game/src/main.rs +++ b/apps/fparkan-game/src/main.rs @@ -7196,7 +7196,17 @@ fn update_gameplay_animation_pose_buffers( if (object_index, component_index) == (cockpit.object_index, cockpit.component_index) { - apply_manual_turret_elevation(&instance.control, radians, &mut node_times); + if let Some(aim) = motion.and_then(|(_, _, engine)| { + fparkan_runtime::bunker_control::aim(engine, cockpit) + }) { + fparkan_runtime::apply_autonomous_turret_pose( + &instance.control, + aim, + &mut node_times, + ); + } else { + apply_manual_turret_elevation(&instance.control, radians, &mut node_times); + } } } if let Some((player, delta_seconds, buildings)) = player_doors { @@ -8946,7 +8956,9 @@ fn run_static_vulkan_mode( (player_weapon_layouts, projectile_draws) = projectile_render::prepare_player_draws( root, &|archive, name| fparkan_runtime::load_player_projectile(engine, archive, name), - std::iter::once(hero).chain(prepared_warbot_weapons(engine)), + std::iter::once(hero) + .chain(prepared_warbot_weapons(engine)) + .chain(fparkan_runtime::bunker_control::prepared_weapons(engine)), 0, &mut preview.mesh, &mut preview.materials, @@ -9727,70 +9739,6 @@ impl StaticVulkanApp { self.update_free_camera(delta_seconds, viewport) } - fn select_cockpit_frame( - &mut self, - cockpit: StartingCockpit, - viewport: [f32; 2], - ) -> Option { - let frame = self.mission_frame.as_ref()?; - let (_, state) = frame - .snapshot - .transforms - .iter() - .find(|(handle, _)| *handle == cockpit.handle)?; - let hierarchy = self - .component_pose_buffers - .get(cockpit.object_index)? - .get(cockpit.component_index)? - .as_ref()?; - let mount = self - .component_mount_poses - .get(cockpit.object_index)? - .get(cockpit.component_index)? - .as_ref() - .copied(); - if cockpit.component_index != 0 && mount.is_none() { - return None; - } - let pose = - control_effect_owner_node_pose(Some(hierarchy), mount.is_some(), cockpit.node_index)?; - let pose = mount.map_or(pose, |mount| compose_unit_pose(mount, pose)); - let offset = rotate_unit_vector(cockpit.node_point, pose.rotation); - let point = std::array::from_fn(|axis| pose.translation[axis] + offset[axis]); - let mut translation = state.position.map(f32::from_bits); - if let Some(engine) = &self.mission_engine { - translation[2] += fparkan_runtime::player_walk_camera_lift(engine, cockpit); - } - let [view_yaw, view_pitch] = frame.player_view_offset_bits.map(f32::from_bits); - let sights = cockpit_geometry::cockpit_sights( - LegacyIron3dEulerTransform { - translation, - orientation_radians: state.orientation.map(f32::from_bits), - }, - state.scale.map(f32::from_bits), - point, - pose.rotation, - (!self.uses_automatic_weapons()).then(|| f32::from_bits(frame.player_pitch_bits)), - )?; - let sights_view = sights.try_direct3d7_view_row_major()?; - let camera = sights - .with_cockpit_yaw(view_yaw)? - .with_cockpit_pitch(view_pitch)?; - let viewport = [0, 0, viewport[0] as i32, viewport[1] as i32]; - let frame = PreviewCameraFrame::from_legacy_d3d7( - camera, - LegacyD3d7Projection { - viewport, - near_plane: 0.5, - far_plane: 700.0, - field_of_view_radians: 1.3, - }, - )?; - self.cockpit_geometry.select(cockpit, camera); - self.player_aim_direction = Some([sights_view[2], sights_view[6], sights_view[10]]); - Some(frame) - } - fn advance_player_projectiles(&mut self, clock_ms: u32) -> Result<(), String> { let Some(engine) = self.mission_engine.as_mut() else { return Ok(()); @@ -9991,7 +9939,9 @@ impl StaticVulkanApp { (&self.mission_engine, self.cockpit, &self.demo_camera) { use std::fmt::Write as _; - let unit = if self.boarded_hero_index.is_some() { + let unit = if fparkan_runtime::bunker_control::aim(engine, cockpit).is_some() { + "Бункер" + } else if self.boarded_hero_index.is_some() { "Варбот" } else { "Герой" -- cgit v1.2.3