From d2a9f21927fd20c15f02bcf4af791f18c309b072 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 2 Dec 2026 10:04:16 +0400 Subject: fix(ui): clear building roofs with the strategic camera --- apps/fparkan-game/src/strategic_view.rs | 13 +++++++++---- crates/fparkan-runtime/src/strategic_view.rs | 28 +++++++++++++++++++++++----- docs/appendices/knowledge-boundaries.md | 4 ++-- docs/appendices/ui-shell.md | 7 +++++++ 4 files changed, 41 insertions(+), 11 deletions(-) diff --git a/apps/fparkan-game/src/strategic_view.rs b/apps/fparkan-game/src/strategic_view.rs index aef1a5d5..7c9ada0a 100644 --- a/apps/fparkan-game/src/strategic_view.rs +++ b/apps/fparkan-game/src/strategic_view.rs @@ -22,9 +22,6 @@ impl StaticVulkanApp { let Some(post) = command_post(engine, cockpit) else { return false; }; - if command_view(engine, post).is_none() { - return false; - } self.command_view = Some(ActiveCommandView { post, pointer_button: None, @@ -52,7 +49,15 @@ impl StaticVulkanApp { let frame = self .mission_engine .as_ref() - .and_then(|engine| command_view(engine, post)) + .and_then(|engine| { + command_view(engine, post, |segment| { + self.building_segment_hit(segment, true) + .inspect_err(|error| eprintln!("strategic camera height: {error}")) + .ok() + .flatten() + .map(|hit| hit[2]) + }) + }) .and_then(|transform| { PreviewCameraFrame::from_legacy_d3d7( transform, diff --git a/crates/fparkan-runtime/src/strategic_view.rs b/crates/fparkan-runtime/src/strategic_view.rs index b22555f6..81d822eb 100644 --- a/crates/fparkan-runtime/src/strategic_view.rs +++ b/crates/fparkan-runtime/src/strategic_view.rs @@ -76,8 +76,13 @@ fn has_command_link(devices: &[crate::EffectiveControlDevice]) -> bool { } /// Initial external viewpoint of a command post, sampled from the current world. +/// `building_height` returns the highest building hit on the downward segment. #[must_use] -pub fn command_view(engine: &Engine, post: CommandPost) -> Option { +pub fn command_view( + engine: &Engine, + post: CommandPost, + building_height: impl FnOnce([[f32; 3]; 2]) -> Option, +) -> Option { let (handle, clearance) = match post { CommandPost::Bunker(handle) => (handle, 36.0), CommandPost::Warbot(handle) => (handle, 2.5), @@ -87,11 +92,15 @@ pub fn command_view(engine: &Engine, post: CommandPost) -> Option