diff options
| author | Valentin Popov <valentin@popov.link> | 2026-12-01 15:38:57 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-12-01 15:38:57 +0300 |
| commit | 1e0128c6de44aa73e446451a27469e9873bc7e93 (patch) | |
| tree | dd056fd39a9223f11d27b21fca5d600b658bb5c7 /crates/fparkan-runtime/src/aim_convergence.rs | |
| parent | 2de3fd6567d6eee36910af260f1e5767213ba89c (diff) | |
| download | fparkan-1e0128c6de44aa73e446451a27469e9873bc7e93.tar.xz fparkan-1e0128c6de44aa73e446451a27469e9873bc7e93.zip | |
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.
Diffstat (limited to 'crates/fparkan-runtime/src/aim_convergence.rs')
| -rw-r--r-- | crates/fparkan-runtime/src/aim_convergence.rs | 14 |
1 files changed, 13 insertions, 1 deletions
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}; @@ -36,6 +37,17 @@ pub fn projectile_sight_target( 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<ProjectileContact>, +) -> Option<[f32; 3]> { let mission = engine.loaded.as_ref()?; let length = axis[0].hypot(axis[1]).hypot(axis[2]); if !length.is_finite() || length <= 0.0 { @@ -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, |
