From c568357edf3c651ca0e16af27491be28ab1e0262 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Thu, 26 Nov 2026 17:00:14 +0400 Subject: fix(terrain): cut basements when scripted buildings finish Use the authored footprint to rebuild the window terrain, floor support and shadow receivers together. Keep terrain draw slots stable across the rebuild, and publish the corrected building height in the construction frame. Verified in a stock Single.02 window with Vulkan validation while the clan built a plant. Headless terrain and native overlap and removal semantics remain open. --- crates/fparkan-runtime/src/basement_geometry.rs | 27 +++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'crates/fparkan-runtime/src/basement_geometry.rs') diff --git a/crates/fparkan-runtime/src/basement_geometry.rs b/crates/fparkan-runtime/src/basement_geometry.rs index 7d373874..c8b274b9 100644 --- a/crates/fparkan-runtime/src/basement_geometry.rs +++ b/crates/fparkan-runtime/src/basement_geometry.rs @@ -1,6 +1,33 @@ use crate::{BasementPlacementMode, MissionAssets, MissionObjectDraft}; use fparkan_render::LegacyIron3dEulerTransform; use fparkan_terrain::BasementFootprint; +use fparkan_world::{set_transform, transform_state, world_snapshot}; + +/// Places a newly completed building at its absolute foundation elevation. +/// +/// The construction frame is refreshed so draw, collision, and script +/// consumers use a single root position. +/// +/// # Errors +/// +/// Rejects a missing building or an invalid elevation. +pub fn place_constructed_basement( + engine: &mut crate::Engine, + frame: &mut crate::FrameResult, + building: crate::SpawnedUnit, + elevation: f32, +) -> Result<(), crate::EngineError> { + if !frame.constructed_buildings.contains(&building) || !elevation.is_finite() { + return Err(crate::EngineError::Movement( + "invalid placement for constructed basement".into(), + )); + } + let mut pose = transform_state(&engine.world, building.handle)?; + pose.position[2] = elevation.to_bits(); + set_transform(&mut engine.world, building.handle, pose)?; + frame.snapshot = world_snapshot(&engine.world, std::mem::take(&mut frame.snapshot.events)); + Ok(()) +} /// One eligible building's authored contours projected into the mission. pub struct MissionBasementFootprint { -- cgit v1.2.3