Proper dimensional stacking

This commit is contained in:
Daniel Mills 2020-10-30 06:14:43 -04:00
parent 13805edba9
commit c5bd594798
19 changed files with 257 additions and 140 deletions

24
.idea/workspace.xml generated
View File

@ -16,8 +16,8 @@
<option name="RECENT_TEMPLATES">
<list>
<option value="Enum" />
<option value="Interface" />
<option value="Class" />
<option value="Interface" />
</list>
</option>
</component>
@ -60,11 +60,11 @@
<recent name="com.volmit.iris.gen.v2.scaffold.stream.sources" />
</key>
<key name="CopyClassDialog.RECENTS_KEY">
<recent name="com.volmit.iris.v2.scaffold.stream.utility" />
<recent name="com.volmit.iris.object" />
<recent name="com.volmit.iris.gen.v2.generator.actuator" />
<recent name="com.volmit.iris.gen.v2.scaffold.stream.utility" />
<recent name="com.volmit.iris.gen.v2.scaffold.stream.arithmetic" />
<recent name="com.volmit.iris.gen.v2.scaffold.stream.convert" />
</key>
<key name="CopyFile.RECENT_KEYS">
<recent name="C:\Users\cyberpwn\Documents\development\workspace\Iris\src\main\java\com\volmit\iris\gen\v2\scaffold\hunk" />
@ -143,22 +143,22 @@
<screen x="0" y="0" width="1920" height="1050" />
</state>
<state x="485" y="234" key="#com.intellij.structuralsearch.plugin.ui.StructuralSearchDialog/-1920.0.1920.1050/1920.0.1920.1050/0.0.1920.1050@0.0.1920.1050" timestamp="1603860057506" />
<state width="1921" height="983" key="GridCell.Tab.0.bottom" timestamp="1603976975935">
<state width="1921" height="983" key="GridCell.Tab.0.bottom" timestamp="1604048198954">
<screen x="0" y="0" width="1920" height="1050" />
</state>
<state width="1921" height="983" key="GridCell.Tab.0.bottom/-1920.0.1920.1050/1920.0.1920.1050/0.0.1920.1050@0.0.1920.1050" timestamp="1603976975935" />
<state width="1921" height="983" key="GridCell.Tab.0.center" timestamp="1603976975935">
<state width="1921" height="983" key="GridCell.Tab.0.bottom/-1920.0.1920.1050/1920.0.1920.1050/0.0.1920.1050@0.0.1920.1050" timestamp="1604048198954" />
<state width="1921" height="983" key="GridCell.Tab.0.center" timestamp="1604048198953">
<screen x="0" y="0" width="1920" height="1050" />
</state>
<state width="1921" height="983" key="GridCell.Tab.0.center/-1920.0.1920.1050/1920.0.1920.1050/0.0.1920.1050@0.0.1920.1050" timestamp="1603976975935" />
<state width="1921" height="983" key="GridCell.Tab.0.left" timestamp="1603976975934">
<state width="1921" height="983" key="GridCell.Tab.0.center/-1920.0.1920.1050/1920.0.1920.1050/0.0.1920.1050@0.0.1920.1050" timestamp="1604048198953" />
<state width="1921" height="983" key="GridCell.Tab.0.left" timestamp="1604048198953">
<screen x="0" y="0" width="1920" height="1050" />
</state>
<state width="1921" height="983" key="GridCell.Tab.0.left/-1920.0.1920.1050/1920.0.1920.1050/0.0.1920.1050@0.0.1920.1050" timestamp="1603976975934" />
<state width="1921" height="983" key="GridCell.Tab.0.right" timestamp="1603976975935">
<state width="1921" height="983" key="GridCell.Tab.0.left/-1920.0.1920.1050/1920.0.1920.1050/0.0.1920.1050@0.0.1920.1050" timestamp="1604048198953" />
<state width="1921" height="983" key="GridCell.Tab.0.right" timestamp="1604048198954">
<screen x="0" y="0" width="1920" height="1050" />
</state>
<state width="1921" height="983" key="GridCell.Tab.0.right/-1920.0.1920.1050/1920.0.1920.1050/0.0.1920.1050@0.0.1920.1050" timestamp="1603976975935" />
<state width="1921" height="983" key="GridCell.Tab.0.right/-1920.0.1920.1050/1920.0.1920.1050/0.0.1920.1050@0.0.1920.1050" timestamp="1604048198954" />
<state x="312" y="0" key="SettingsEditor" timestamp="1603947206451">
<screen x="0" y="0" width="1920" height="1050" />
</state>
@ -171,9 +171,9 @@
<screen x="0" y="0" width="1920" height="1050" />
</state>
<state x="532" y="239" key="run.anything.popup/-1920.0.1920.1050/1920.0.1920.1050/0.0.1920.1050@0.0.1920.1050" timestamp="1603859771295" />
<state x="539" y="15" width="840" height="1034" key="search.everywhere.popup" timestamp="1603972322783">
<state x="539" y="15" width="840" height="1034" key="search.everywhere.popup" timestamp="1604046453193">
<screen x="0" y="0" width="1920" height="1050" />
</state>
<state x="539" y="15" width="840" height="1034" key="search.everywhere.popup/-1920.0.1920.1050/1920.0.1920.1050/0.0.1920.1050@0.0.1920.1050" timestamp="1603972322783" />
<state x="539" y="15" width="840" height="1034" key="search.everywhere.popup/-1920.0.1920.1050/1920.0.1920.1050/0.0.1920.1050@0.0.1920.1050" timestamp="1604046453193" />
</component>
</project>

View File

@ -7,6 +7,7 @@ import com.volmit.iris.util.Command;
import com.volmit.iris.util.KList;
import com.volmit.iris.util.MortarCommand;
import com.volmit.iris.util.MortarSender;
import com.volmit.iris.v2.scaffold.engine.Hotloadable;
public class CommandIris extends MortarCommand
{
@ -70,6 +71,13 @@ public class CommandIris extends MortarCommand
return true;
}
if(args.length == 1 && args[0].equalsIgnoreCase("hl!") && IrisSettings.get().allowExperimentalV2Generator)
{
((Hotloadable)sender.player().getWorld().getGenerator()).hotload();
sender.sendMessage("Done!");
return true;
}
sender.sendMessage("Iris v" + Iris.instance.getDescription().getVersion() + " by Volmit Software");
printHelp(sender);
return true;

View File

@ -184,7 +184,7 @@ public class IrisDataManager
}
}
public void preferFolder(String name)
public IrisDataManager preferFolder(String name)
{
biomeLoader.preferFolder(name);
blockLoader.preferFolder(name);
@ -194,6 +194,7 @@ public class IrisDataManager
dimensionLoader.preferFolder(name);
generatorLoader.preferFolder(name);
structureLoader.preferFolder(name);
return this;
}
public void clearLists()

View File

@ -25,6 +25,6 @@ public class TestGen
public static void gen(Player p)
{
p.teleport(new Location(new WorldCreator("t/" + UUID.randomUUID().toString())
.generator(EngineCompositeGenerator.newStudioWorld("flat")).createWorld(), 0, 70, 0));
.generator(EngineCompositeGenerator.newStudioWorld("test")).createWorld(), 0, 70, 0));
}
}

View File

@ -53,7 +53,6 @@ public class IrisComplex implements DataProvider
private ProceduralStream<IrisDecorator> terrainCeilingDecoration;
private ProceduralStream<IrisDecorator> seaSurfaceDecoration;
private ProceduralStream<IrisDecorator> shoreSurfaceDecoration;
private ProceduralStream<BlockData> terrainStream;
private ProceduralStream<BlockData> rockStream;
private ProceduralStream<BlockData> fluidStream;
private ProceduralStream<BlockData> glassStream;
@ -102,8 +101,7 @@ public class IrisComplex implements DataProvider
overlayStream = ProceduralStream.ofDouble((x, z) -> 0D);
engine.getDimension().getOverlayNoise().forEach((i) -> overlayStream.add((x, z) -> i.get(rng, x, z)));
rngStream = ProceduralStream.of((x, z) -> new RNG(((x.longValue()) << 32) | (z.longValue() & 0xffffffffL))
.nextParallelRNG(engine.getWorld().getSeed()), Interpolated.RNG)
.cache2D(64);
.nextParallelRNG(engine.getWorld().getSeed()), Interpolated.RNG);
chunkRngStream = rngStream.blockToChunkCoords();
rockStream = engine.getDimension().getRockPalette().getLayerGenerator(rng.nextRNG(), data).stream()
.select(engine.getDimension().getRockPalette().getBlockData(data));
@ -112,17 +110,15 @@ public class IrisComplex implements DataProvider
regionStream = engine.getDimension().getRegionStyle().create(rng.nextRNG()).stream()
.zoom(engine.getDimension().getRegionZoom())
.selectRarity(engine.getDimension().getRegions())
.convertCached((s) -> data.getRegionLoader().load(s))
.cache2D(cacheSize);
caveBiomeStream = regionStream.convertCached((r)
.convertCached((s) -> data.getRegionLoader().load(s)).cache2D(cacheSize);
caveBiomeStream = regionStream.convert((r)
-> engine.getDimension().getCaveBiomeStyle().create(rng.nextRNG()).stream()
.zoom(r.getCaveBiomeZoom())
.selectRarity(r.getCaveBiomes())
.convertCached((s) -> data.getBiomeLoader().load(s)
.setInferredType(InferredType.CAVE))
).convertAware2D(ProceduralStream::get)
.cache2D(cacheSize);
landBiomeStream = regionStream.convertCached((r)
).convertAware2D(ProceduralStream::get).cache2D(cacheSize);
landBiomeStream = regionStream.convert((r)
-> engine.getDimension().getLandBiomeStyle().create(rng.nextRNG()).stream()
.zoom(r.getLandBiomeZoom())
.selectRarity(r.getLandBiomes())
@ -130,7 +126,7 @@ public class IrisComplex implements DataProvider
.setInferredType(InferredType.LAND))
).convertAware2D(ProceduralStream::get)
.cache2D(cacheSize);
seaBiomeStream = regionStream.convertCached((r)
seaBiomeStream = regionStream.convert((r)
-> engine.getDimension().getSeaBiomeStyle().create(rng.nextRNG()).stream()
.zoom(r.getSeaBiomeZoom())
.selectRarity(r.getSeaBiomes())
@ -138,29 +134,27 @@ public class IrisComplex implements DataProvider
.setInferredType(InferredType.SEA))
).convertAware2D(ProceduralStream::get)
.cache2D(cacheSize);
shoreBiomeStream = regionStream.convertCached((r)
shoreBiomeStream = regionStream.convert((r)
-> engine.getDimension().getShoreBiomeStyle().create(rng.nextRNG()).stream()
.zoom(r.getShoreBiomeZoom())
.selectRarity(r.getShoreBiomes())
.convertCached((s) -> data.getBiomeLoader().load(s)
.setInferredType(InferredType.SHORE))
).convertAware2D(ProceduralStream::get)
.cache2D(cacheSize);
).convertAware2D(ProceduralStream::get).cache2D(cacheSize);
bridgeStream = engine.getDimension().getContinentalStyle().create(rng.nextRNG()).stream()
.convert((v) -> v >= engine.getDimension().getLandChance() ? InferredType.SEA : InferredType.LAND);
baseBiomeStream = bridgeStream.convertAware2D((t, x, z) -> t.equals(InferredType.SEA)
? seaBiomeStream.get(x, z) : landBiomeStream.get(x, z))
.convertAware2D(this::implode).cache2D(cacheSize);
heightStream = baseBiomeStream.convertAware2D((b, x, z) -> getHeight(b, x, z, engine.getWorld().getSeed()))
.roundDouble()
.cache2D(cacheSize);
slopeStream = heightStream.slope();
.roundDouble().cache2D(cacheSize);
slopeStream = heightStream.slope().cache2D(cacheSize);
trueBiomeStream = heightStream
.convertAware2D((h, x, z) ->
fixBiomeType(h, baseBiomeStream.get(x, z),
regionStream.get(x, z), x, z, fluidHeight));
trueBiomeDerivativeStream = trueBiomeStream.convert(IrisBiome::getDerivative);
heightFluidStream = heightStream.max(fluidHeight);
regionStream.get(x, z), x, z, fluidHeight)).cache2D(cacheSize);
trueBiomeDerivativeStream = trueBiomeStream.convert(IrisBiome::getDerivative).cache2D(cacheSize);
heightFluidStream = heightStream.max(fluidHeight).cache2D(cacheSize);
maxHeightStream = ProceduralStream.ofDouble((x, z) -> height);
terrainSurfaceDecoration = trueBiomeStream
.convertAware2D((b, xx,zz) -> decorateFor(b, xx, zz, DecorationPart.NONE));
@ -170,42 +164,9 @@ public class IrisComplex implements DataProvider
.convertAware2D((b, xx,zz) -> decorateFor(b, xx, zz, DecorationPart.SHORE_LINE));
seaSurfaceDecoration = trueBiomeStream
.convertAware2D((b, xx,zz) -> decorateFor(b, xx, zz, DecorationPart.SEA_SURFACE));
terrainStream = ProceduralStream.of(this::fillTerrain, Interpolated.BLOCK_DATA);
//@done
}
private BlockData fillTerrain(Double x, Double y, Double z)
{
double height = heightStream.get(x, z);
IrisBiome biome = trueBiomeStream.get(x, z);
int depth = (int) (Math.round(height) - y);
int atDepth = 0;
if(y > height && y <= fluidHeight)
{
return fluidStream.get(x, y, z);
}
if(depth < -1)
{
return AIR;
}
for(IrisBiomePaletteLayer i : biome.getLayers())
{
int th = i.getHeightGenerator(rng, data).fit(i.getMinHeight(), i.getMaxHeight(), x, z);
if(atDepth + th >= depth)
{
return i.get(rng, x, y, z, data);
}
atDepth += th;
}
return rockStream.get(x, y, z);
}
private IrisDecorator decorateFor(IrisBiome b, double x, double z, DecorationPart part)
{
RNG rngc = chunkRngStream.get(x, z);

View File

@ -1,5 +1,6 @@
package com.volmit.iris.v2.generator;
import com.volmit.iris.Iris;
import com.volmit.iris.v2.scaffold.engine.Engine;
import com.volmit.iris.v2.scaffold.engine.EngineFramework;
import com.volmit.iris.v2.scaffold.engine.EngineTarget;
@ -23,6 +24,7 @@ public class IrisEngine implements Engine
public IrisEngine(EngineTarget target)
{
Iris.info("Initializing Engine: " + target.getWorld().getName() + "/" + target.getDimension().getLoadKey() + " (" + target.getHeight() + " height)");
this.target = target;
this.framework = new IrisEngineFramework(this);
}

View File

@ -4,6 +4,7 @@ import com.volmit.iris.Iris;
import com.volmit.iris.manager.IrisDataManager;
import com.volmit.iris.object.IrisDimension;
import com.volmit.iris.object.IrisDimensionIndex;
import com.volmit.iris.util.J;
import com.volmit.iris.util.KList;
import com.volmit.iris.v2.scaffold.engine.Engine;
import com.volmit.iris.v2.scaffold.engine.EngineCompound;
@ -16,6 +17,7 @@ import lombok.Getter;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;
import org.bukkit.craftbukkit.v1_16_R2.generator.CraftChunkData;
import java.io.File;
import java.util.concurrent.atomic.AtomicInteger;
@ -35,6 +37,7 @@ public class IrisEngineCompound implements EngineCompound {
public IrisEngineCompound(World world, IrisDimension rootDimension, IrisDataManager data, int maximumThreads)
{
Iris.info("Initializing Engine Composite for " + world.getName());
this.world = world;
engineMetadata = EngineData.load(getEngineMetadataFile());
saveEngineMetadata();
@ -66,7 +69,7 @@ public class IrisEngineCompound implements EngineCompound {
{
IrisDimensionIndex index = rootDimension.getDimensionalComposite().get(i);
IrisDimension dimension = data.getDimensionLoader().load(index.getDimension());
engines[i] = new IrisEngine(new EngineTarget(world, dimension, data.copy(), (int)Math.floor(256D * (index.getWeight() / totalWeight)), index.isInverted(), threadDist));
engines[i] = new IrisEngine(new EngineTarget(world, dimension, data.copy().preferFolder(rootDimension.getLoadKey()), (int)Math.floor(256D * (index.getWeight() / totalWeight)), index.isInverted(), threadDist));
}
}
}
@ -94,18 +97,19 @@ public class IrisEngineCompound implements EngineCompound {
{
AtomicInteger index = new AtomicInteger(i);
Engine engine = engines[i];
int doffset = offset;
int height = engine.getTarget().getHeight();
AtomicReference<Hunk<BlockData>> cblock = new AtomicReference<>(blocks.croppedView(0, offset, 0, 16, offset+height, 16));
AtomicReference<Hunk<Biome>> cbiome = new AtomicReference<>(biomes.croppedView(0, offset, 0, 16, offset+height, 16));
AtomicReference<Hunk<BlockData>> cblock = new AtomicReference<>(Hunk.newArrayHunk(16, height, 16));
AtomicReference<Hunk<Biome>> cbiome = new AtomicReference<>(Hunk.newArrayHunk(16, height, 16));
cblock.set(engine.getTarget().isInverted() ? cblock.get().invertY() : cblock.get());
cbiome.set(engine.getTarget().isInverted() ? cbiome.get().invertY() : cbiome.get());
e.queue(() -> {
generate(x, z, cblock.get(), cbiome.get());
engine.generate(x, z, cblock.get(), cbiome.get());
synchronized (insert)
{
insert[index.get()] = () -> {
blocks.insert(cblock.get());
biomes.insert(cbiome.get());
blocks.insert(0, doffset, 0, cblock.get());
biomes.insert(0, doffset, 0, cbiome.get());
};
}
});

View File

@ -8,11 +8,11 @@ import org.bukkit.block.Biome;
public class IrisBiomeActuator extends EngineAssignedActuator<Biome>
{
public IrisBiomeActuator(Engine engine) {
super(engine);
super(engine, "Biome");
}
@Override
public void actuate(int x, int z, Hunk<Biome> output) {
public void onActuate(int x, int z, Hunk<Biome> output) {
output.compute2D(getParallelism(), (xx, yy, zz, h) -> {
int i,zf;
Biome v;

View File

@ -7,6 +7,7 @@ import com.volmit.iris.object.IrisBiome;
import com.volmit.iris.object.IrisDecorator;
import com.volmit.iris.util.RNG;
import org.bukkit.Material;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;
import java.util.function.Predicate;
@ -17,80 +18,121 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData>
private final RNG rng;
public IrisDecorantActuator(Engine engine) {
super(engine);
super(engine, "Decorant");
this.rng = new RNG(engine.getTarget().getWorld().getSeed());
}
@Override
public void actuate(int x, int z, Hunk<BlockData> output) {
output.iterateSurfaces2D(getParallelism(), PREDICATE_SOLID, (hunkRelativeX, hunkRelativeZ, hunkOffsetX, hunkOffsetZ, top, bottom, lastBottom, h) ->
{
int realX = x + hunkOffsetX + hunkRelativeX;
int realZ = z + hunkOffsetZ + hunkRelativeZ;
RNG g = rng.nextParallelRNG(realX).nextParallelRNG(realZ); //TODO: Technically incorrect! Use chunkX & chunkZ
IrisBiome b = getComplex().getTrueBiomeStream().get(realX, realZ);
boolean surface = lastBottom == -1;
int floor = top + 1;
int ceiling = lastBottom == -1 ? floor < getDimension().getFluidHeight() ? getDimension().getFluidHeight() : output.getHeight() : lastBottom - 1;
int height = ceiling - floor;
private boolean shouldDecorate()
{
return getEngine().getDimension().isDecorate();
}
if(height < 2)
private boolean shouldRayDecorate()
{
return getEngine().getDimension().isCarving() || getEngine().getDimension().isCaves() || getEngine().getDimension().isVanillaCaves() || getEngine().getDimension().isRavines();
}
@Override
public void onActuate(int x, int z, Hunk<BlockData> output) {
if(!shouldDecorate())
{
return;
}
if(shouldRayDecorate())
{
output.iterateSurfaces2D(getParallelism(), PREDICATE_SOLID, (hunkRelativeX, hunkRelativeZ, hunkOffsetX, hunkOffsetZ, top, bottom, lastBottom, h) -> decorateLayer(x, z, hunkRelativeX, hunkRelativeZ, hunkOffsetX, hunkOffsetZ,top,bottom,lastBottom,h));
}
else
{
output.compute2D(getParallelism(), (xx, yy, zz, h) -> {
int he;
for(int i = 0; i < h.getWidth(); i++)
{
for(int j = 0; j < h.getDepth(); j++)
{
he = getComplex().getHeightFluidStream().get(x + xx+i, z + zz+j).intValue();
decorateLayer(x, z, i, j, xx, zz, he, 0, getEngine().getHeight(), h);
}
}
});
}
}
private void decorateLayer(int x, int z, int hunkRelativeX, int hunkRelativeZ, int hunkOffsetX, int hunkOffsetZ, int top, int bottom,int lastBottom, Hunk<BlockData> h)
{
int realX = x + hunkOffsetX + hunkRelativeX;
int realZ = z + hunkOffsetZ + hunkRelativeZ;
IrisBiome b = getComplex().getTrueBiomeStream().get(realX, realZ);
if(b.getDecorators().isEmpty())
{
return;
}
RNG g = rng.nextParallelRNG(realX >> 4).nextParallelRNG(realZ >> 4);
boolean surface = lastBottom == -1;
int floor = top + 1;
int ceiling = lastBottom == -1 ? floor < getDimension().getFluidHeight() ? getDimension().getFluidHeight() : getEngine().getHeight() : lastBottom - 1;
int height = ceiling - floor;
if(height < 2)
{
return;
}
IrisDecorator deco = getComplex().getTerrainSurfaceDecoration().get(realX, realZ);
if(deco != null)
{
if(deco.isStacking())
{
return;
int stack = Math.min(g.i(deco.getStackMin(), deco.getStackMax()), height);
for(int i = 0; i < stack; i++)
{
h.set(hunkRelativeX, i + floor, hunkRelativeZ, deco.getBlockData100(b, rng, realX - i, realZ + i, getData()));
}
if(deco.getTopPalette().isNotEmpty())
{
h.set(hunkRelativeX, stack + floor - 1, hunkRelativeZ, deco.getBlockDataForTop(b, rng, realX - stack, realZ + stack, getData()));
}
}
IrisDecorator deco = getComplex().getTerrainSurfaceDecoration().get(realX, realZ);
if(deco != null)
else
{
if(deco.isStacking())
h.set(hunkRelativeX, floor, hunkRelativeZ, deco.getBlockData100(b, rng, realX, realZ, getData()));
}
}
if(!surface)
{
IrisDecorator cdeco = getComplex().getTerrainCeilingDecoration().get(realX, realZ);
if(cdeco != null)
{
if(cdeco.isStacking())
{
int stack = Math.min(g.i(deco.getStackMin(), deco.getStackMax()), height);
int stack = Math.min(g.i(cdeco.getStackMin(), cdeco.getStackMax()), height);
for(int i = 0; i < stack; i++)
{
h.set(hunkRelativeX, i + floor, hunkRelativeZ, deco.getBlockData100(b, rng, realX - i, realZ + i, getData()));
h.set(hunkRelativeX, -i + ceiling, hunkRelativeZ, cdeco.getBlockData100(b, rng, realX - i, realZ + i, getData()));
}
if(deco.getTopPalette().isNotEmpty())
if(cdeco.getTopPalette().isNotEmpty())
{
h.set(hunkRelativeX, stack + floor - 1, hunkRelativeZ, deco.getBlockDataForTop(b, rng, realX - stack, realZ + stack, getData()));
h.set(hunkRelativeX, -stack + ceiling - 1, hunkRelativeZ, cdeco.getBlockDataForTop(b, rng, realX - stack, realZ + stack, getData()));
}
}
else
{
h.set(hunkRelativeX, floor, hunkRelativeZ, deco.getBlockData100(b, rng, realX, realZ, getData()));
h.set(hunkRelativeX, ceiling, hunkRelativeZ, cdeco.getBlockData100(b, rng, realX, realZ, getData()));
}
}
if(!surface)
{
IrisDecorator cdeco = getComplex().getTerrainCeilingDecoration().get(realX, realZ);
if(cdeco != null)
{
if(cdeco.isStacking())
{
int stack = Math.min(g.i(cdeco.getStackMin(), cdeco.getStackMax()), height);
for(int i = 0; i < stack; i++)
{
h.set(hunkRelativeX, -i + ceiling, hunkRelativeZ, cdeco.getBlockData100(b, rng, realX - i, realZ + i, getData()));
}
if(cdeco.getTopPalette().isNotEmpty())
{
h.set(hunkRelativeX, -stack + ceiling - 1, hunkRelativeZ, cdeco.getBlockDataForTop(b, rng, realX - stack, realZ + stack, getData()));
}
}
else
{
h.set(hunkRelativeX, ceiling, hunkRelativeZ, cdeco.getBlockData100(b, rng, realX, realZ, getData()));
}
}
}
});
}
}
}

View File

@ -1,32 +1,65 @@
package com.volmit.iris.v2.generator.actuator;
import com.volmit.iris.object.IrisBiome;
import com.volmit.iris.object.IrisBiomePaletteLayer;
import com.volmit.iris.util.KList;
import com.volmit.iris.util.RNG;
import com.volmit.iris.v2.scaffold.engine.Engine;
import com.volmit.iris.v2.scaffold.engine.EngineAssignedActuator;
import com.volmit.iris.v2.scaffold.hunk.Hunk;
import org.bukkit.Material;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;
public class IrisTerrainActuator extends EngineAssignedActuator<BlockData>
{
private static final BlockData AIR = Material.AIR.createBlockData();
private final RNG rng;
public IrisTerrainActuator(Engine engine) {
super(engine);
super(engine, "Terrain");
rng = new RNG(engine.getWorld().getSeed());
}
@Override
public void actuate(int x, int z, Hunk<BlockData> output) {
public void onActuate(int x, int z, Hunk<BlockData> output) {
output.compute2D(getParallelism(), (xx, yy, zz, h) -> {
int i,zf;
int i,zf, depth, atDepth;
double he;
BlockData block;
IrisBiome biome;
for(int xf = 0; xf < h.getWidth(); xf++)
{
for(zf = 0; zf < h.getDepth(); zf++)
{
he = Math.min(h.getHeight(), getComplex().getHeightFluidStream().get(xx+xf+x, zz+zf+z));
biome = getComplex().getTrueBiomeStream().get(xx+xf+x, zz+zf+z);
KList<BlockData> blocks = biome.generateLayers(xx+xf+x, zz+zf+z, rng, (int)he, (int)he, getData());
for(i = 0; i < he; i++)
{
h.set(xx+xf, i, zz+zf, getComplex().getTerrainStream().get(xx+xf+x, i, zz+zf+z));
depth = ((int)he) - i;
if(i > he && i <= he)
{
h.set(xx+xf, i, zz+zf, getComplex().getFluidStream().get(xx+xf+x, zz+zf+z));
continue;
}
if(depth < -1)
{
h.set(xx+xf, i, zz+zf, AIR);
continue;
}
if(blocks.hasIndex(blocks.last() - ((int)he - depth)))
{
h.set(xx+xf, i, zz+zf, blocks.get(blocks.last() - ((int)he - depth)));
continue;
}
h.set(xx+xf, i, zz+zf, getComplex().getRockStream().get(xx+xf+x, zz+zf+z));
}
}
}

View File

@ -1,5 +1,6 @@
package com.volmit.iris.v2.scaffold.engine;
import com.volmit.iris.util.RollingSequence;
import com.volmit.iris.v2.generator.IrisComplex;
import com.volmit.iris.v2.scaffold.hunk.Hunk;
import com.volmit.iris.v2.scaffold.parallax.ParallaxAccess;
@ -10,6 +11,10 @@ public interface EngineActuator<O>
{
public Engine getEngine();
public RollingSequence getMetrics();
public String getName();
public default IrisDataManager getData()
{
return getEngine().getData();

View File

@ -1,11 +1,38 @@
package com.volmit.iris.v2.scaffold.engine;
import com.volmit.iris.util.PrecisionStopwatch;
import com.volmit.iris.util.RollingSequence;
import com.volmit.iris.v2.scaffold.hunk.Hunk;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.bukkit.block.data.BlockData;
@AllArgsConstructor
public abstract class EngineAssignedActuator<T> implements EngineActuator<T>
{
@Getter
private final Engine engine;
@Getter
private final RollingSequence metrics;
@Getter
private final String name;
public EngineAssignedActuator(Engine engine, String name)
{
this.engine = engine;
this.name = name;
metrics = new RollingSequence(16);
}
public abstract void onActuate(int x, int z, Hunk<T> output);
@Override
public void actuate(int x, int z, Hunk<T> output) {
PrecisionStopwatch p = PrecisionStopwatch.start();
onActuate(x, z, output);
p.end();
getMetrics().put(p.getMilliseconds());
}
}

View File

@ -22,7 +22,7 @@ import java.util.List;
import java.util.Random;
import java.util.concurrent.atomic.AtomicBoolean;
public class EngineCompositeGenerator extends ChunkGenerator {
public class EngineCompositeGenerator extends ChunkGenerator implements Hotloadable {
private EngineCompound compound;
private final AtomicBoolean initialized;
private final String dimensionHint;
@ -39,6 +39,11 @@ public class EngineCompositeGenerator extends ChunkGenerator {
initialized = new AtomicBoolean(false);
}
public void hotload()
{
initialized.lazySet(false);
}
private synchronized IrisDimension getDimension(World world) {
String hint = dimensionHint;
IrisDimension dim = null;
@ -71,14 +76,14 @@ public class EngineCompositeGenerator extends ChunkGenerator {
throw new RuntimeException("Cannot find iris dimension data for world: " + world.getName() + "! FAILED");
}
dim = Iris.globaldata.getDimensionLoader().load(hint);
dim = Iris.globaldata.preferFolder(hint).getDimensionLoader().load(hint);
if (dim == null) {
throw new RuntimeException("Cannot find dimension: " + hint);
}
if (production) {
dim = new IrisDataManager(getDataFolder(world), true).getDimensionLoader().load(dim.getLoadKey());
dim = new IrisDataManager(getDataFolder(world), true).preferFolder(dim.getLoadKey()).getDimensionLoader().load(dim.getLoadKey());
if (dim == null) {
throw new RuntimeException("Cannot find dimension: " + hint);
@ -94,7 +99,9 @@ public class EngineCompositeGenerator extends ChunkGenerator {
}
IrisDataManager data = production ? new IrisDataManager(getDataFolder(world)) : Iris.globaldata.copy();
compound = new IrisEngineCompound(world, getDimension(world), data, Iris.getThreadCount());
IrisDimension dim = getDimension(world);
data.preferFolder(dim.getLoadKey());
compound = new IrisEngineCompound(world, dim, data, Iris.getThreadCount());
initialized.set(true);
}
@ -111,7 +118,7 @@ public class EngineCompositeGenerator extends ChunkGenerator {
Hunk<Biome> biomes = Hunk.view(biome);
PrecisionStopwatch p = PrecisionStopwatch.start();
compound.generate(x * 16, z * 16, blocks, biomes);
System.out.println("Generated " + x + "," + z + " in " + Form.duration(p.getMilliseconds(), 0));
System.out.println("Generated " + x + "," + z + " in " + Form.duration(p.getMilliseconds(), 0) + " (Terrain: " + Form.duration(compound.getEngine(0).getFramework().getTerrainActuator().getMetrics().getAverage(), 2) + ", Biome: " + Form.duration(compound.getEngine(0).getFramework().getBiomeActuator().getMetrics().getAverage(), 2) + ", Decorant: " + Form.duration(compound.getEngine(0).getFramework().getDecorantActuator().getMetrics().getAverage(), 2) + ")");
return chunk;
}

View File

@ -0,0 +1,5 @@
package com.volmit.iris.v2.scaffold.engine;
public interface Hotloadable {
public void hotload();
}

View File

@ -36,6 +36,11 @@ public class ChunkBiomeHunkView implements Hunk<Biome>
@Override
public void setRaw(int x, int y, int z, Biome t)
{
if(t == null)
{
return;
}
Iris.edit.setBiome(chunk.getWorld(), x + (chunk.getX() * 16), y, z + (chunk.getZ() * 16), t);
}

View File

@ -34,6 +34,11 @@ public class ChunkDataHunkView implements Hunk<BlockData>
@Override
public void set(int x1, int y1, int z1, int x2, int y2, int z2, BlockData t)
{
if(t == null)
{
return;
}
enforceBounds(x1, y1, z1, x2 - x1, y2 - y1, z2 - z1);
chunk.setRegion(x1, y1, z1, x2, y2, z2, t);
}
@ -41,6 +46,11 @@ public class ChunkDataHunkView implements Hunk<BlockData>
@Override
public void setRaw(int x, int y, int z, BlockData t)
{
if(t == null)
{
return;
}
chunk.setBlock(x, y, z, t);
}

View File

@ -36,6 +36,11 @@ public class ChunkHunkView implements Hunk<BlockData>
@Override
public void setRaw(int x, int y, int z, BlockData t)
{
if(t == null)
{
return;
}
Iris.edit.set(chunk.getWorld(), x + (chunk.getX() * 16), y, z + (chunk.getZ() * 16), t);
}

View File

@ -1,4 +1,6 @@
package com.volmit.iris.v2.scaffold.hunk;
package com.volmit.iris.v2.scaffold.hunk.view;
import com.volmit.iris.v2.scaffold.hunk.Hunk;
public class HunkView<T> implements Hunk<T>
{

View File

@ -14,13 +14,13 @@ public class InvertedHunkView<T> implements Hunk<T>
@Override
public void setRaw(int x, int y, int z, T t)
{
src.setRaw(x, getHeight() - y, z, t);
src.setRaw(x, (getHeight() -1) - y, z, t);
}
@Override
public T getRaw(int x, int y, int z)
{
return src.getRaw(x, getHeight() - y, z);
return src.getRaw(x, y, z);
}
@Override