mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-19 10:43:14 +00:00
Bam
This commit is contained in:
parent
7d7269bfe6
commit
6e294d1363
@ -3,32 +3,23 @@ package com.volmit.iris.gen.v2;
|
|||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.gen.v2.scaffold.hunk.Hunk;
|
||||||
import com.volmit.iris.gen.v2.scaffold.Hunk;
|
|
||||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||||
import com.volmit.iris.gen.v2.scaffold.multicore.MultiBurst;
|
|
||||||
import com.volmit.iris.manager.IrisDataManager;
|
import com.volmit.iris.manager.IrisDataManager;
|
||||||
import com.volmit.iris.object.IrisDimension;
|
import com.volmit.iris.object.IrisDimension;
|
||||||
import com.volmit.iris.util.KMap;
|
|
||||||
import com.volmit.iris.util.M;
|
|
||||||
import com.volmit.iris.util.PrecisionStopwatch;
|
import com.volmit.iris.util.PrecisionStopwatch;
|
||||||
import com.volmit.iris.util.RollingSequence;
|
|
||||||
|
|
||||||
public class IrisTerrainGenerator
|
public class IrisTerrainGenerator
|
||||||
{
|
{
|
||||||
private long seed;
|
private long seed;
|
||||||
private MultiBurst burster;
|
|
||||||
private IrisDataManager data;
|
private IrisDataManager data;
|
||||||
private IrisDimension dimension;
|
private IrisDimension dimension;
|
||||||
private IrisComplex complex;
|
private IrisComplex complex;
|
||||||
private int parallelism;
|
|
||||||
|
|
||||||
public IrisTerrainGenerator(long seed, IrisDimension dimension, IrisDataManager data)
|
public IrisTerrainGenerator(long seed, IrisDimension dimension, IrisDataManager data)
|
||||||
{
|
{
|
||||||
this.seed = seed;
|
this.seed = seed;
|
||||||
complex = new IrisComplex();
|
complex = new IrisComplex();
|
||||||
parallelism = 6;
|
|
||||||
burster = new MultiBurst((parallelism * parallelism) * 4);
|
|
||||||
this.data = data;
|
this.data = data;
|
||||||
this.dimension = dimension;
|
this.dimension = dimension;
|
||||||
|
|
||||||
@ -41,29 +32,18 @@ public class IrisTerrainGenerator
|
|||||||
}
|
}
|
||||||
|
|
||||||
private <V, T> void fill2D(ProceduralStream<T> t, Hunk<V> h, double x, double z, ProceduralStream<V> v)
|
private <V, T> void fill2D(ProceduralStream<T> t, Hunk<V> h, double x, double z, ProceduralStream<V> v)
|
||||||
{
|
|
||||||
if(parallelism <= 1)
|
|
||||||
{
|
{
|
||||||
t.fill2D(h, x * 16, z * 16, v);
|
t.fill2D(h, x * 16, z * 16, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
t.fill2DParallel(burster.burst(parallelism * parallelism), parallelism, h, x * 16, z * 16, v);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private <V, T> void fill2DYLock(ProceduralStream<T> t, Hunk<V> h, double x, double z, ProceduralStream<V> v)
|
private <V, T> void fill2DYLock(ProceduralStream<T> t, Hunk<V> h, double x, double z, ProceduralStream<V> v)
|
||||||
{
|
|
||||||
if(parallelism <= 1)
|
|
||||||
{
|
{
|
||||||
t.fill2DYLocked(h, x * 16, z * 16, v);
|
t.fill2DYLocked(h, x * 16, z * 16, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
public void generateDecorations(int x, int z, Hunk<BlockData> blocks)
|
||||||
{
|
{
|
||||||
t.fill2DParallelYLocked(burster.burst(parallelism * parallelism), parallelism, h, x * 16, z * 16, v);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void generateTerrain(int x, int z, Hunk<BlockData> blocks)
|
public void generateTerrain(int x, int z, Hunk<BlockData> blocks)
|
||||||
|
@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.gen.v2.scaffold.Hunk;
|
import com.volmit.iris.gen.v2.scaffold.hunk.Hunk;
|
||||||
import com.volmit.iris.util.Form;
|
import com.volmit.iris.util.Form;
|
||||||
import com.volmit.iris.util.PrecisionStopwatch;
|
import com.volmit.iris.util.PrecisionStopwatch;
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ public class TestGen
|
|||||||
{
|
{
|
||||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||||
ChunkData c = createChunkData(world);
|
ChunkData c = createChunkData(world);
|
||||||
Hunk<Biome> b = Hunk.create(16, 256, 16);
|
Hunk<Biome> b = Hunk.newHunk(16, 256, 16);
|
||||||
tg.generate(x, z, Hunk.view(c), b);
|
tg.generate(x, z, Hunk.view(c), b);
|
||||||
|
|
||||||
for(int i = 0; i < 16; i++)
|
for(int i = 0; i < 16; i++)
|
||||||
|
@ -3,8 +3,8 @@ package com.volmit.iris.gen.v2.scaffold.layer;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
import com.volmit.iris.gen.v2.scaffold.Hunk;
|
|
||||||
import com.volmit.iris.gen.v2.scaffold.Significance;
|
import com.volmit.iris.gen.v2.scaffold.Significance;
|
||||||
|
import com.volmit.iris.gen.v2.scaffold.hunk.Hunk;
|
||||||
import com.volmit.iris.gen.v2.scaffold.multicore.BurstExecutor;
|
import com.volmit.iris.gen.v2.scaffold.multicore.BurstExecutor;
|
||||||
import com.volmit.iris.gen.v2.scaffold.stream.AddingStream;
|
import com.volmit.iris.gen.v2.scaffold.stream.AddingStream;
|
||||||
import com.volmit.iris.gen.v2.scaffold.stream.AwareConversionStream2D;
|
import com.volmit.iris.gen.v2.scaffold.stream.AwareConversionStream2D;
|
||||||
@ -293,163 +293,142 @@ public interface ProceduralStream<T> extends ProceduralLayer, Interpolated<T>
|
|||||||
return new FittedStream<T>(this, inMin, inMax, min, max);
|
return new FittedStream<T>(this, inMin, inMax, min, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default void fill(Hunk<T> h, double x, double y, double z, int parallelism)
|
||||||
|
{
|
||||||
|
h.compute3D(parallelism, (xx, yy, zz, hh) -> hh.iterate((xv, yv, zv) -> hh.set(xv, yv, zv, get(xx + xv + x, yy + yv + y, zz + zv + z))));
|
||||||
|
}
|
||||||
|
|
||||||
|
default <V> void fill2D(Hunk<V> h, double x, double z, V v, int parallelism)
|
||||||
|
{
|
||||||
|
h.compute2D(parallelism, (xx, __, zz, hh) ->
|
||||||
|
{
|
||||||
|
for(int i = 0; i < hh.getWidth(); i++)
|
||||||
|
{
|
||||||
|
for(int k = 0; k < hh.getDepth(); k++)
|
||||||
|
{
|
||||||
|
double n = getDouble(i + x + xx, k + z + zz);
|
||||||
|
|
||||||
|
for(int j = 0; j < Math.min(h.getHeight(), n); j++)
|
||||||
|
{
|
||||||
|
hh.set(i, j, k, v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
default <V> void fill2D(Hunk<V> h, double x, double z, ProceduralStream<V> v, int parallelism)
|
||||||
|
{
|
||||||
|
h.compute2D(parallelism, (xx, yy, zz, hh) ->
|
||||||
|
{
|
||||||
|
for(int i = 0; i < hh.getWidth(); i++)
|
||||||
|
{
|
||||||
|
for(int k = 0; k < hh.getDepth(); k++)
|
||||||
|
{
|
||||||
|
double n = getDouble(i + x + xx, k + z + zz);
|
||||||
|
|
||||||
|
for(int j = 0; j < Math.min(h.getHeight(), n); j++)
|
||||||
|
{
|
||||||
|
hh.set(i, j, k, v.get(i + x + xx, j + yy, k + z + zz));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
default <V> void fill2DYLocked(Hunk<V> h, double x, double z, V v, int parallelism)
|
||||||
|
{
|
||||||
|
h.compute2D(parallelism, (xx, yy, zz, hh) ->
|
||||||
|
{
|
||||||
|
for(int i = 0; i < hh.getWidth(); i++)
|
||||||
|
{
|
||||||
|
for(int k = 0; k < hh.getDepth(); k++)
|
||||||
|
{
|
||||||
|
double n = getDouble(i + x + xx, k + z + zz);
|
||||||
|
|
||||||
|
for(int j = 0; j < Math.min(h.getHeight(), n); j++)
|
||||||
|
{
|
||||||
|
hh.set(i, j, k, v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
default <V> void fill2DYLocked(Hunk<V> h, double x, double z, ProceduralStream<V> v, int parallelism)
|
||||||
|
{
|
||||||
|
h.compute2D(parallelism, (xx, yy, zz, hh) ->
|
||||||
|
{
|
||||||
|
for(int i = 0; i < hh.getWidth(); i++)
|
||||||
|
{
|
||||||
|
for(int k = 0; k < hh.getDepth(); k++)
|
||||||
|
{
|
||||||
|
double n = getDouble(i + x + xx, k + z + zz);
|
||||||
|
|
||||||
|
for(int j = 0; j < Math.min(h.getHeight(), n); j++)
|
||||||
|
{
|
||||||
|
hh.set(i, j, k, v.get(i + x + xx, k + z + zz));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
default <V> void fill3D(Hunk<V> h, double x, int y, double z, V v, int parallelism)
|
||||||
|
{
|
||||||
|
h.compute3D(parallelism, (xx, yy, zz, hh) -> hh.iterate((xv, yv, zv) ->
|
||||||
|
{
|
||||||
|
if(getDouble(xx + xv + x, yy + yv + y, zz + zv + z) > 0.5)
|
||||||
|
{
|
||||||
|
hh.set(xv, yv, zv, v);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
default <V> void fill3D(Hunk<V> h, double x, int y, double z, ProceduralStream<V> v, int parallelism)
|
||||||
|
{
|
||||||
|
h.compute3D(parallelism, (xx, yy, zz, hh) -> hh.iterate((xv, yv, zv) ->
|
||||||
|
{
|
||||||
|
if(getDouble(xx + xv + x, yy + yv + y, zz + zv + z) > 0.5)
|
||||||
|
{
|
||||||
|
hh.set(xv, yv, zv, v.get(xx + xv + x, yy + yv + y, zz + zv + z));
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
default void fill(Hunk<T> h, double x, double y, double z)
|
default void fill(Hunk<T> h, double x, double y, double z)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < h.getWidth(); i++)
|
fill(h, x, z, 4);
|
||||||
{
|
|
||||||
for(int j = 0; j < h.getHeight(); j++)
|
|
||||||
{
|
|
||||||
for(int k = 0; k < h.getDepth(); k++)
|
|
||||||
{
|
|
||||||
h.set(i, j, k, get(i + x, j + y, k + z));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
default <V> void fill2D(Hunk<V> h, double x, double z, V v)
|
default <V> void fill2D(Hunk<V> h, double x, double z, V v)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < h.getWidth(); i++)
|
fill2D(h, x, z, v, 4);
|
||||||
{
|
|
||||||
for(int k = 0; k < h.getDepth(); k++)
|
|
||||||
{
|
|
||||||
double n = getDouble(i + x, k + z);
|
|
||||||
|
|
||||||
for(int j = 0; j < Math.min(h.getHeight(), n); j++)
|
|
||||||
{
|
|
||||||
h.set(i, j, k, v);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
default <V> void fill3D(Hunk<V> h, double x, int y, double z, V v)
|
|
||||||
{
|
|
||||||
for(int i = 0; i < h.getWidth(); i++)
|
|
||||||
{
|
|
||||||
for(int k = 0; k < h.getDepth(); k++)
|
|
||||||
{
|
|
||||||
|
|
||||||
for(int j = 0; j < h.getHeight(); j++)
|
|
||||||
{
|
|
||||||
double n = getDouble(i + x, j + y, k + z);
|
|
||||||
|
|
||||||
if(n >= 0.5)
|
|
||||||
{
|
|
||||||
h.set(i, j, k, v);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
default <V> void fill3D(Hunk<V> h, double x, int y, double z, ProceduralStream<V> v)
|
|
||||||
{
|
|
||||||
for(int i = 0; i < h.getWidth(); i++)
|
|
||||||
{
|
|
||||||
for(int k = 0; k < h.getDepth(); k++)
|
|
||||||
{
|
|
||||||
for(int j = 0; j < h.getHeight(); j++)
|
|
||||||
{
|
|
||||||
double n = getDouble(i + x, j + y, k + z);
|
|
||||||
|
|
||||||
if(n >= 0.5)
|
|
||||||
{
|
|
||||||
h.set(i, j, k, v.get(i + x, j + y, k + z));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
default <V> void fill2D(Hunk<V> h, double x, double z, ProceduralStream<V> v)
|
default <V> void fill2D(Hunk<V> h, double x, double z, ProceduralStream<V> v)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < h.getWidth(); i++)
|
fill2D(h, x, z, v, 4);
|
||||||
{
|
}
|
||||||
for(int k = 0; k < h.getDepth(); k++)
|
|
||||||
{
|
|
||||||
double n = getDouble(i + x, k + z);
|
|
||||||
|
|
||||||
for(int j = 0; j < Math.min(h.getHeight(), n); j++)
|
default <V> void fill2DYLocked(Hunk<V> h, double x, double z, V v)
|
||||||
{
|
{
|
||||||
h.set(i, j, k, v.get(i + x, j, k + z));
|
fill2DYLocked(h, x, z, v, 4);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
default <V> void fill2DYLocked(Hunk<V> h, double x, double z, ProceduralStream<V> v)
|
default <V> void fill2DYLocked(Hunk<V> h, double x, double z, ProceduralStream<V> v)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < h.getWidth(); i++)
|
fill2DYLocked(h, x, z, v, 4);
|
||||||
{
|
|
||||||
for(int k = 0; k < h.getDepth(); k++)
|
|
||||||
{
|
|
||||||
double n = getDouble(i + x, k + z);
|
|
||||||
V yy = v.get(i + x, k + z);
|
|
||||||
for(int j = 0; j < Math.min(h.getHeight(), n); j++)
|
|
||||||
{
|
|
||||||
h.set(i, j, k, yy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
default <V> void fill2DParallel(BurstExecutor burster, int parallelismRooted, Hunk<V> h, double x, double z, ProceduralStream<V> v)
|
default <V> void fill3D(Hunk<V> h, double x, int y, double z, V v)
|
||||||
{
|
{
|
||||||
parallelismRooted = parallelismRooted % 2 != 0 ? parallelismRooted + 1 : parallelismRooted;
|
fill3D(h, x, y, z, v, 4);
|
||||||
KList<Runnable> future = new KList<>();
|
|
||||||
int w = h.getWidth() / parallelismRooted;
|
|
||||||
int d = h.getDepth() / parallelismRooted;
|
|
||||||
int i, j;
|
|
||||||
|
|
||||||
for(i = 0; i < h.getWidth(); i += w)
|
|
||||||
{
|
|
||||||
int ii = i;
|
|
||||||
|
|
||||||
for(j = 0; j < h.getDepth(); j += d)
|
|
||||||
{
|
|
||||||
int jj = j;
|
|
||||||
Hunk<V> mh = h.crop(i, 0, j, i + w, h.getHeight(), j + d);
|
|
||||||
burster.queue(() -> fill2D(mh, x + ii, z + jj, v));
|
|
||||||
future.add(() -> h.insert(ii, 0, jj, mh));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
burster.complete();
|
default <V> void fill3D(Hunk<V> h, double x, int y, double z, ProceduralStream<V> v)
|
||||||
|
|
||||||
for(Runnable vx : future)
|
|
||||||
{
|
{
|
||||||
vx.run();
|
fill3D(h, x, y, z, v, 4);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
default <V> void fill2DParallelYLocked(BurstExecutor burster, int parallelismRooted, Hunk<V> h, double x, double z, ProceduralStream<V> v)
|
|
||||||
{
|
|
||||||
parallelismRooted = parallelismRooted % 2 != 0 ? parallelismRooted + 1 : parallelismRooted;
|
|
||||||
KList<Runnable> future = new KList<>();
|
|
||||||
int w = h.getWidth() / parallelismRooted;
|
|
||||||
int d = h.getDepth() / parallelismRooted;
|
|
||||||
int i, j;
|
|
||||||
|
|
||||||
for(i = 0; i < h.getWidth(); i += w)
|
|
||||||
{
|
|
||||||
int ii = i;
|
|
||||||
|
|
||||||
for(j = 0; j < h.getDepth(); j += d)
|
|
||||||
{
|
|
||||||
int jj = j;
|
|
||||||
Hunk<V> mh = h.crop(i, 0, j, i + w, h.getHeight(), j + d);
|
|
||||||
burster.queue(() -> fill2DYLocked(mh, x + ii, z + jj, v));
|
|
||||||
future.add(() -> h.insert(ii, 0, jj, mh));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
burster.complete();
|
|
||||||
|
|
||||||
for(Runnable vx : future)
|
|
||||||
{
|
|
||||||
vx.run();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public T get(double x, double z);
|
public T get(double x, double z);
|
||||||
|
8
src/main/java/com/volmit/iris/util/Consumer4.java
Normal file
8
src/main/java/com/volmit/iris/util/Consumer4.java
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
package com.volmit.iris.util;
|
||||||
|
|
||||||
|
@SuppressWarnings("hiding")
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface Consumer4<A, B, C, D>
|
||||||
|
{
|
||||||
|
public void accept(A a, B b, C c, D d);
|
||||||
|
}
|
8
src/main/java/com/volmit/iris/util/Consumer5.java
Normal file
8
src/main/java/com/volmit/iris/util/Consumer5.java
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
package com.volmit.iris.util;
|
||||||
|
|
||||||
|
@SuppressWarnings("hiding")
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface Consumer5<A, B, C, D, E>
|
||||||
|
{
|
||||||
|
public void accept(A a, B b, C c, D d, E e);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user