From 45262e52841f23f956de8937b933ff5e59ffa94e Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Tue, 1 Dec 2026 10:01:42 +0400 Subject: fix(movement): use visible building stages for collision Share building stage selection with the renderer and query the current slot for floor and wall contacts. Verify the same floor probe against the intact and damaged factory in a validated stock mission window. --- apps/fparkan-game/src/damage_visibility.rs | 52 ++++++++++++++++++------------ 1 file changed, 32 insertions(+), 20 deletions(-) (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 fe462da1..46940213 100644 --- a/apps/fparkan-game/src/damage_visibility.rs +++ b/apps/fparkan-game/src/damage_visibility.rs @@ -6,10 +6,40 @@ use fparkan_msh::{draw_batches, selected_slot, Group, Lod, NodeId}; use fparkan_render_vulkan::{VulkanSmokeRenderer, VulkanStaticMesh}; use fparkan_runtime::{ depleted_warbot_nodes, loaded_mission_control_device_tables, Engine, + MissionControlDeviceTableState, MissionControlNodeProviderRow, MissionControlNodeProviderTableStatus, }; use std::collections::HashSet; +pub(super) fn building_provider_rows( + tables: &[MissionControlDeviceTableState], + object_index: usize, +) -> &[MissionControlNodeProviderRow] { + 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() +} + +pub(super) fn visible_node_stage( + rows: &[MissionControlNodeProviderRow], + component_index: usize, + node: usize, +) -> u32 { + rows.iter() + .find(|row| row.unit_component_index == component_index && row.source_row_index == node) + .and_then(|row| row.mesh_state) + .map_or(0, |state| state.visible_stage) +} + pub(super) fn inactive_building_ranges( engine: &Engine, geometry: &[Vec>], @@ -24,31 +54,13 @@ pub(super) fn inactive_building_ranges( { 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(); + let rows = building_provider_rows(tables, object_index); 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); + let active = visible_node_stage(rows, component_index, variant.node); if u32::from(variant.stage) != active { hidden.extend(variant.ranges.clone()); } -- cgit v1.2.3