Configured carvers: caves and canyons
The router's noise caves are one kind of cave. The other kind -- the long
winding tunnels with rooms and side branches, and the ravines that cut down
through the terrain -- is walked, step by step, by a random source, and none of
it existed.
The shape of the work is unusual enough to state plainly. To carve one chunk,
vanilla replays every carver seeded in the 17x17 chunks around it and keeps only
what lands inside, so the same tunnel is walked up to 289 times across a world.
That redundancy is the point: it is what lets a chunk be carved without
generating its neighbours, which is the only way carving fits a generator that
produces one chunk at a time. A carve-once-write-into-neighbours design would be
cheaper and would not reproduce vanilla's mask and ordering.
Two primitives had to be right before any of it could be, and both are pinned
against values captured from the jar:
* setLargeFeatureSeed, which decides which chunks start a cave. It combines
its two products with XOR; setDecorationSeed, which it otherwise resembles,
uses addition and forces the low bit. Getting them the wrong way round moves
every tunnel in the world and nothing complains.
* Mth.sin and Mth.cos, which are a 65536-entry lookup table and not libm.
Mth.sin(-1.0) is -0.8414514 against Math.sin's -0.8414709848078965, and a
tunnel that walks by adding cos(yaw) a hundred times ends up somewhere else
entirely if that difference is smoothed away.
Carving lands between the surface pass and decoration, where vanilla puts it,
and both neighbours matter: the surface rules must already have placed grass for
a cave mouth to be retextured, and decoration must come after so nothing is
planted over a hole. The heights decoration plants against are recomputed
afterwards, which is why vanilla re-primes its heightmaps at the start of the
feature step.
The configs are extracted from the jar rather than transcribed, along with the
flattened #minecraft:overworld_carver_replaceables tag, so the probabilities and
Y ranges are data. Open volume below y=60 rises 28% over sixteen sampled chunks,
tunnels cut at or below y=-56 fill with lava rather than air (869 blocks, no
air), and the cost is inside the noise floor of the density pass.
This commit is contained in:
parent
0f76058db6
commit
c6185d88c8
13 changed files with 1402 additions and 9 deletions
|
|
@ -32,12 +32,17 @@ func NewVanillaGenerator(seed int64) Generator {
|
|||
}
|
||||
fluidPicker := worldgen.OverworldFluidPicker(od.SeaLevel)
|
||||
veins := worldgen.NewOreVeinifier(od)
|
||||
carver, err := worldgen.NewCarver(od, seed)
|
||||
if err != nil {
|
||||
panic("world: loading carvers: " + err.Error())
|
||||
}
|
||||
initCarverReplaceable(carver.ReplaceableBlocks())
|
||||
return func(cx, cz int32) *Chunk {
|
||||
return generateVanilla(od, fluidPicker, veins, seed, cx, cz)
|
||||
return generateVanilla(od, fluidPicker, veins, carver, seed, cx, cz)
|
||||
}
|
||||
}
|
||||
|
||||
func generateVanilla(od *worldgen.OverworldDensity, fluidPicker worldgen.FluidPicker, veins *worldgen.OreVeinifier, seed int64, cx, cz int32) *Chunk {
|
||||
func generateVanilla(od *worldgen.OverworldDensity, fluidPicker worldgen.FluidPicker, veins *worldgen.OreVeinifier, carver *worldgen.Carver, seed int64, cx, cz int32) *Chunk {
|
||||
c := NewChunk(cx, cz, BiomePlains) // per-cell biomes override below
|
||||
baseX, baseZ := int(cx)*16, int(cz)*16
|
||||
|
||||
|
|
@ -135,6 +140,26 @@ func generateVanilla(od *worldgen.OverworldDensity, fluidPicker worldgen.FluidPi
|
|||
}
|
||||
wg.Wait()
|
||||
|
||||
// Carving sits between the surface pass and decoration, as it does in
|
||||
// vanilla: it needs the surfaced blocks to retexture a cave mouth, and
|
||||
// decoration needs the carved heights so nothing is planted over a hole.
|
||||
if carver != nil && ruleErr == nil {
|
||||
view := &carveView{
|
||||
cols: &columns, od: od, rules: surfaceRule,
|
||||
sctx: surfaceRule.NewContext(), biomes: &biomeName,
|
||||
worldSurface: &worldSurface, baseX: baseX, baseZ: baseZ,
|
||||
}
|
||||
carver.CarveChunk(view, aq, int(cx), int(cz))
|
||||
// The heights decoration plants against are the post-carve ones.
|
||||
// Vanilla re-primes its heightmaps at the start of the feature step for
|
||||
// the same reason.
|
||||
for lx := 0; lx < 16; lx++ {
|
||||
for lz := 0; lz < 16; lz++ {
|
||||
surfTop[lx][lz], grass[lx][lz] = classifyColumn(&columns[lx][lz])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for lx := 0; lx < 16; lx++ {
|
||||
for lz := 0; lz < 16; lz++ {
|
||||
col := &columns[lx][lz]
|
||||
|
|
@ -216,13 +241,31 @@ func fillVanillaColumn(od *worldgen.OverworldDensity, aq *worldgen.Aquifer, flui
|
|||
}
|
||||
}
|
||||
|
||||
_, grass = classifyColumn(out)
|
||||
return top, worldSurface, grass
|
||||
}
|
||||
|
||||
// classifyColumn returns the top solid index and whether that surface is
|
||||
// plantable grassy land. It is recomputed after carving, because a column whose
|
||||
// top block a ravine removed is no longer the column decoration was told about.
|
||||
func classifyColumn(col *[WorldHeight]uint16) (top int, grass bool) {
|
||||
top = -1
|
||||
for i := WorldHeight - 1; i >= 0; i-- {
|
||||
if isStoneState(col[i]) {
|
||||
top = i
|
||||
break
|
||||
}
|
||||
}
|
||||
if top < 0 {
|
||||
return top, false
|
||||
}
|
||||
topY := MinY + top
|
||||
// Beach: a narrow band straddling the waterline. Dry columns well above sea
|
||||
// level stay grass; deep water floors become gravel, not sand.
|
||||
const beachBand = 3
|
||||
beach := top >= 0 && topY >= SeaLevel-beachBand && topY <= SeaLevel+1
|
||||
deepWater := top >= 0 && topY < SeaLevel-beachBand
|
||||
return top, worldSurface, top >= 0 && !beach && !deepWater && topY >= SeaLevel
|
||||
beach := topY >= SeaLevel-beachBand && topY <= SeaLevel+1
|
||||
deepWater := topY < SeaLevel-beachBand
|
||||
return top, !beach && !deepWater && topY >= SeaLevel
|
||||
}
|
||||
|
||||
// steepAt is SurfaceRules.SteepMaterialCondition: true where the column's
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue