diff options
| author | Valentin Popov <valentin@popov.link> | 2026-11-26 12:25:10 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-11-26 12:25:10 +0300 |
| commit | 54b6e83f62fe52b221dcb7eebff245e9d5b39305 (patch) | |
| tree | bacae515b98f0774e185a3777d4157fa22cc9c41 /crates/fparkan-terrain | |
| parent | 8153f1d085c17a633bda68acb4cc01bbbc279615 (diff) | |
| download | fparkan-54b6e83f62fe52b221dcb7eebff245e9d5b39305.tar.xz fparkan-54b6e83f62fe52b221dcb7eebff245e9d5b39305.zip | |
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.
Diffstat (limited to 'crates/fparkan-terrain')
| -rw-r--r-- | crates/fparkan-terrain/src/lib.rs | 19 |
1 files changed, 16 insertions, 3 deletions
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<Option<f32>, TerrainError> { +impl TerrainWorld { + /// Returns the highest terrain surface and its authored flags at this XY. + pub fn support_at( + &self, + position: [f32; 2], + ) -> Result<Option<(f32, FullSurfaceMask)>, 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<Option<f32>, TerrainError> { + Ok(self.support_at(position)?.map(|(height, _)| height)) + } fn raycast( &self, |
