aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-runtime/src/capture_barrier.rs
diff options
context:
space:
mode:
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 {