From 1e0128c6de44aa73e446451a27469e9873bc7e93 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Tue, 1 Dec 2026 16:38:57 +0400 Subject: fix(combat): fire autonomous turrets along their barrel and sights Transform the live CPT axis through the weapon sockets and the chassis. Mounted weapons use the same sight convergence as manual shots for compatible profiles. The autonomous ray checks current chassis and mounted geometry. Checked the Control.dll CPT transform and convergence oracle against the Rust path, observed the initial AutoDemo combat in the Vulkan window, and ran the licensed AutoDemo combat test. --- crates/fparkan-runtime/src/aim_convergence.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'crates/fparkan-runtime/src/aim_convergence.rs') diff --git a/crates/fparkan-runtime/src/aim_convergence.rs b/crates/fparkan-runtime/src/aim_convergence.rs index c67a9ab0..36acc2dc 100644 --- a/crates/fparkan-runtime/src/aim_convergence.rs +++ b/crates/fparkan-runtime/src/aim_convergence.rs @@ -2,6 +2,7 @@ use crate::{ projectile::segment_point, projectile_terrain_hit, projectile_unit_hit, Engine, ObjectHandle, + ProjectileContact, }; use fparkan_assets::{PreparedComponentControl, PreparedControlPoint}; @@ -35,6 +36,17 @@ pub fn projectile_sight_target( shooter: ObjectHandle, origin: [f32; 3], axis: [f32; 3], +) -> Option<[f32; 3]> { + sight_target(engine, origin, axis, |segment| { + projectile_unit_hit(engine, shooter, segment) + }) +} + +pub(super) fn sight_target( + engine: &Engine, + origin: [f32; 3], + axis: [f32; 3], + body_contact: impl FnOnce([[f32; 3]; 2]) -> Option, ) -> Option<[f32; 3]> { let mission = engine.loaded.as_ref()?; let length = axis[0].hypot(axis[1]).hypot(axis[2]); @@ -45,7 +57,7 @@ pub fn projectile_sight_target( let at = |distance: f32| std::array::from_fn(|i| origin[i] + axis[i] * distance); let segment = [at(5.0), at(1_000_000.0)]; let terrain = projectile_terrain_hit(&mission.terrain, segment).ok()?; - let unit = projectile_unit_hit(engine, shooter, segment).map(|hit| hit.fraction); + let unit = body_contact(segment).map(|hit| hit.fraction); let fraction = terrain.into_iter().chain(unit).min_by(f32::total_cmp)?; Some(convergence_point( origin, -- cgit v1.2.3