Skip to content

fix: improve coastal worldgen surfaces#681

Merged
github-actions[bot] merged 2 commits into
devfrom
opencode/lucky-wolf
May 3, 2026
Merged

fix: improve coastal worldgen surfaces#681
github-actions[bot] merged 2 commits into
devfrom
opencode/lucky-wolf

Conversation

@MichaelFisher1997
Copy link
Copy Markdown
Collaborator

Summary

  • Blend nearby biome terrain modifiers to reduce hard coastline and biome-transition height seams.
  • Use registry-backed biome surfaces for close chunks and LOD/classification so beach, tropical, and coastal materials stay consistent.
  • Retune coastal height and surface placement tests to prevent broad sand slabs, rectangular transition bands, and painted grass-side artifacts.

Tests

  • nix develop --command zig build test

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label May 3, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 3, 2026

📋 Summary

No linked issues found in the PR description. The PR implements coastal worldgen improvements: blending biome terrain modifiers, using registry-backed biome surfaces, and retuning coastal height/surface placement to eliminate hard transitions and artificial sand/gravel slabs.

📌 Review Metadata

The PR retunes coastal generation to reduce hard biome boundaries, replaces auto-painted cliffs/gravel with biome-aware surfaces, fixes grass side-face tinting in the mesher, and adds blended terrain modifiers sampled from neighboring positions. Tests pass and formatting is clean.

🔴 Critical Issues (Must Fix - Blocks Merge)

None identified.

⚠️ High Priority Issues (Should Fix)

None identified.

💡 Medium Priority Issues (Nice to Fix)

[MEDIUM] modules/world-worldgen/src/terrain_shape_generator.zig:204 - Redundant biome sampling in sampleBlendedTerrainModifier
Confidence: High
Description: sampleBlendedTerrainModifier performs 9 column samples + biome selections per column, but neighboring columns in the same chunk overlap significantly in their sample neighborhoods. For a 16x16 chunk this means ~2304 column evaluations instead of ~81 unique positions.
Impact: Chunk generation performance regression, especially in worker threads.
Suggested Fix: Cache blended terrain modifiers in a slightly enlarged grid (e.g., 20x20 covering the chunk plus influence radius) before the main column loop, then reuse cached values.

[MEDIUM] modules/world-worldgen/src/terrain_shape_generator.zig:136 - hasNearbyOceanWater performs out-of-chunk column sampling synchronously
Confidence: Medium
Description: For each of the 256 chunk columns, this function may call sampleColumnDataWithControlsAndTerrainModifier on out-of-chunk positions to check for ocean water. This adds extra noise sampling cost on the hot path.
Impact: Additional chunk generation overhead for coastal chunks.
Suggested Fix: Consider sampling ocean water flags from the chunk's edge neighbor data if available, or precomputing an ocean proximity mask at a coarser resolution.

ℹ️ Low Priority Suggestions (Optional)

[LOW] modules/world-meshing/src/meshing/greedy_mesher.zig:101 - Unreachable else branch in face switch
Confidence: High
Description: The switch on axis for determining face includes .top, .east, .south and an else => return error.UnsupportedFace. However, meshSlice already guards against unsupported axes at line 62.
Impact: Dead code / unnecessary error path.
Suggested Fix: Remove the else branch since it's unreachable, or assert with unreachable instead.

[LOW] modules/world-worldgen/src/height_sampler.zig:304 - Magic number in coastal detail calculation
Confidence: Low
Description: The value 0.45 in coastal_detail_factor = coastal_ramp * (1.0 - land_factor) * 0.45 lacks a named constant.
Impact: Reduced readability.
Suggested Fix: Extract to a named constant like coastal_detail_blend_weight.

[LOW] modules/world-worldgen/src/terrain_shape_generator.zig:260 - Magic threshold in clamp blending
Confidence: Low
Description: The threshold 0.65 for clamp_to_sea_level blending is inconsistent with TerrainModifier.blend which uses 0.5.
Impact: Slight maintainability concern; unclear why different thresholds are used.
Suggested Fix: Document why spatial blending uses 0.65 instead of 0.5, or unify the thresholds.

📊 SOLID Principles Score

Principle Score Notes
Single Responsibility 8 Generation, meshing, and registry concerns are well-separated.
Open/Closed 7 Registry-based surfaces improve extensibility over hardcoded switches.
Liskov Substitution 8 Biome registry changes don't break existing interfaces.
Interface Segregation 8 Clean separation between color sampling, height sampling, and surface building.
Dependency Inversion 7 Overworld generator now depends on registry abstractions rather than hardcoded biome logic.
Average 7.6

🎯 Final Assessment

Overall Confidence Score: 85%

How to interpret: 81-100%: High confidence, ready to merge or with trivial fixes

Confidence Breakdown:

  • Code Quality: 85% (Clean, well-tested, addresses the stated goals)
  • Completeness: 90% (Fully implements coastal smoothing and registry-backed surfaces)
  • Risk Level: 75% (Terrain changes affect world fingerprints; moderate performance regression possible)
  • Test Coverage: 85% (Tests updated for new behavior; new tests added for blending)

Merge Readiness:

  • All critical issues resolved
  • SOLID average score >= 6.0
  • Overall confidence >= 60%
  • No security concerns
  • Tests present and passing

Verdict:

MERGE WITH FIXES - The medium priority performance concerns should be addressed or at least benchmarked before merging to ensure chunk generation doesn't regress significantly.

{
  "reviewed_sha": "2edf806878d6294c06b0e905be50326f9515df27",
  "critical_issues": 0,
  "high_priority_issues": 0,
  "medium_priority_issues": 2,
  "overall_confidence_score": 85,
  "recommendation": "MERGE WITH FIXES"
}

New%20session%20-%202026-05-03T04%3A13%3A59.883Z
opencode session  |  github run

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 3, 2026

📋 Summary

No linked issues found in the PR description. The PR improves coastal worldgen surfaces by blending biome terrain modifiers, switching to registry-backed biome surfaces, and retuning coastal height/surface placement to eliminate hard transitions, artificial sand slabs, and grass-side tinting artifacts.

📌 Review Metadata

The PR addresses all feedback from the previous automated review: terrain modifier caching eliminates redundant biome sampling, ocean proximity is precomputed in a grid to avoid per-column out-of-chunk sampling, magic numbers are now named constants, and unreachable branches use unreachable. Tests pass and code is well-formatted.

🔴 Critical Issues (Must Fix - Blocks Merge)

None identified.

⚠️ High Priority Issues (Should Fix)

None identified.

💡 Medium Priority Issues (Nice to Fix)

None identified.

[FIXED] Previous issue: Redundant biome sampling in sampleBlendedTerrainModifier — Now precomputes terrain_modifier_cache in a 32×32 grid and reuses cached values per column (terrain_shape_generator.zig).

[FIXED] Previous issue: hasNearbyOceanWater performed out-of-chunk column sampling synchronously per column — Now precomputes ocean_grid once per chunk; hasNearbyOceanWater only reads cached booleans (terrain_shape_generator.zig).

ℹ️ Low Priority Suggestions (Optional)

None identified.

[FIXED] Previous issue: Unreachable else branch in greedy mesher face switch — Now uses else => unreachable (greedy_mesher.zig:105).

[FIXED] Previous issue: Magic number 0.45 in coastal detail calculation — Now named COASTAL_DETAIL_BLEND_WEIGHT (height_sampler.zig).

[FIXED] Previous issue: Magic threshold 0.65 in clamp blending — Now named CLAMP_TO_SEA_LEVEL_BLEND_THRESHOLD (terrain_shape_generator.zig:34).

📊 SOLID Principles Score

Principle Score Notes
Single Responsibility 8 Generation, meshing, and registry concerns remain well-separated.
Open/Closed 7 Registry-backed surfaces improve extensibility over hardcoded switches.
Liskov Substitution 8 Biome registry changes don't break existing interfaces.
Interface Segregation 8 Clean separation between color sampling, height sampling, and surface building.
Dependency Inversion 7 Overworld generator depends on registry abstractions rather than hardcoded biome logic.
Average 7.6

🎯 Final Assessment

Overall Confidence Score: 90%

How to interpret: 81-100%: High confidence, ready to merge or with trivial fixes

Confidence Breakdown:

  • Code Quality: 90% (Clean, addresses prior review feedback, good caching strategy)
  • Completeness: 90% (Fully implements coastal smoothing and registry-backed surfaces)
  • Risk Level: 85% (Terrain fingerprint changes are expected and tested; caching reduces performance risk)
  • Test Coverage: 90% (Tests updated for new behavior; new blending and height tests added)

Merge Readiness:

  • All critical issues resolved
  • SOLID average score >= 6.0
  • Overall confidence >= 60%
  • No security concerns
  • Tests present and passing

Verdict:

MERGE — All previous review issues have been resolved, tests pass, and the caching improvements effectively address performance concerns.

{
  "reviewed_sha": "8ee5f49a14d72053b2bd6682b88748e7c98406fb",
  "critical_issues": 0,
  "high_priority_issues": 0,
  "medium_priority_issues": 0,
  "overall_confidence_score": 90,
  "recommendation": "MERGE"
}

New%20session%20-%202026-05-03T04%3A25%3A15.511Z
opencode session  |  github run

@github-actions github-actions Bot merged commit 3fc9502 into dev May 3, 2026
8 checks passed
@MichaelFisher1997 MichaelFisher1997 deleted the opencode/lucky-wolf branch May 3, 2026 04:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant