mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-25 10:09:14 +00:00
Fix biome issues
This commit is contained in:
@@ -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("test")).createWorld(), 0, 70, 0));
|
||||
.generator(EngineCompositeGenerator.newStudioWorld("overworld")).createWorld(), 0, 70, 0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.volmit.iris.v2.scaffold.engine.Engine;
|
||||
import com.volmit.iris.v2.scaffold.engine.EngineFramework;
|
||||
import com.volmit.iris.v2.scaffold.engine.EngineTarget;
|
||||
import com.volmit.iris.v2.scaffold.hunk.Hunk;
|
||||
import com.volmit.iris.v2.scaffold.parallel.MultiBurst;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.block.Biome;
|
||||
@@ -31,8 +32,14 @@ public class IrisEngine implements Engine
|
||||
|
||||
@Override
|
||||
public void generate(int x, int z, Hunk<BlockData> blocks, Hunk<Biome> biomes) {
|
||||
getFramework().getTerrainActuator().actuate(x, z, blocks);
|
||||
getFramework().getDecorantActuator().actuate(x, z, blocks);
|
||||
getFramework().getBiomeActuator().actuate(x, z, biomes);
|
||||
MultiBurst.burst.burst(
|
||||
() -> blocks.compute2D(getParallelism(), (xx,yy,zz, b) -> {
|
||||
getFramework().getTerrainActuator().actuate(x+xx, z+zz, b);
|
||||
getFramework().getDecorantActuator().actuate(x+xx, z+zz, b);
|
||||
}),
|
||||
()->biomes.compute2D(getParallelism(), (xx,yy,zz,b) -> {
|
||||
getFramework().getBiomeActuator().actuate(x+xx, z+zz, b);
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,23 +12,21 @@ public class IrisBiomeActuator extends EngineAssignedActuator<Biome>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActuate(int x, int z, Hunk<Biome> output) {
|
||||
output.compute2D(getParallelism(), (xx, yy, zz, h) -> {
|
||||
int i,zf;
|
||||
Biome v;
|
||||
public void onActuate(int x, int z, Hunk<Biome> h) {
|
||||
int i,zf;
|
||||
Biome v;
|
||||
|
||||
for(int xf = 0; xf < h.getWidth(); xf++)
|
||||
for(int xf = 0; xf < h.getWidth(); xf++)
|
||||
{
|
||||
for(zf = 0; zf < h.getDepth(); zf++)
|
||||
{
|
||||
for(zf = 0; zf < h.getDepth(); zf++)
|
||||
{
|
||||
v = getComplex().getTrueBiomeDerivativeStream().get(xx+xf+x, zz+zf+z);
|
||||
v = getComplex().getTrueBiomeDerivativeStream().get(xf+x, zf+z);
|
||||
|
||||
for(i = 0; i < h.getHeight(); i++)
|
||||
{
|
||||
h.set(xx+xf, i, zz+zf, v);
|
||||
}
|
||||
for(i = 0; i < h.getHeight(); i++)
|
||||
{
|
||||
h.set(xf, i, zf, v);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,22 +41,20 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData>
|
||||
|
||||
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));
|
||||
output.iterateSurfaces2D(0, 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++)
|
||||
int he;
|
||||
for(int i = 0; i < output.getWidth(); i++)
|
||||
{
|
||||
for(int j = 0; j < output.getDepth(); j++)
|
||||
{
|
||||
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);
|
||||
}
|
||||
he = getComplex().getHeightFluidStream().get(x + i, z + j).intValue();
|
||||
decorateLayer(x, z, i, j, 0, 0, he, 0, getEngine().getHeight(), output);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,6 +80,11 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData>
|
||||
return;
|
||||
}
|
||||
|
||||
if(b.isShore() && floor <= getDimension().getFluidHeight())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IrisDecorator deco = getComplex().getTerrainSurfaceDecoration().get(realX, realZ);
|
||||
|
||||
if(deco != null)
|
||||
|
||||
@@ -22,47 +22,48 @@ public class IrisTerrainActuator extends EngineAssignedActuator<BlockData>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActuate(int x, int z, Hunk<BlockData> output) {
|
||||
output.compute2D(getParallelism(), (xx, yy, zz, h) -> {
|
||||
int i,zf, depth, atDepth;
|
||||
double he;
|
||||
BlockData block;
|
||||
IrisBiome biome;
|
||||
public void onActuate(int x, int z, Hunk<BlockData> h) {
|
||||
int i,zf, depth, realX, realZ,hf, he;
|
||||
IrisBiome biome;
|
||||
KList<BlockData> blocks;
|
||||
|
||||
for(int xf = 0; xf < h.getWidth(); xf++)
|
||||
for(int xf = 0; xf < h.getWidth(); xf++)
|
||||
{
|
||||
for(zf = 0; zf < h.getDepth(); zf++)
|
||||
{
|
||||
for(zf = 0; zf < h.getDepth(); zf++)
|
||||
realX = xf + x;
|
||||
realZ = zf + z;
|
||||
he = (int) Math.round(Math.min(h.getHeight(), getComplex().getHeightStream().get(realX, realZ)));
|
||||
hf = (int) Math.round(Math.max(Math.min(h.getHeight(), getDimension().getFluidHeight()), he));
|
||||
biome = getComplex().getTrueBiomeStream().get(realX, realZ);
|
||||
blocks = null;
|
||||
|
||||
for(i = hf; i >= 0; i--)
|
||||
{
|
||||
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++)
|
||||
if(i > he && i <= hf)
|
||||
{
|
||||
depth = ((int)he) - i;
|
||||
h.set(xf, i, zf, getComplex().getFluidStream().get(realX, +realZ));
|
||||
continue;
|
||||
}
|
||||
|
||||
if(i > he && i <= he)
|
||||
if(i <= he)
|
||||
{
|
||||
depth = he - i;
|
||||
if(blocks == null)
|
||||
{
|
||||
h.set(xx+xf, i, zz+zf, getComplex().getFluidStream().get(xx+xf+x, zz+zf+z));
|
||||
blocks = biome.generateLayers(realX, realZ, rng, (int)he, (int)he, getData());
|
||||
}
|
||||
|
||||
if(blocks.hasIndex(depth))
|
||||
{
|
||||
h.set(xf, i, zf, blocks.get(depth));
|
||||
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));
|
||||
h.set(xf, i, zf, getComplex().getRockStream().get(realX, realZ));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,53 +7,7 @@ import com.volmit.iris.v2.scaffold.parallax.ParallaxAccess;
|
||||
import com.volmit.iris.manager.IrisDataManager;
|
||||
import com.volmit.iris.object.IrisDimension;
|
||||
|
||||
public interface EngineActuator<O>
|
||||
public interface EngineActuator<O> extends EngineComponent
|
||||
{
|
||||
public Engine getEngine();
|
||||
|
||||
public RollingSequence getMetrics();
|
||||
|
||||
public String getName();
|
||||
|
||||
public default IrisDataManager getData()
|
||||
{
|
||||
return getEngine().getData();
|
||||
}
|
||||
|
||||
public default ParallaxAccess getParallax()
|
||||
{
|
||||
return getEngine().getParallax();
|
||||
}
|
||||
|
||||
public default EngineTarget getTarget()
|
||||
{
|
||||
return getEngine().getTarget();
|
||||
}
|
||||
|
||||
public default IrisDimension getDimension()
|
||||
{
|
||||
return getEngine().getDimension();
|
||||
}
|
||||
|
||||
public default long getSeed()
|
||||
{
|
||||
return getTarget().getWorld().getSeed();
|
||||
}
|
||||
|
||||
public default EngineFramework getFramework()
|
||||
{
|
||||
return getEngine().getFramework();
|
||||
}
|
||||
|
||||
public default int getParallelism()
|
||||
{
|
||||
return getEngine().getParallelism();
|
||||
}
|
||||
|
||||
public default IrisComplex getComplex()
|
||||
{
|
||||
return getFramework().getComplex();
|
||||
}
|
||||
|
||||
public void actuate(int x, int z, Hunk<O> output);
|
||||
}
|
||||
|
||||
@@ -7,32 +7,17 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
public abstract class EngineAssignedActuator<T> implements EngineActuator<T>
|
||||
public abstract class EngineAssignedActuator<T> extends EngineAssignedComponent 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);
|
||||
super(engine, name);
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.volmit.iris.v2.scaffold.engine;
|
||||
|
||||
import com.volmit.iris.util.RollingSequence;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class EngineAssignedComponent implements EngineComponent {
|
||||
private final Engine engine;
|
||||
private final RollingSequence metrics;
|
||||
private final String name;
|
||||
|
||||
public EngineAssignedComponent(Engine engine, String name)
|
||||
{
|
||||
this.engine = engine;
|
||||
this.metrics = new RollingSequence(16);
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
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.Getter;
|
||||
|
||||
public abstract class EngineAssignedModifier<T> extends EngineAssignedComponent implements EngineModifier<T>
|
||||
{
|
||||
public EngineAssignedModifier(Engine engine, String name)
|
||||
{
|
||||
super(engine, name);
|
||||
}
|
||||
|
||||
public abstract void onModify(Hunk<T> output);
|
||||
|
||||
@Override
|
||||
public void modify(Hunk<T> output) {
|
||||
onModify(output);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.volmit.iris.v2.scaffold.engine;
|
||||
|
||||
import com.volmit.iris.manager.IrisDataManager;
|
||||
import com.volmit.iris.object.IrisDimension;
|
||||
import com.volmit.iris.util.RollingSequence;
|
||||
import com.volmit.iris.v2.generator.IrisComplex;
|
||||
import com.volmit.iris.v2.scaffold.parallax.ParallaxAccess;
|
||||
|
||||
public interface EngineComponent {
|
||||
public Engine getEngine();
|
||||
|
||||
public RollingSequence getMetrics();
|
||||
|
||||
public String getName();
|
||||
|
||||
public default IrisDataManager getData()
|
||||
{
|
||||
return getEngine().getData();
|
||||
}
|
||||
|
||||
public default ParallaxAccess getParallax()
|
||||
{
|
||||
return getEngine().getParallax();
|
||||
}
|
||||
|
||||
public default EngineTarget getTarget()
|
||||
{
|
||||
return getEngine().getTarget();
|
||||
}
|
||||
|
||||
public default IrisDimension getDimension()
|
||||
{
|
||||
return getEngine().getDimension();
|
||||
}
|
||||
|
||||
public default long getSeed()
|
||||
{
|
||||
return getTarget().getWorld().getSeed();
|
||||
}
|
||||
|
||||
public default EngineFramework getFramework()
|
||||
{
|
||||
return getEngine().getFramework();
|
||||
}
|
||||
|
||||
public default int getParallelism()
|
||||
{
|
||||
return getEngine().getParallelism();
|
||||
}
|
||||
|
||||
public default IrisComplex getComplex()
|
||||
{
|
||||
return getFramework().getComplex();
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.manager.IrisDataManager;
|
||||
import com.volmit.iris.object.IrisDimension;
|
||||
import com.volmit.iris.util.Form;
|
||||
import com.volmit.iris.util.M;
|
||||
import com.volmit.iris.util.PrecisionStopwatch;
|
||||
import com.volmit.iris.v2.generator.IrisEngineCompound;
|
||||
import com.volmit.iris.v2.scaffold.hunk.Hunk;
|
||||
@@ -41,6 +42,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements Hotloada
|
||||
|
||||
public void hotload()
|
||||
{
|
||||
Iris.globaldata.dump();
|
||||
initialized.lazySet(false);
|
||||
}
|
||||
|
||||
@@ -116,9 +118,9 @@ public class EngineCompositeGenerator extends ChunkGenerator implements Hotloada
|
||||
ChunkData chunk = createChunkData(world);
|
||||
Hunk<BlockData> blocks = Hunk.view(chunk);
|
||||
Hunk<Biome> biomes = Hunk.view(biome);
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
long m = M.ms();
|
||||
compound.generate(x * 16, z * 16, blocks, biomes);
|
||||
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) + ")");
|
||||
System.out.println("Generated " + x + "," + z + " in " + Form.duration(M.ms() - m, 0));
|
||||
return chunk;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.volmit.iris.v2.scaffold.engine;
|
||||
|
||||
import com.volmit.iris.manager.IrisDataManager;
|
||||
import com.volmit.iris.object.IrisDimension;
|
||||
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;
|
||||
|
||||
public interface EngineModifier<T> extends EngineComponent {
|
||||
public void modify(Hunk<T> t);
|
||||
}
|
||||
@@ -27,6 +27,20 @@ public class BurstExecutor
|
||||
}
|
||||
}
|
||||
|
||||
public BurstExecutor queue(Runnable[] r)
|
||||
{
|
||||
synchronized(futures)
|
||||
{
|
||||
for(Runnable i : r)
|
||||
{
|
||||
CompletableFuture<Void> c = CompletableFuture.runAsync(i, executor);
|
||||
futures.add(c);
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public void complete()
|
||||
{
|
||||
synchronized(futures)
|
||||
|
||||
@@ -13,6 +13,11 @@ public class MultiBurst
|
||||
service = Executors.newWorkStealingPool(tc);
|
||||
}
|
||||
|
||||
public void burst(Runnable... r)
|
||||
{
|
||||
burst(r.length).queue(r).complete();
|
||||
}
|
||||
|
||||
public BurstExecutor burst(int estimate)
|
||||
{
|
||||
return new BurstExecutor(service, estimate);
|
||||
|
||||
Reference in New Issue
Block a user