Skip to content

feat: add overworld v2 generator#684

Merged
github-actions[bot] merged 4 commits into
devfrom
opencode/sunny-planet
May 3, 2026
Merged

feat: add overworld v2 generator#684
github-actions[bot] merged 4 commits into
devfrom
opencode/sunny-planet

Conversation

@MichaelFisher1997
Copy link
Copy Markdown
Collaborator

Summary

  • Add a standalone Luanti v7-inspired overworld-v2 generator with terrain, caves, biome surfaces, trees, and vegetation.
  • Register zigcraft:overworld-v2 with aliases and build integration.
  • Improve distant LOD terrain quality and add texture mappings for new aquatic vegetation/coral blocks.

Verification

  • nix develop --command zig build test -- --test-filter "overworld-v2"
  • nix develop --command zig build test -- --test-filter "LOD"
  • nix develop --command zig build test -- --test-filter "Texture"
  • nix develop --command zig build -Dskip-present
  • nix develop --command zig build test

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

github-actions Bot commented May 3, 2026

📋 Summary

No linked issues are mentioned in the PR description.

This PR adds a new Luanti v7-inspired overworld-v2 world generator with terrain, caves, rivers, biomes, trees, and vegetation. It also modifies LOD grid sizes, improves LOD normal calculation, adds texture mappings for aquatic blocks, and includes unit tests. The code is well-structured and deterministic, but the LOD mesh changes contain a visual regression that contradicts the stated quality improvement goal.

📌 Review Metadata

🔴 Critical Issues (Must Fix - Blocks Merge)

None identified.

⚠️ High Priority Issues (Should Fix)

[HIGH] modules/world-lod/src/lod_mesh.zig:231 - addHeightDeltaFaces call removed without replacement
Confidence: High
Description: The call to addHeightDeltaFaces was removed from LODMesh.build, eliminating vertical faces between adjacent LOD cells with significant height differences. This creates visible gaps/holes in the LOD mesh when neighboring cells have different terrain heights (e.g., cliffs).
Impact: Visual regression in distant terrain; players can see through the mesh at height discontinuities. This directly contradicts the PR's stated goal of improving LOD terrain quality.
Suggested Fix: Restore the addHeightDeltaFaces call after addSideFaceQuad calls in the meshing loop, or implement equivalent gap-filling geometry.

[HIGH] modules/world-lod/src/lod_mesh.zig:743 - shouldRenderLODTree ignores lod_level parameter
Confidence: High
Description: The function now discards the lod_level parameter (_ = lod_level;) and renders trees at all LOD levels, including lod0 and lod1 which are closer to the camera and already covered by regular chunk meshes.
Impact: Unnecessary vertex count increase at closer LOD distances. lod1 now has ~4000 quads and would additionally render tree impostors, significantly increasing GPU load without visual benefit.
Suggested Fix: Restore the lod_level gate: if (@intFromEnum(lod_level) < @intFromEnum(LODLevel.lod2)) return false;

[HIGH] modules/world-core/src/lod_data.zig:84-98 - LOD1 grid size is excessively dense
Confidence: Medium
Description: The new getGridSize sets lod1 to 64 points for a 64-block region, yielding ~1 block per cell (3969 quads). This is finer than the old lod0 density and comparable to regular chunk rendering, defeating the performance purpose of LOD meshing.
Impact: lod1 meshes may have similar or higher vertex counts than the regular chunks they're meant to replace, causing performance degradation.
Suggested Fix: Reduce lod1 grid size to 32 or lower to maintain a sensible LOD density ladder (e.g., lod0=16, lod1=32, lod2=48, lod3=48).

💡 Medium Priority Issues (Nice to Fix)

[MEDIUM] modules/worldgen-overworld-v2/src/root.zig:1208 - setTreeBlock leaves_only parameter is semantically ineffective
Confidence: High
Description: Both branches of the leaves_only check evaluate the exact same condition, making the parameter have no effect on behavior.
Impact: Latent defect; if the function is ever used to place trunks through existing blocks (not just air), the behavior will be incorrect.
Suggested Fix: Make leaves_only = false allow overwriting any block, while leaves_only = true restricts to air/leaves only.

[MEDIUM] modules/worldgen-overworld-v2/src/root.zig:1194-1195 - Potential overflow in tree canopy placement
Confidence: Low
Description: placeFlatCanopy passes cy (u32) through @intCast(cy) to setTreeBlockOffset which takes y: i32. For cy values near CHUNK_SIZE_Y, this could overflow if cy + 1 exceeds bounds, though the caller checks if (y + height + 1 >= CHUNK_SIZE_Y) return;.
Impact: Low risk due to caller bounds check, but inconsistent type signatures between canopy placement functions (placeRoundCanopy takes cy: u32, placeConeLeaves takes base_y: u32, but setTreeBlockOffset takes y: i32).
Suggested Fix: Unify parameter types or add explicit bounds checks in all canopy functions.

ℹ️ Low Priority Suggestions (Optional)

[LOW] modules/world-lod/src/lod_mesh.zig:794 - Dead code: addHeightDeltaFaces is defined but never called
Confidence: High
Description: After its call site was removed, addHeightDeltaFaces remains as dead code in the file.
Suggested Fix: Remove the unused function to reduce maintenance burden.

[LOW] modules/worldgen-overworld-v2/src/root.zig:478 - deinit is a no-op stub
Confidence: Medium
Description: OverworldV2Generator.deinit does nothing. Currently harmless since the struct has no heap-allocated fields, but future additions could leak memory.
Suggested Fix: Either document that the generator owns no allocations, or add a comment explaining why deinit is empty.

📊 SOLID Principles Score

Principle Score Notes
Single Responsibility 8 Generator is self-contained; noise, biome, surface, and decoration logic are separated into focused functions.
Open/Closed 7 New generator extends the registry without modifying existing generators. LOD mesh changes modify existing behavior.
Liskov Substitution 8 Implements the same Generator VTable interface as other generators.
Interface Segregation 8 Uses the existing worldgen-api contracts appropriately.
Dependency Inversion 8 Depends on abstractions (worldgen-api, world-core) rather than concrete modules.
Average 7.8

🎯 Final Assessment

Overall Confidence Score: 72%

Confidence Breakdown:

  • Code Quality: 75% (Clean generator structure, but LOD mesh regression and dead code)
  • Completeness: 85% (New generator is feature-complete with tests, but LOD gap-filling was removed)
  • Risk Level: 55% (LOD visual regression and potential performance impact from dense grids/tree rendering)
  • Test Coverage: 80% (Good tests for new generator, but no visual/LOD mesh regression tests)

Merge Readiness:

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

Verdict:

MERGE WITH FIXES

The new generator is solid and well-tested, but the LOD mesh changes introduce a visual regression by removing addHeightDeltaFaces. The dense lod1 grid and unconditional tree rendering also raise performance concerns. These should be addressed before merging.

{
  "reviewed_sha": "9e60f6da0918f24c7894f817fde79291f1350674",
  "critical_issues": 0,
  "high_priority_issues": 3,
  "medium_priority_issues": 2,
  "overall_confidence_score": 72,
  "recommendation": "MERGE WITH FIXES"
}

New%20session%20-%202026-05-03T09%3A44%3A39.775Z
opencode session  |  github run

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 3, 2026

📋 Summary

No linked issues are mentioned in the PR description.

This PR adds a new Luanti v7-inspired overworld-v2 world generator with terrain, caves, rivers, biomes, trees, and vegetation. It also improves LOD mesh normal calculation (per-vertex smooth normals), adjusts LOD grid sizes for more uniform cell spacing, adds texture mappings for aquatic blocks, and includes unit tests. The second commit addresses feedback from the initial automated review.

📌 Review Metadata

The implementation is well-structured and deterministic. The new generator follows the existing worldgen-api contracts, has good test coverage, and all tests pass. The LOD mesh changes are intentional improvements, not regressions.

🔴 Critical Issues (Must Fix - Blocks Merge)

None identified.

⚠️ High Priority Issues (Should Fix)

None identified.

[FIXED] All previously reported high priority issues have been resolved:

  • shouldRenderLODTree now correctly gates tree rendering to lod2 and beyond
  • LOD1 grid size reduced from 64 to 32 for sensible density
  • addHeightDeltaFaces removal is an intentional design decision (heightmap cells share edge vertices, so internal vertical walls are unnecessary). The author added a clarifying comment.

💡 Medium Priority Issues (Nice to Fix)

[MEDIUM] modules/worldgen-overworld-v2/src/root.zig:1190-1200 - Type inconsistency in tree canopy placement
Confidence: Low
Description: placeFlatCanopy receives cy: u32 and passes @intCast(cy) to setTreeBlockOffset(y: i32), which then casts back to u32 for setTreeBlock. Similarly, placeConeLeaves passes @intCast(cy) where cy is computed from base_y + layer. While caller bounds checks (if (y + height + 1 >= CHUNK_SIZE_Y) return;) prevent actual overflow, the inconsistent signatures between canopy functions and setTreeBlock/setTreeBlockOffset create a latent maintenance hazard.
Impact: Very low risk due to existing bounds checks, but could lead to subtle bugs if future refactors relax those checks.
Suggested Fix: Unify the tree placement functions to use i32 for y-coordinates throughout, or add explicit std.math.cast bounds assertions in setTreeBlockOffset.

ℹ️ Low Priority Suggestions (Optional)

[LOW] modules/worldgen-overworld-v2/src/root.zig:849-856 - highestSolidY scans full chunk height unnecessarily
Confidence: Medium
Description: highestSolidY iterates from CHUNK_SIZE_Y - 1 down to 0 for every column. However, estimateGroundedTerrainHeight already computes the top solid y during terrain generation. Re-scanning adds O(CHUNK_SIZE_Y) work per column.
Impact: Minor performance overhead during chunk generation.
Suggested Fix: Reuse the terrain height computed during estimateGroundedTerrainHeight instead of re-scanning the column.

📊 SOLID Principles Score

Principle Score Notes
Single Responsibility 8 Generator is self-contained; noise, biome, surface, and decoration logic are separated into focused functions.
Open/Closed 7 New generator extends the registry without modifying existing generators. LOD mesh changes modify existing behavior.
Liskov Substitution 8 Implements the same Generator VTable interface as other generators.
Interface Segregation 8 Uses the existing worldgen-api contracts appropriately.
Dependency Inversion 8 Depends on abstractions (worldgen-api, world-core) rather than concrete modules.
Average 7.8

🎯 Final Assessment

Overall Confidence Score: 85%

Confidence Breakdown:

  • Code Quality: 85% (Clean generator structure, good normal calculation for LOD, proper memory lifecycle)
  • Completeness: 90% (New generator is feature-complete with tests, LOD improvements are intentional)
  • Risk Level: 75% (LOD mesh changes are well-reasoned; minor type inconsistency in tree code)
  • Test Coverage: 85% (Good tests for new generator and registry integration)

Merge Readiness:

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

Verdict:

MERGE

The PR is well-structured and ready to merge. All previously reported issues have been addressed. The remaining medium-priority item is a low-risk type inconsistency mitigated by existing bounds checks.

{
  "reviewed_sha": "a2f428ac880552ab9dcd87c6e12c673675d94506",
  "critical_issues": 0,
  "high_priority_issues": 0,
  "medium_priority_issues": 1,
  "overall_confidence_score": 85,
  "recommendation": "MERGE"
}

New%20session%20-%202026-05-03T15%3A35%3A06.540Z
opencode session  |  github run

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 3, 2026

📋 Summary

No linked issues are mentioned in the PR description.

This PR adds a new Luanti v7-inspired overworld-v2 world generator with terrain, caves, rivers, biomes, trees, and vegetation. It also improves LOD mesh normal calculation, adjusts LOD grid sizes, adds texture mappings for aquatic blocks, and includes unit tests. The code is well-structured and deterministic, and all previously reported high-priority issues have been resolved.

📌 Review Metadata

🔴 Critical Issues (Must Fix - Blocks Merge)

None identified.

⚠️ High Priority Issues (Should Fix)

None identified.

[FIXED] All previously reported high priority issues have been resolved:

  • addHeightDeltaFaces removal is an intentional design decision (heightmap cells share edge vertices, internal vertical walls are unnecessary). Clarifying comment added at modules/world-lod/src/lod_mesh.zig:239-240.
  • shouldRenderLODTree now correctly gates tree rendering to lod2 and beyond (modules/world-lod/src/lod_mesh.zig:748).
  • LOD1 grid size reduced from 64 to 32 for sensible density (modules/world-core/src/lod_data.zig:86).

💡 Medium Priority Issues (Nice to Fix)

[MEDIUM] modules/worldgen-overworld-v2/src/root.zig:1210 - setTreeBlock leaves_only parameter is semantically ineffective
Confidence: High
Description: Both branches of the leaves_only check evaluate the exact same condition. For leaves_only = true, it returns if existing is not air and not one of five explicit leaf types. For leaves_only = false, it returns if existing is not air and !isLeafBlock(existing). Since isLeafBlock covers exactly the same five leaf types, both branches are logically equivalent, making the parameter have no effect.
Impact: Latent defect; if the function is ever relied upon to differentiate trunk placement (which should replace more block types) from leaf placement, the behavior will be incorrect. Currently does not manifest visibly since trunks are placed in air blocks.
Suggested Fix: Make leaves_only = false allow overwriting any block (or at least non-solid blocks like grass/dirt), while leaves_only = true restricts to air/leaves only. For example:

if (leaves_only and existing != .air and !isLeafBlock(existing)) return;
if (!leaves_only and existing != .air and existing != .water) return; // or similar

[FIXED] Previous issue: Type inconsistency in tree canopy placement (reported at lines 1190-1200 in prior review) - Tree helper signatures have been unified. setTreeBlockOffset now takes base_y: u32 and oy: i32 separately, and all canopy functions pass coordinates consistently.

ℹ️ Low Priority Suggestions (Optional)

None identified.

[FIXED] Previous low priority issues have been resolved:

  • highestSolidY no longer scans the full chunk height; it now accepts a max_y parameter and scans downward from @min(max_y, CHUNK_SIZE_Y - 1) (modules/worldgen-overworld-v2/src/root.zig:849).
  • deinit now includes a clarifying comment explaining that the generator owns no heap allocations (modules/worldgen-overworld-v2/src/root.zig:175-178).
  • Dead code addHeightDeltaFaces has been removed from modules/world-lod/src/lod_mesh.zig.

📊 SOLID Principles Score

Principle Score Notes
Single Responsibility 8 Generator is self-contained; noise, biome, surface, and decoration logic are separated into focused functions.
Open/Closed 7 New generator extends the registry without modifying existing generators. LOD mesh changes modify existing behavior.
Liskov Substitution 8 Implements the same Generator VTable interface as other generators.
Interface Segregation 8 Uses the existing worldgen-api contracts appropriately.
Dependency Inversion 8 Depends on abstractions (worldgen-api, world-core) rather than concrete modules.
Average 7.8

🎯 Final Assessment

Overall Confidence Score: 82%

Confidence Breakdown:

  • Code Quality: 85% (Clean generator structure, good normal calculation for LOD, proper memory lifecycle)
  • Completeness: 90% (New generator is feature-complete with tests, LOD improvements are intentional)
  • Risk Level: 75% (LOD mesh changes are well-reasoned; minor semantic issue in tree code)
  • Test Coverage: 85% (Good tests for new generator and registry integration)

Merge Readiness:

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

Verdict:

MERGE WITH FIXES

The PR is well-structured and nearly ready to merge. All previously reported high and low priority issues have been addressed. The remaining medium-priority item is a semantic defect in setTreeBlock where the leaves_only parameter has no effect. While this does not currently cause visible bugs (trunks are placed in air), it should be fixed to ensure the parameter behaves as intended.

{
  "reviewed_sha": "d326d0e813020b413396da8055f67644034622d3",
  "critical_issues": 0,
  "high_priority_issues": 0,
  "medium_priority_issues": 1,
  "overall_confidence_score": 82,
  "recommendation": "MERGE WITH FIXES"
}

New%20session%20-%202026-05-03T15%3A48%3A10.462Z
opencode session  |  github run

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 3, 2026

📋 Summary

No linked issues are mentioned in the PR description.

This PR adds a new Luanti v7-inspired overworld-v2 world generator with terrain, caves, rivers, biomes, trees, and vegetation. It also improves LOD mesh normal calculation (per-vertex smooth normals), adjusts LOD grid sizes for more uniform cell spacing, adds texture mappings for aquatic blocks, and includes unit tests. The fourth and final commit fixes the tree block replacement semantics.

📌 Review Metadata

All previously reported issues from prior automated reviews have been fully addressed. The new generator follows the existing worldgen-api contracts, has good test coverage, and all tests pass.

🔴 Critical Issues (Must Fix - Blocks Merge)

None identified.

[FIXED] All previously reported critical issues have been resolved.

⚠️ High Priority Issues (Should Fix)

None identified.

[FIXED] All previously reported high priority issues have been resolved:

  • addHeightDeltaFaces removal is an intentional design decision (heightmap cells share edge vertices, internal vertical walls are unnecessary). Clarifying comment added at modules/world-lod/src/lod_mesh.zig:239-240.
  • shouldRenderLODTree now correctly gates tree rendering to lod2 and beyond (modules/world-lod/src/lod_mesh.zig:748).
  • LOD1 grid size reduced from 64 to 32 for sensible density (modules/world-core/src/lod_data.zig:86).

💡 Medium Priority Issues (Nice to Fix)

None identified.

[FIXED] Previous medium-priority issue resolved:

  • setTreeBlock leaves_only parameter is now semantically effective. The !leaves_only branch allows replacing replaceable base blocks (tall_grass, flowers, dead_bush, snow_layer, seagrass, etc.) via the new isReplaceableTreeBase() helper, while leaves_only = true correctly restricts placement to air and leaf blocks only (modules/worldgen-overworld-v2/src/root.zig:1210-1216).

[FIXED] Previous medium-priority issue resolved:

  • Type inconsistency in tree canopy placement - Tree helper signatures have been unified. setTreeBlockOffset now takes base_y: u32 and oy: i32 separately, and all canopy functions pass coordinates consistently.

ℹ️ Low Priority Suggestions (Optional)

None identified.

[FIXED] All previously reported low priority issues have been resolved:

  • highestSolidY no longer scans the full chunk height; it now accepts a max_y parameter and scans downward from @min(max_y, CHUNK_SIZE_Y - 1) (modules/worldgen-overworld-v2/src/root.zig:849).
  • deinit now includes a clarifying comment explaining that the generator owns no heap allocations (modules/worldgen-overworld-v2/src/root.zig:175-178).
  • Dead code addHeightDeltaFaces has been removed from modules/world-lod/src/lod_mesh.zig.

📊 SOLID Principles Score

Principle Score Notes
Single Responsibility 8 Generator is self-contained; noise, biome, surface, and decoration logic are separated into focused functions.
Open/Closed 7 New generator extends the registry without modifying existing generators. LOD mesh changes modify existing behavior.
Liskov Substitution 8 Implements the same Generator VTable interface as other generators.
Interface Segregation 8 Uses the existing worldgen-api contracts appropriately.
Dependency Inversion 8 Depends on abstractions (worldgen-api, world-core) rather than concrete modules.
Average 7.8

🎯 Final Assessment

Overall Confidence Score: 88%

Confidence Breakdown:

  • Code Quality: 88% (Clean generator structure, good normal calculation for LOD, proper memory lifecycle, tree replacement rules are now semantically correct)
  • Completeness: 92% (New generator is feature-complete with tests, LOD improvements are intentional and well-reasoned)
  • Risk Level: 80% (LOD mesh changes are well-reasoned; all prior issues resolved)
  • Test Coverage: 88% (Good tests for new generator and registry integration, deterministic output verified)

Merge Readiness:

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

Verdict:

MERGE

The PR is well-structured and ready to merge. All previously reported issues have been addressed in the 4 commits. The tree block replacement semantics are now correct, the LOD mesh changes are intentional with proper documentation, and the new generator is fully integrated with tests passing.

{
  "reviewed_sha": "fd83e93511be5970e3d47ea08f7bdc4bd2678f76",
  "critical_issues": 0,
  "high_priority_issues": 0,
  "medium_priority_issues": 0,
  "overall_confidence_score": 88,
  "recommendation": "MERGE"
}

New%20session%20-%202026-05-03T16%3A04%3A37.593Z
opencode session  |  github run

@github-actions github-actions Bot merged commit 5494b9f into dev May 3, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant