feat(worldgen): wire EssencePalette into WorldGenerator interface#90
Merged
Conversation
Add EssencePalette* parameter to generate() and generateToBuffer() across the WorldGenerator hierarchy (5 subclasses, 6 production call sites). Implement classifyEssence() in MinecraftNoiseGenerator to map terrain features (warmth, wetness, ruggedness, coastalness, sediment) plus spatial hash jitter to Vec4 OCLD values clamped to [0,1]. When palette is non-null, MinecraftNoiseGenerator populates essence inline during generation via palette->quantize8(). Existing assignEssence() post-pass calls are preserved for backward compatibility; the essenceIdx == materialId invariant is not broken in this change. 6 new tests: palette population, null safety, spatial variation, OCLD clamping, multi-material essence diversity, cross-generator safety. 2356 tests pass (2353 + 3 skipped). Wave 4 of the D2+D3 combined implementation plan.
Greptile SummaryThis PR (Wave 4 of the D2+D3 plan) wires Key changes:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Caller as VoxelSimulationSystem / WorldSession / ReplayExecutor
participant WG as WorldGenerator (interface)
participant MNG as MinecraftNoiseGenerator
participant EP as EssencePalette
participant AE as assignEssence (fallback)
Caller->>WG: generateToBuffer(buffer, cx, cy, cz, &palette)
WG->>MNG: generateToBuffer(buffer, cx, cy, cz, palette)
loop for each non-AIR voxel
MNG->>MNG: classifyMaterial(column, wy)
alt palette != nullptr
MNG->>MNG: classifyEssence(column, materialId, wx, wy, wz)
MNG->>EP: quantize8(essenceVec4)
EP-->>MNG: uint8_t index
MNG->>MNG: cell.essenceIdx = index
end
MNG->>MNG: buffer[idx] = cell
end
MNG-->>Caller: (buffer populated)
alt palette->paletteSize() == 0 (generator ignored palette)
Caller->>AE: assignEssence(buffer, cx, cy, cz, materials, palette, 42)
AE-->>Caller: (essenceIdx = materialId fallback)
end
Reviews (2): Last reviewed commit: "fix(worldgen): address PR #90 review fin..." | Re-trigger Greptile |
- Cast spatial hash operands to uint32_t before multiplying to avoid signed-integer overflow UB in classifyEssence (R90-1) - Guard assignEssence() calls with paletteSize() == 0 so generators that populate the palette inline (MinecraftNoiseGenerator) skip the post-pass that would read corrupted essenceIdx values (R90-2) - Simplify tautological assertion in EssenceVariesSpatially test to EXPECT_NE on the two sets directly (R90-3)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
EssencePalette*parameter toWorldGenerator::generate()andgenerateToBuffer()across all 5 subclasses and 6 production call sitesclassifyEssence()inMinecraftNoiseGeneratorto map terrain features (warmth, wetness, ruggedness, coastalness, sediment) plus spatial hash jitter to Vec4 OCLD values clamped to [0,1]generateToBuffer()when palette is non-null viapalette->quantize8()Wave 4 of the D2+D3 combined implementation plan. The
essenceIdx == materialIdinvariant is preserved; existingassignEssence()post-pass calls remain for backward compatibility. The invariant break is deferred to a follow-up PR.Changes
Interface (W4-A):
generate()andgenerateToBuffer()gainEssencePalette* palette = nullptr. Default parameter on declarations only. All subclasses (MinecraftNoise, NaturalWorld, Flat, Layered, SingleMaterial, TestWorld) updated. NaturalWorldGenerator passes palette through to its inner noise generator.classifyEssence (W4-B): Private const method on MinecraftNoiseGenerator. Maps 6 base materials (STONE, DIRT, SAND, WATER, GRAVEL, AIR) to OCLD base vectors, modulates with ColumnSample terrain features, adds spatial hash jitter, clamps all components to [0,1].
Inline essence (W4-C): MinecraftNoiseGenerator::generateToBuffer() calls classifyEssence() + palette->quantize8() for non-air cells when palette is non-null. Air cells are skipped. Null palette preserves existing behavior.
Call site updates: VoxelSimulationSystem (3 sites) passes chunk palette. WorldSession (2 sites) and ReplayExecutor (1 site) create local
EssencePalette refPalettebeforegenerateToBuffer().Test plan
mise run buildcompiles cleanmise run testpasses 2356 tests (2353 + 3 skipped)mise run lint:changedshows only pre-existing warnings