From af281721b24a4c80d4c640c3d79a293dba2bee61 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Tue, 1 Dec 2026 09:39:16 +0400 Subject: fix(render): show building damage stages after projectile hits Update the contacted provider with the native stage rule. Upload the authored variants with their original material and pose, and draw the active stage only. The Two Fortresses plant switches in a validated before/after capture. --- apps/fparkan-game/src/damage_visibility.rs | 54 +++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) (limited to 'apps/fparkan-game/src/damage_visibility.rs') diff --git a/apps/fparkan-game/src/damage_visibility.rs b/apps/fparkan-game/src/damage_visibility.rs index e9ffdf53..fe462da1 100644 --- a/apps/fparkan-game/src/damage_visibility.rs +++ b/apps/fparkan-game/src/damage_visibility.rs @@ -4,7 +4,59 @@ use super::DynamicComponentGeometry; use fparkan_animation::NodePoseBuffer; use fparkan_msh::{draw_batches, selected_slot, Group, Lod, NodeId}; use fparkan_render_vulkan::{VulkanSmokeRenderer, VulkanStaticMesh}; -use fparkan_runtime::{depleted_warbot_nodes, Engine}; +use fparkan_runtime::{ + depleted_warbot_nodes, loaded_mission_control_device_tables, Engine, + MissionControlNodeProviderTableStatus, +}; +use std::collections::HashSet; + +pub(super) fn inactive_building_ranges( + engine: &Engine, + geometry: &[Vec>], +) -> HashSet { + let mut hidden = HashSet::new(); + let tables = loaded_mission_control_device_tables(engine).unwrap_or_default(); + for (object_index, components) in geometry.iter().enumerate() { + if !components + .iter() + .flatten() + .any(|component| !component.damage_stages.is_empty()) + { + continue; + } + let rows = tables + .iter() + .find(|table| { + table + .original_id + .is_some_and(|id| id.0 as usize == object_index) + }) + .and_then(|table| match &table.node_provider_status { + MissionControlNodeProviderTableStatus::Available(rows) => Some(rows.as_slice()), + MissionControlNodeProviderTableStatus::Unavailable(_) => None, + }) + .unwrap_or_default(); + for (component_index, component) in components.iter().enumerate() { + let Some(component) = component else { + continue; + }; + for variant in &component.damage_stages { + let active = rows + .iter() + .find(|row| { + row.unit_component_index == component_index + && row.source_row_index == variant.node + }) + .and_then(|row| row.mesh_state) + .map_or(0, |state| state.visible_stage); + if u32::from(variant.stage) != active { + hidden.extend(variant.ranges.clone()); + } + } + } + } + hidden +} pub(super) fn apply( engine: &Engine, -- cgit v1.2.3