diff options
| author | Valentin Popov <valentin@popov.link> | 2026-11-26 16:00:14 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-11-26 16:00:14 +0300 |
| commit | c568357edf3c651ca0e16af27491be28ab1e0262 (patch) | |
| tree | 58d8e825a45b2db77dc739930c0e815168876d92 /crates/fparkan-runtime/src/basement_geometry.rs | |
| parent | bd9d7926768296ebad9f64550ede7cd840e6e5c8 (diff) | |
| download | fparkan-c568357edf3c651ca0e16af27491be28ab1e0262.tar.xz fparkan-c568357edf3c651ca0e16af27491be28ab1e0262.zip | |
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.
Diffstat (limited to 'crates/fparkan-runtime/src/basement_geometry.rs')
| -rw-r--r-- | crates/fparkan-runtime/src/basement_geometry.rs | 27 |
1 files changed, 27 insertions, 0 deletions
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 { |
