From 0224286b0277d63f320f30df8bd2887ac596d207 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Tue, 1 Dec 2026 09:47:00 +0400 Subject: fix(combat): use building damage stages for projectile contacts AniMesh resolves the current node stage for its segment query. Select the same variant for projectile contacts in FParkan and verify a ray through the damaged factory roof on stock assets. --- crates/fparkan-runtime/src/capture_barrier.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'crates/fparkan-runtime/src/capture_barrier.rs') diff --git a/crates/fparkan-runtime/src/capture_barrier.rs b/crates/fparkan-runtime/src/capture_barrier.rs index 4375e379..de14c6be 100644 --- a/crates/fparkan-runtime/src/capture_barrier.rs +++ b/crates/fparkan-runtime/src/capture_barrier.rs @@ -4,7 +4,7 @@ use crate::projectile_parts::{model_triangle_hit, root_model}; use crate::{Engine, LoadedMissionState, MissionAssets, ProjectileNode, TransformState}; use fparkan_animation::AnimationTime; use fparkan_assets::{PreparedComponentControl, PreparedControlTimelineRow}; -use fparkan_msh::node38_sampled_hierarchy_at_times; +use fparkan_msh::{node38_sampled_hierarchy_at_times, Lod}; use fparkan_world::{transform_state, ObjectHandle, World}; pub(super) struct CaptureBarrier { @@ -148,8 +148,20 @@ pub(super) fn projectile_contact( segment: [[f32; 3]; 2], ) -> Option<(f32, ProjectileNode)> { let assets = &mission.mission_assets; + let table = mission + .control_device_tables + .iter() + .find(|table| table.handle == building); + let node_stage = |node| { + let stage = table + .and_then(|table| crate::control_node_provider_row(table, node).ok()) + .filter(|row| row.unit_component_index == 0 && row.source_row_index == node as usize) + .and_then(|row| row.mesh_state) + .map_or(0, |state| state.visible_stage); + Some(Lod(u8::try_from(stage).ok()?)) + }; let fallback = || { - crate::projectile_parts::root_triangle_hit(assets, index, state, segment, |_| true) + crate::projectile_parts::root_triangle_hit(assets, index, state, segment, node_stage) .map(|(fraction, node)| (fraction, ProjectileNode::Building(node))) }; let Some(control) = control(assets, index).filter(|control| rows(control).next().is_some()) @@ -167,7 +179,7 @@ pub(super) fn projectile_contact( let Some(poses) = node38_sampled_hierarchy_at_times(model, ×) else { return fallback(); }; - let (fraction, node) = model_triangle_hit(model, poses, state, segment, |_| true)?; + let (fraction, node) = model_triangle_hit(model, poses, state, segment, node_stage)?; let node = if times[node as usize].is_some() { ProjectileNode::CaptureBarrier } else { -- cgit v1.2.3