diff options
| author | Valentin Popov <valentin@popov.link> | 2026-12-01 09:01:42 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-12-01 09:01:42 +0300 |
| commit | 45262e52841f23f956de8937b933ff5e59ffa94e (patch) | |
| tree | ae6a6fa5158ef54fb086fb618b8bdcb5da89dd8f /apps/fparkan-game/src/damage_visibility.rs | |
| parent | 0224286b0277d63f320f30df8bd2887ac596d207 (diff) | |
| download | fparkan-45262e52841f23f956de8937b933ff5e59ffa94e.tar.xz fparkan-45262e52841f23f956de8937b933ff5e59ffa94e.zip | |
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.
Diffstat (limited to 'apps/fparkan-game/src/damage_visibility.rs')
| -rw-r--r-- | apps/fparkan-game/src/damage_visibility.rs | 52 |
1 files changed, 32 insertions, 20 deletions
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<Option<DynamicComponentGeometry>>], @@ -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()); } |
