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. --- apps/fparkan-game/src/player_collision.rs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'apps/fparkan-game/src') diff --git a/apps/fparkan-game/src/player_collision.rs b/apps/fparkan-game/src/player_collision.rs index 57f29754..c74a8ec8 100644 --- a/apps/fparkan-game/src/player_collision.rs +++ b/apps/fparkan-game/src/player_collision.rs @@ -1,5 +1,4 @@ use super::StaticVulkanApp; -use fparkan_terrain::SurfaceQuery; impl StaticVulkanApp { pub(super) fn resolve_player_building_step( @@ -9,13 +8,13 @@ impl StaticVulkanApp { if let Some(probe) = step.floor_probe() { let crossing_cut = if self.terrain.basement_foundation().is_some() { let [start, end] = step.sweep.expect("walking floor probe"); - let height = |[x, y, _]: [f32; 3]| { + let support = |[x, y, _]: [f32; 3]| { self.terrain - .height_at([x, y]) + .support_at([x, y]) .map_err(|err| err.to_string()) }; - let previous = height(start)?; - let next = height(end)?; + let previous = support(start)?.map(|(height, _)| height); + let next = support(end)?; step = step.with_scene_terrain(previous, next); previous.is_none() || next.is_none() } else { @@ -35,20 +34,24 @@ impl StaticVulkanApp { } else { None }; - let mut floor = mesh_floor; + let mut floor = mesh_floor.map(|height| (height, false)); if let Some(height) = terrain_exit { - if floor.is_none_or(|mesh| mesh < height) + if mesh_floor.is_none_or(|mesh| mesh < height) && (crossing_cut || previous_mesh.is_some()) && !self.building_segment_blocked([ [probe[0][0], probe[0][1], height + 0.02], probe[0], ])? { - floor = Some(height); + floor = Some((height, true)); } } - if let Some(height) = floor { - step = step.with_building_floor(height, previous_mesh); + if let Some((height, terrain)) = floor { + step = if terrain { + step.with_terrain_floor(height, previous_mesh) + } else { + step.with_building_floor(height, previous_mesh) + }; if let Some(segments) = step.floor_sweeps() { for segment in segments.into_iter().filter(|[from, to]| from != to) { if self.building_segment_blocked(segment)? { -- cgit v1.2.3