mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 00:34:19 +00:00
Give every stage its own random stream derived from the invocation seed and stage id
Stages no longer share one RandomGenerator. StageContext.random() is the running stage's own stream: java.util.Random seeded with mix(mix(invocationSeed) ^ fnv1a64(utf8(stageId))), mix being the SplitMix64 finalizer. Adding, removing or reordering modules, or how much other stages draw, no longer changes a stage's draws. A block stage keeps one stream across the blocks of its pass. The host passes a long invocation seed to PlacementRunner.place and ChunkRunner.generate instead of a RandomGenerator on the inputs; InvocationContext loses random(), so stages cannot reach a shared stream. ObjectGenerationContext keeps its own random() for geometry generators. StageRandom documents the derivation, and a test pins it to values computed from the specification.
This commit is contained in:
1 parent
4cb718f706
commit
307e488d1a
17 files changed
+293
-34
No files matched your search
@@ -10,8 +10,6 @@ import com.volmit.resource.PackResources;
|
||||
import com.volmit.world.TerrainSampler;
|
||||
import com.volmit.world.BlockView;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.random.RandomGenerator;
|
||||
|
||||
/** Tests needing no platform facilities fail loudly if code starts using one. */
|
||||
public final class TestContexts {
|
||||
@@ -21,12 +19,10 @@ public final class TestContexts {
|
||||
|
||||
public static GenerationContext generation(Map<Class<?>, Hunk<?>> hunks) {
|
||||
return new GenerationContext() {
|
||||
private final RandomGenerator random = new Random(SEED);
|
||||
public int originX() { return 0; }
|
||||
public int originY() { return -64; }
|
||||
public int originZ() { return 0; }
|
||||
public long worldSeed() { return SEED; }
|
||||
public RandomGenerator random() { return random; }
|
||||
public PackResources resources() { throw new AssertionError("Unused resources"); }
|
||||
public TerrainSampler terrain() { throw new AssertionError("Unused terrain"); }
|
||||
public FeatureSettings settings() { throw new AssertionError("Unused settings"); }
|
||||
@@ -46,9 +42,7 @@ public final class TestContexts {
|
||||
|
||||
public static PlacementContext placement(BlockView blocks) {
|
||||
return new PlacementContext() {
|
||||
private final RandomGenerator random = new Random(SEED);
|
||||
public long worldSeed() { return SEED; }
|
||||
public RandomGenerator random() { return random; }
|
||||
public PackResources resources() { throw new AssertionError("Unused resources"); }
|
||||
public TerrainSampler terrain() { throw new AssertionError("Unused terrain"); }
|
||||
public FeatureSettings settings() { throw new AssertionError("Unused settings"); }
|
||||
|
||||
Reference in new issue
Block a user