From 79635316902c69a363f1d1a9ebef110d94190356 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Tue, 1 Dec 2026 08:55:10 +0400 Subject: fix(combat): let projectiles destroy mounted warbot parts Resolve mounted model triangles through the sampled socket chain and publish the damage to the assembled Control provider. Remove the damaged geometry, stop weapons whose provider was depleted, and preserve already separated ranges when the chassis later dies. Confirmed with a licensed AutoDemo ray query and two frames around a controlled hit in the Vulkan window. --- crates/fparkan-runtime/src/weapon_pose.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'crates/fparkan-runtime/src/weapon_pose.rs') diff --git a/crates/fparkan-runtime/src/weapon_pose.rs b/crates/fparkan-runtime/src/weapon_pose.rs index f5f7758e..9da98bee 100644 --- a/crates/fparkan-runtime/src/weapon_pose.rs +++ b/crates/fparkan-runtime/src/weapon_pose.rs @@ -37,6 +37,7 @@ pub(super) struct WeaponPoses { states: Vec, hierarchies: Vec>, aims: Vec>, + pub(super) mounted_radius: f32, } impl WeaponPoses { @@ -69,6 +70,7 @@ impl WeaponPoses { states: vec![ControlInstanceState::default(); visuals.len()], hierarchies: vec![None; visuals.len()], aims: vec![None; visuals.len()], + mounted_radius: 0.0, } } @@ -81,6 +83,7 @@ impl WeaponPoses { hull_local_target: Option<[f32; 3]>, report: &mut WeaponPoseReport, ) { + self.mounted_radius = 0.0; for (component, &visual) in assets.visuals_for_object(index).iter().enumerate() { let model = assets .visual_by_id(visual) @@ -132,9 +135,32 @@ impl WeaponPoses { .as_ref() .and_then(|times| node38_sampled_hierarchy_at_times(&model.validated, times)) .or_else(|| node38_fallback_hierarchy(&model.validated)); + if let Some(center) = + self.model_point_on_hull(component, model.validated.bounding_sphere_center) + { + let distance = center[0].hypot(center[1]).hypot(center[2]); + self.mounted_radius = self + .mounted_radius + .max(distance + model.validated.bounding_sphere_radius); + } } } + pub(super) fn model_point_on_hull( + &self, + component: usize, + point: [f32; 3], + ) -> Option<[f32; 3]> { + let Mount::Socket(parent, socket) = *self.mounts.get(component)? else { + return None; + }; + mounted_point(&self.hierarchies, &self.mounts, parent, socket, point) + } + + pub(super) fn model_hierarchy(&self, component: usize) -> Option<&NodePoseBuffer> { + self.hierarchies.get(component)?.as_ref() + } + fn aim_at(&self, component: usize, target: [f32; 3]) -> Option { let local = match *self.mounts.get(component)? { Mount::Root => target, @@ -350,6 +376,7 @@ mod tests { fn cpt_scale_and_world_transform_match_control_dll_query() { // GOG Control.dll RVA 0x1b4f0, native execution with a supplied node matrix. let poses = WeaponPoses { + mounted_radius: 0.0, mounts: vec![Mount::Root], states: vec![], aims: vec![], -- cgit v1.2.3