mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 16:25:36 +00:00
Read seeded noise styles flat in blocks
Palette layers, the decorator chance gate and carving child biomes divide by their zoom or shrink factor only for a style without a seed; a seeded style is read in plain blocks, so its own zoom is its only scale and it lines up with every other reader of the same seed. Ported from v3e a1bd24186. IrisApi2914ed1, Iris3b9012535.
This commit is contained in:
1 parent
3ac971c0d9
commit
9852f730a7
5 files changed
+25
-10
No files matched your search
@@ -186,8 +186,16 @@ final class ResolvedDecorator {
|
||||
if (blocks.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
double zoom = settings.style().zoom();
|
||||
return chanceNoise().sample(x / zoom, z / zoom) <= settings.chance();
|
||||
return chanceNoisePlacesAt(x, z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the style noise stays under the chance at the column. A style without a seed divides by its zoom here on top
|
||||
* of its own scale; a seeded one is read in plain blocks.
|
||||
*/
|
||||
private boolean chanceNoisePlacesAt(double x, double z) {
|
||||
double blocksPerSample = settings.style().isSeeded() ? 1 : settings.style().zoom();
|
||||
return chanceNoise().sample(x / blocksPerSample, z / blocksPerSample) <= settings.chance();
|
||||
}
|
||||
|
||||
/** The block of the palette at the position, for decorations that fill a column block by block; null when the palette has no block. */
|
||||
@@ -210,8 +218,7 @@ final class ResolvedDecorator {
|
||||
return blockAt(x, y, z);
|
||||
}
|
||||
|
||||
double zoom = settings.style().zoom();
|
||||
if (!(chanceNoise().sample(x / zoom, z / zoom) <= settings.chance())) {
|
||||
if (!chanceNoisePlacesAt(x, z)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
+5
-2
@@ -94,8 +94,11 @@ public final class ResolvedCarvingEntry {
|
||||
long idHash = settings.id().trim().hashCode();
|
||||
long generatorSeed = seed ^ (idHash << 32) ^ CHILD_GENERATOR_SALT;
|
||||
return childGenerators.computeIfAbsent(generatorSeed, key -> {
|
||||
double scale = Math.max(MIN_CHILD_SCALE, settings.childShrinkFactor());
|
||||
return resources.noise().sampler(settings.childStyle(), key + CHILD_GENERATOR_SIGNATURE).scaled(scale);
|
||||
NoiseSampler children = resources.noise().sampler(settings.childStyle(), key + CHILD_GENERATOR_SIGNATURE);
|
||||
if (settings.childStyle().isSeeded()) {
|
||||
return children;
|
||||
}
|
||||
return children.scaled(Math.max(MIN_CHILD_SCALE, settings.childShrinkFactor()));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -246,9 +246,9 @@ public final class BiomeLayers {
|
||||
|
||||
/** Adds the layer's block {@code j} blocks down; a layer that fails to pick adds nothing. */
|
||||
private void addBlock(KList<BlockState> blocks, ResolvedLayer layer, int index, int j, double wx, double wz, RNG random) {
|
||||
double zoom = layer.zoom();
|
||||
double blocksPerSample = layer.blocksPerSample();
|
||||
try {
|
||||
blocks.add(layer.get(random, index + j, (wx + j) / zoom, j, (wz - j) / zoom));
|
||||
blocks.add(layer.get(random, index + j, (wx + j) / blocksPerSample, j, (wz - j) / blocksPerSample));
|
||||
} catch (Throwable e) {
|
||||
log.error("A biome layer failed to pick a block", e);
|
||||
}
|
||||
|
||||
@@ -71,8 +71,8 @@ public final class LayerBlocks {
|
||||
if (size <= 1) {
|
||||
return size - 1;
|
||||
}
|
||||
double zoom = layer.zoom();
|
||||
double noise = layerPicks.noise(parent, signature).sample(x / zoom, y / zoom, z / zoom);
|
||||
NoiseSampler sampler = layerPicks.noise(parent, signature);
|
||||
double noise = layer.style().isSeeded() ? sampler.sample(x, z) : sampler.sample(x / layer.zoom(), y / layer.zoom(), z / layer.zoom());
|
||||
int index = (int) Math.round(noise * (size - 1));
|
||||
return index < 0 || index >= size ? 0 : index;
|
||||
}
|
||||
|
||||
@@ -71,6 +71,11 @@ public final class ResolvedLayer {
|
||||
return settings.zoom();
|
||||
}
|
||||
|
||||
/** How many blocks one step of the layer's block noise spans: its zoom, or 1 for a seeded style, which is read flat. */
|
||||
public double blocksPerSample() {
|
||||
return settings.style().isSeeded() ? 1 : settings.zoom();
|
||||
}
|
||||
|
||||
public SlopeClip slopeCondition() {
|
||||
return settings.slopeCondition();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user