fix: set water elevation during map generation to prevent depth issues#1348
Conversation
Root cause: Water cells were inheriting elevation from the underlying terrain grid, causing water to render at varying heights instead of at a consistent water surface level. Fix: - Add ELEVATION.WATER (20) constant for water surface level - Both deep AND shallow water use the same surface elevation (deep vs shallow refers to depth BELOW the surface, not surface height) - Modify paintFeatureCircle() and paintFeatureRect() to set water cells to ELEVATION.WATER Water surface is always level - that's how water works. https://claude.ai/code/session_01CEq99bYXB2fmcaLE6H46Sz
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 426236f3bd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // Set water elevation - water surface is always level | ||
| if (isWater) { | ||
| grid.elevation[y][x] = ELEVATION.WATER; | ||
| } |
There was a problem hiding this comment.
Avoid shoreline cliffs from fixed water elevation
Setting water cells to ELEVATION.WATER (20) makes the elevation difference to normal ground (ELEVATION.LOW = 60) exactly CLIFF_THRESHOLD (40 in src/data/pathfinding.config.ts). Because isCliffCell flags any diff ≥ threshold, any land (or shallow-water) cell adjacent to water now becomes a cliff and therefore unwalkable. This makes shores impassable on maps where water meets low ground, which is a regression from the previous behavior where water inherited the surrounding elevation. Consider excluding water neighbors from cliff checks or choosing a water elevation that doesn’t trip the threshold.
Useful? React with 👍 / 👎.
426236f to
f34b462
Compare
…hallow AI water generation improvements: - Enhanced system prompt with detailed water layering instructions - Water bodies should be created in layers: shallow first (larger), deep on top (smaller) - This creates natural shorelines where shallow water surrounds deep water - Added concrete examples for lakes and rivers - Updated user prompt with step-by-step water creation guidance Rendering fix: - Remove 0.02 height offset between deep and shallow water - All water now renders at the exact same height (water surface is level) - This eliminates the visible gap/seam between deep and shallow regions https://claude.ai/code/session_01CEq99bYXB2fmcaLE6H46Sz
ELEVATION.WATER was 20, making the difference from LOW (60) exactly equal to CLIFF_THRESHOLD (40). This caused all shorelines to be detected as cliffs, making them unwalkable. Changed ELEVATION.WATER from 20 to 25: - Difference from LOW is now 35, which is < CLIFF_THRESHOLD (40) - Shorelines are no longer flagged as cliffs - Water still renders below ground level as expected https://claude.ai/code/session_01CEq99bYXB2fmcaLE6H46Sz
Root cause: Water cells were inheriting elevation from the underlying terrain grid, causing water to render at varying heights instead of at a consistent water surface level.
Fix:
Water surface is always level - that's how water works.
https://claude.ai/code/session_01CEq99bYXB2fmcaLE6H46Sz