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 /apps/fparkan-game/src | |
| 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 'apps/fparkan-game/src')
| -rw-r--r-- | apps/fparkan-game/src/player_collision.rs | 23 |
1 files changed, 13 insertions, 10 deletions
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)? { |
