diff options
| author | Valentin Popov <valentin@popov.link> | 2026-12-01 08:47:00 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-12-01 08:47:00 +0300 |
| commit | 0224286b0277d63f320f30df8bd2887ac596d207 (patch) | |
| tree | c0efa6b6ccffe4192eb954ecbc9e671033d9f85a /crates/fparkan-runtime/src/projectile_parts.rs | |
| parent | af281721b24a4c80d4c640c3d79a293dba2bee61 (diff) | |
| download | fparkan-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/projectile_parts.rs')
| -rw-r--r-- | crates/fparkan-runtime/src/projectile_parts.rs | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/crates/fparkan-runtime/src/projectile_parts.rs b/crates/fparkan-runtime/src/projectile_parts.rs index 8094ba0b..2a035e2f 100644 --- a/crates/fparkan-runtime/src/projectile_parts.rs +++ b/crates/fparkan-runtime/src/projectile_parts.rs @@ -81,11 +81,13 @@ pub(super) fn chassis_part_contact( }; let chassis = sphere_fraction.and_then(|_| { root_triangle_hit(&mission.mission_assets, index, state, segment, |node| { - rows.get(node as usize).is_some_and(|row| { - row.unit_component_index == 0 - && row.source_row_index == node as usize - && viable(row) - }) + rows.get(node as usize) + .filter(|row| { + row.unit_component_index == 0 + && row.source_row_index == node as usize + && viable(row) + }) + .map(|_| Lod(0)) }) .map(|(fraction, node)| (fraction, ProjectileNode::Chassis(node))) }); @@ -187,7 +189,7 @@ fn mounted_triangle_hit( model_segment, [1.0; 3], squared_length(model_segment), - |node| key(node).is_some(), + |node| key(node).map(|_| Lod(0)), )?; Some(( fraction, @@ -207,12 +209,12 @@ pub(super) fn root_triangle_hit( index: usize, state: TransformState, segment: [[f32; 3]; 2], - accept_node: impl Fn(u32) -> bool, + node_stage: impl Fn(u32) -> Option<Lod>, ) -> Option<(f32, u32)> { let model = &root_model(assets, index)?.validated; // shortcut: use root MSH fallback poses until combat shares live component transforms. let poses = node38_fallback_hierarchy(model)?; - model_triangle_hit(model, poses, state, segment, accept_node) + model_triangle_hit(model, poses, state, segment, node_stage) } pub(super) fn model_triangle_hit( @@ -220,7 +222,7 @@ pub(super) fn model_triangle_hit( poses: NodePoseBuffer, state: TransformState, segment: [[f32; 3]; 2], - accept_node: impl Fn(u32) -> bool, + node_stage: impl Fn(u32) -> Option<Lod>, ) -> Option<(f32, u32)> { let root = LegacyIron3dEulerTransform { translation: state.position.map(f32::from_bits), @@ -241,7 +243,7 @@ pub(super) fn model_triangle_hit( body_segment, scale, squared_length(segment), - accept_node, + node_stage, ) } @@ -257,7 +259,7 @@ fn triangle_hit( body_segment: [[f32; 3]; 2], scale: [f32; 3], squared_length: f32, - accept_node: impl Fn(u32) -> bool, + node_stage: impl Fn(u32) -> Option<Lod>, ) -> Option<(f32, u32)> { if squared_length == 0.0 { return None; @@ -269,10 +271,7 @@ fn triangle_hit( .enumerate() .filter_map(|(i, pose)| { let node = NodeId(u32::try_from(i).ok()?); - if !accept_node(node.0) { - return None; - } - let slot = selected_slot(model, node, Lod(0), Group(0))?; + let slot = selected_slot(model, node, node_stage(node.0)?, Group(0))?; let mut inverse = pose; inverse.translation = [0.0; 3]; for component in &mut inverse.rotation[..3] { |
