From 54b6e83f62fe52b221dcb7eebff245e9d5b39305 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Thu, 26 Nov 2026 13:25:10 +0400 Subject: fix(player): drown on first supported step into water Carry the terrain surface flags through the walking collision decision. A mesh floor over water remains safe. The first accepted wet step removes the hero and produces the normal mission failure event. Verified the surface flag in the original Control DLL and walked from the stock Constructor spawn to the lake in the Vulkan window. --- crates/fparkan-terrain/src/lib.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'crates/fparkan-terrain') diff --git a/crates/fparkan-terrain/src/lib.rs b/crates/fparkan-terrain/src/lib.rs index 33d7dfe9..022b937d 100644 --- a/crates/fparkan-terrain/src/lib.rs +++ b/crates/fparkan-terrain/src/lib.rs @@ -552,8 +552,12 @@ impl TerrainWorld { } } -impl SurfaceQuery for TerrainWorld { - fn height_at(&self, position: [f32; 2]) -> Result, TerrainError> { +impl TerrainWorld { + /// Returns the highest terrain surface and its authored flags at this XY. + pub fn support_at( + &self, + position: [f32; 2], + ) -> Result, TerrainError> { if self.surfaces.is_empty() { return Err(TerrainError::Unsupported); } @@ -561,11 +565,20 @@ impl SurfaceQuery for TerrainWorld { for index in self.surface_bvh.xy_candidates(position) { let triangle = &self.surfaces[index]; if let Some(height) = triangle.height_at(position) { - best = Some(best.map_or(height, |current: f32| current.max(height))); + best = Some(match best { + Some((current, mask)) if current >= height => (height.max(current), mask), + _ => (height, triangle.mask), + }); } } Ok(best) } +} + +impl SurfaceQuery for TerrainWorld { + fn height_at(&self, position: [f32; 2]) -> Result, TerrainError> { + Ok(self.support_at(position)?.map(|(height, _)| height)) + } fn raycast( &self, -- cgit v1.2.3