aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-runtime/src/capture_barrier.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-12-01 08:47:00 +0300
committerValentin Popov <valentin@popov.link>2026-12-01 08:47:00 +0300
commit0224286b0277d63f320f30df8bd2887ac596d207 (patch)
treec0efa6b6ccffe4192eb954ecbc9e671033d9f85a /crates/fparkan-runtime/src/capture_barrier.rs
parentaf281721b24a4c80d4c640c3d79a293dba2bee61 (diff)
downloadfparkan-0224286b0277d63f320f30df8bd2887ac596d207.tar.xz
fparkan-0224286b0277d63f320f30df8bd2887ac596d207.zip
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.
Diffstat (limited to 'crates/fparkan-runtime/src/capture_barrier.rs')
-rw-r--r--crates/fparkan-runtime/src/capture_barrier.rs18
1 files changed, 15 insertions, 3 deletions
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, &times) 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 {