mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-29 12:09:07 +00:00
Auto stash before merge of "master" and "origin/master"
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
package com.volmit.iris.gen.v2;
|
||||
|
||||
import com.volmit.iris.util.B;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.Interpolated;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.interpolation.Interpolated;
|
||||
import com.volmit.iris.manager.IrisDataManager;
|
||||
import com.volmit.iris.noise.CNG;
|
||||
import com.volmit.iris.object.DecorationPart;
|
||||
@@ -44,6 +45,7 @@ public class IrisComplex implements DataProvider
|
||||
private ProceduralStream<Double> maxHeightStream;
|
||||
private ProceduralStream<Double> overlayStream;
|
||||
private ProceduralStream<Double> heightFluidStream;
|
||||
private ProceduralStream<Double> slopeStream;
|
||||
private ProceduralStream<RNG> rngStream;
|
||||
private ProceduralStream<RNG> chunkRngStream;
|
||||
private ProceduralStream<IrisDecorator> terrainSurfaceDecoration;
|
||||
@@ -53,6 +55,7 @@ public class IrisComplex implements DataProvider
|
||||
private ProceduralStream<BlockData> terrainStream;
|
||||
private ProceduralStream<BlockData> rockStream;
|
||||
private ProceduralStream<BlockData> fluidStream;
|
||||
private ProceduralStream<BlockData> glassStream;
|
||||
|
||||
public IrisComplex()
|
||||
{
|
||||
@@ -86,11 +89,14 @@ public class IrisComplex implements DataProvider
|
||||
|
||||
public void flash(long seed, IrisDimension dimension, IrisDataManager data)
|
||||
{
|
||||
int cacheSize = 8192;
|
||||
BlockData glass = B.getBlockData("GLASS");
|
||||
this.rng = new RNG(seed);
|
||||
this.data = data;
|
||||
fluidHeight = dimension.getFluidHeight();
|
||||
generators = new KList<>();
|
||||
RNG rng = new RNG(seed);
|
||||
glassStream = ProceduralStream.of((x,y,z) -> glass, Interpolated.BLOCK_DATA);
|
||||
//@builder
|
||||
dimension.getRegions().forEach((i) -> data.getRegionLoader().load(i)
|
||||
.getAllBiomes(this).forEach((b) -> b
|
||||
@@ -98,7 +104,8 @@ public class IrisComplex implements DataProvider
|
||||
.forEach((c) -> registerGenerator(c.getCachedGenerator(this)))));
|
||||
overlayStream = ProceduralStream.ofDouble((x, z) -> 0D);
|
||||
dimension.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(seed), Interpolated.RNG)
|
||||
rngStream = ProceduralStream.of((x, z) -> new RNG(((x.longValue()) << 32) | (z.longValue() & 0xffffffffL))
|
||||
.nextParallelRNG(seed), Interpolated.RNG)
|
||||
.cache2D(64);
|
||||
chunkRngStream = rngStream.blockToChunkCoords();
|
||||
rockStream = dimension.getRockPalette().getLayerGenerator(rng.nextRNG(), data).stream()
|
||||
@@ -109,55 +116,57 @@ public class IrisComplex implements DataProvider
|
||||
.zoom(dimension.getRegionZoom())
|
||||
.selectRarity(dimension.getRegions())
|
||||
.convertCached((s) -> data.getRegionLoader().load(s))
|
||||
.cache2D(1024);
|
||||
caveBiomeStream = regionStream.convertCached((r)
|
||||
.cache2D(cacheSize);
|
||||
caveBiomeStream = regionStream.convertCached((r)
|
||||
-> dimension.getCaveBiomeStyle().create(rng.nextRNG()).stream()
|
||||
.zoom(r.getCaveBiomeZoom())
|
||||
.selectRarity(r.getCaveBiomes())
|
||||
.convertCached((s) -> data.getBiomeLoader().load(s)
|
||||
.setInferredType(InferredType.CAVE))
|
||||
).convertAware2D((str, x, z) -> str.get(x, z))
|
||||
.cache2D(1024);
|
||||
landBiomeStream = regionStream.convertCached((r)
|
||||
).convertAware2D(ProceduralStream::get)
|
||||
|
||||
.cache2D(cacheSize);
|
||||
landBiomeStream = regionStream.convertCached((r)
|
||||
-> dimension.getLandBiomeStyle().create(rng.nextRNG()).stream()
|
||||
.zoom(r.getLandBiomeZoom())
|
||||
.selectRarity(r.getLandBiomes())
|
||||
.convertCached((s) -> data.getBiomeLoader().load(s)
|
||||
.setInferredType(InferredType.LAND))
|
||||
).convertAware2D((str, x, z) -> str.get(x, z))
|
||||
.cache2D(1024);
|
||||
seaBiomeStream = regionStream.convertCached((r)
|
||||
).convertAware2D(ProceduralStream::get)
|
||||
.cache2D(cacheSize);
|
||||
seaBiomeStream = regionStream.convertCached((r)
|
||||
-> dimension.getSeaBiomeStyle().create(rng.nextRNG()).stream()
|
||||
.zoom(r.getSeaBiomeZoom())
|
||||
.selectRarity(r.getSeaBiomes())
|
||||
.convertCached((s) -> data.getBiomeLoader().load(s)
|
||||
.setInferredType(InferredType.SEA))
|
||||
).convertAware2D((str, x, z) -> str.get(x, z))
|
||||
.cache2D(1024);
|
||||
shoreBiomeStream = regionStream.convertCached((r)
|
||||
).convertAware2D(ProceduralStream::get)
|
||||
.cache2D(cacheSize);
|
||||
shoreBiomeStream = regionStream.convertCached((r)
|
||||
-> dimension.getShoreBiomeStyle().create(rng.nextRNG()).stream()
|
||||
.zoom(r.getShoreBiomeZoom())
|
||||
.selectRarity(r.getShoreBiomes())
|
||||
.convertCached((s) -> data.getBiomeLoader().load(s)
|
||||
.setInferredType(InferredType.SHORE))
|
||||
).convertAware2D((str, x, z) -> str.get(x, z))
|
||||
.cache2D(1024);
|
||||
).convertAware2D(ProceduralStream::get)
|
||||
.cache2D(cacheSize);
|
||||
bridgeStream = dimension.getContinentalStyle().create(rng.nextRNG()).stream()
|
||||
.convert((v) -> v >= dimension.getLandChance() ? InferredType.SEA : InferredType.LAND);
|
||||
baseBiomeStream = bridgeStream.convertAware2D((t, x, z) -> t.equals(InferredType.SEA)
|
||||
baseBiomeStream = bridgeStream.convertAware2D((t, x, z) -> t.equals(InferredType.SEA)
|
||||
? seaBiomeStream.get(x, z) : landBiomeStream.get(x, z))
|
||||
.convertAware2D(this::implode)
|
||||
.cache2D(1024);
|
||||
.convertAware2D(this::implode).cache2D(cacheSize);
|
||||
heightStream = baseBiomeStream.convertAware2D((b, x, z) -> getHeight(b, x, z, seed))
|
||||
.forceDouble().add(fluidHeight)
|
||||
.add2D(overlayStream::get).roundDouble()
|
||||
.cache2D(1024);
|
||||
.add(fluidHeight)
|
||||
.add2D(overlayStream::get)
|
||||
.roundDouble()
|
||||
.cache2D(cacheSize);
|
||||
slopeStream = heightStream.slope();
|
||||
trueBiomeStream = heightStream
|
||||
.convertAware2D((h, x, z) ->
|
||||
.convertAware2D((h, x, z) ->
|
||||
fixBiomeType(h, baseBiomeStream.get(x, z),
|
||||
regionStream.get(x, z), x, z, fluidHeight))
|
||||
.cache2D(1024);
|
||||
trueBiomeDerivativeStream = trueBiomeStream.convert((b) -> b.getDerivative());
|
||||
.cache2D(cacheSize);
|
||||
trueBiomeDerivativeStream = trueBiomeStream.convert(IrisBiome::getDerivative);
|
||||
heightFluidStream = heightStream.max(fluidHeight);
|
||||
maxHeightStream = ProceduralStream.ofDouble((x, z) -> 255D);
|
||||
terrainSurfaceDecoration = trueBiomeStream
|
||||
|
||||
@@ -2,18 +2,20 @@ package com.volmit.iris.gen.v2;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.utility.ProfiledStream;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.hunk.Hunk;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
import com.volmit.iris.manager.IrisDataManager;
|
||||
import com.volmit.iris.object.IrisBiome;
|
||||
import com.volmit.iris.object.IrisDecorator;
|
||||
import com.volmit.iris.object.IrisDimension;
|
||||
import com.volmit.iris.util.PrecisionStopwatch;
|
||||
import com.volmit.iris.util.RNG;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class IrisTerrainGenerator
|
||||
{
|
||||
@@ -33,7 +35,6 @@ public class IrisTerrainGenerator
|
||||
complex = new IrisComplex();
|
||||
this.data = data;
|
||||
this.dimension = dimension;
|
||||
|
||||
flash();
|
||||
}
|
||||
|
||||
@@ -130,16 +131,12 @@ public class IrisTerrainGenerator
|
||||
|
||||
public void generateTerrain(int x, int z, Hunk<BlockData> blocks)
|
||||
{
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
fill2D(complex.getHeightFluidStream(), blocks, x, z, complex.getTerrainStream());
|
||||
p.end();
|
||||
}
|
||||
|
||||
public void generateBiome(int x, int z, Hunk<Biome> blocks)
|
||||
{
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
fill2DYLock(complex.getMaxHeightStream(), blocks, x, z, complex.getTrueBiomeDerivativeStream());
|
||||
p.end();
|
||||
}
|
||||
|
||||
public void generate(int x, int z, Hunk<BlockData> blocks, Hunk<Biome> biomes)
|
||||
@@ -148,4 +145,8 @@ public class IrisTerrainGenerator
|
||||
generateBiome(x, z, biomes);
|
||||
generateDecorations(x, z, blocks);
|
||||
}
|
||||
|
||||
public void printMetrics(Player p) {
|
||||
ProfiledStream.print(Iris::verbose, complex.getTerrainStream());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@ package com.volmit.iris.gen.v2;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.volmit.iris.util.J;
|
||||
import net.minecraft.server.v1_16_R2.MinecraftServer;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.block.Biome;
|
||||
@@ -18,10 +21,9 @@ public class TestGen
|
||||
{
|
||||
public static void gen(Player p)
|
||||
{
|
||||
p.teleport(new WorldCreator("t/" + UUID.randomUUID().toString()).generator(new ChunkGenerator()
|
||||
IrisTerrainGenerator tg = new IrisTerrainGenerator(1337, Iris.globaldata.getDimensionLoader().load("overworld"), Iris.globaldata);
|
||||
p.teleport(new Location(new WorldCreator("t/" + UUID.randomUUID().toString()).generator(new ChunkGenerator()
|
||||
{
|
||||
IrisTerrainGenerator tg = new IrisTerrainGenerator(1337, Iris.globaldata.getDimensionLoader().load("overworld"), Iris.globaldata);
|
||||
|
||||
public boolean isParallelCapable()
|
||||
{
|
||||
return true;
|
||||
@@ -49,6 +51,10 @@ public class TestGen
|
||||
Iris.info("Generated " + x + " " + z + " in " + Form.duration(p.getMilliseconds(), 2));
|
||||
return c;
|
||||
}
|
||||
}).createWorld().getSpawnLocation());
|
||||
}).createWorld(), 0, 200, 0));
|
||||
|
||||
J.s(() -> {
|
||||
tg.printMetrics(p);
|
||||
}, 200);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.layer;
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
|
||||
public abstract class BasicStream<T> extends BasicLayer implements ProceduralStream<T>
|
||||
{
|
||||
private final ProceduralStream<T> source;
|
||||
|
||||
public BasicStream(ProceduralStream<T> source)
|
||||
{
|
||||
super();
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
public BasicStream()
|
||||
{
|
||||
this(null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ProceduralStream<T> getTypedSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProceduralStream<?> getSource() {
|
||||
return getTypedSource();
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract T get(double x, double z);
|
||||
|
||||
@Override
|
||||
public abstract T get(double x, double y, double z);
|
||||
|
||||
@Override
|
||||
public abstract double toDouble(T t);
|
||||
|
||||
@Override
|
||||
public abstract T fromDouble(double d);
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
|
||||
public class ClampedStream<T> extends BasicLayer implements ProceduralStream<T>
|
||||
{
|
||||
private final ProceduralStream<T> stream;
|
||||
private final double min;
|
||||
private final double max;
|
||||
|
||||
public ClampedStream(ProceduralStream<T> stream, double min, double max)
|
||||
{
|
||||
super();
|
||||
this.stream = stream;
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double toDouble(T t)
|
||||
{
|
||||
return stream.toDouble(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromDouble(double d)
|
||||
{
|
||||
return stream.fromDouble(d);
|
||||
}
|
||||
|
||||
private double clamp(double v)
|
||||
{
|
||||
return Math.max(Math.min(v, max), min);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double z)
|
||||
{
|
||||
return fromDouble(clamp(stream.getDouble(x, z)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double y, double z)
|
||||
{
|
||||
return fromDouble(clamp(stream.getDouble(x, y, z)));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
|
||||
public class CoordinateBitShiftLeftStream<T> extends BasicLayer implements ProceduralStream<T>
|
||||
{
|
||||
private final ProceduralStream<T> stream;
|
||||
private final int amount;
|
||||
|
||||
public CoordinateBitShiftLeftStream(ProceduralStream<T> stream, int amount)
|
||||
{
|
||||
super();
|
||||
this.stream = stream;
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double toDouble(T t)
|
||||
{
|
||||
return stream.toDouble(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromDouble(double d)
|
||||
{
|
||||
return stream.fromDouble(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double z)
|
||||
{
|
||||
return stream.get((int) x << amount, (int) z << amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double y, double z)
|
||||
{
|
||||
return stream.get((int) x << amount, (int) y << amount, (int) z << amount);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
|
||||
public class CoordinateBitShiftRightStream<T> extends BasicLayer implements ProceduralStream<T>
|
||||
{
|
||||
private final ProceduralStream<T> stream;
|
||||
private final int amount;
|
||||
|
||||
public CoordinateBitShiftRightStream(ProceduralStream<T> stream, int amount)
|
||||
{
|
||||
super();
|
||||
this.stream = stream;
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double toDouble(T t)
|
||||
{
|
||||
return stream.toDouble(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromDouble(double d)
|
||||
{
|
||||
return stream.fromDouble(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double z)
|
||||
{
|
||||
return stream.get((int) x >> amount, (int) z >> amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double y, double z)
|
||||
{
|
||||
return stream.get((int) x >> amount, (int) y >> amount, (int) z >> amount);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
|
||||
public class ForceDoubleStream<T> extends BasicLayer implements ProceduralStream<T>
|
||||
{
|
||||
private final ProceduralStream<T> stream;
|
||||
|
||||
public ForceDoubleStream(ProceduralStream<T> stream)
|
||||
{
|
||||
super();
|
||||
this.stream = stream;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double toDouble(T t)
|
||||
{
|
||||
return (double) t;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public T fromDouble(double d)
|
||||
{
|
||||
return (T) Double.valueOf(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double z)
|
||||
{
|
||||
return stream.get(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double y, double z)
|
||||
{
|
||||
return stream.get(x, y, z);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
|
||||
public class OffsetStream<T> extends BasicLayer implements ProceduralStream<T>
|
||||
{
|
||||
private final ProceduralStream<T> stream;
|
||||
private final double ox;
|
||||
private final double oy;
|
||||
private final double oz;
|
||||
|
||||
public OffsetStream(ProceduralStream<T> stream, double x, double y, double z)
|
||||
{
|
||||
super();
|
||||
this.stream = stream;
|
||||
this.ox = x;
|
||||
this.oy = y;
|
||||
this.oz = z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double toDouble(T t)
|
||||
{
|
||||
return stream.toDouble(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromDouble(double d)
|
||||
{
|
||||
return stream.fromDouble(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double z)
|
||||
{
|
||||
return stream.get(x + ox, z + oz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double y, double z)
|
||||
{
|
||||
return stream.get(x + ox, y + oy, z + oz);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.layer;
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
|
||||
public interface ProceduralLayer
|
||||
{
|
||||
@@ -1,36 +1,19 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.layer;
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.Significance;
|
||||
import com.volmit.iris.gen.v2.scaffold.hunk.Hunk;
|
||||
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.AwareConversionStream3D;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.CachedConversionStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.CachedStream2D;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ClampedStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ConversionStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.CoordinateBitShiftLeftStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.CoordinateBitShiftRightStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.DividingStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.FittedStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ForceDoubleStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.FunctionStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.Interpolated;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.MaxingStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.MinningStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ModuloStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.MultiplyingStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.OffsetStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.RoundingDoubleStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.RoundingStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.SelectionStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.SignificanceStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.SubtractingStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.To3DStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ZoomStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.arithmetic.*;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.convert.*;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.interpolation.Interpolated;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.sources.FunctionStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.utility.CachedStream2D;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.utility.ProfiledStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.utility.SemaphoreStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.utility.SynchronizedStream;
|
||||
import com.volmit.iris.util.Function2;
|
||||
import com.volmit.iris.util.Function3;
|
||||
import com.volmit.iris.util.Function4;
|
||||
@@ -64,6 +47,16 @@ public interface ProceduralStream<T> extends ProceduralLayer, Interpolated<T>
|
||||
return new FunctionStream<>(f, f2, helper);
|
||||
}
|
||||
|
||||
default ProceduralStream<T> profile()
|
||||
{
|
||||
return profile(10);
|
||||
}
|
||||
|
||||
default ProceduralStream<T> profile(int memory)
|
||||
{
|
||||
return new ProfiledStream<>(this, memory);
|
||||
}
|
||||
|
||||
default ProceduralStream<T> add(Function3<Double, Double, Double, Double> a)
|
||||
{
|
||||
return new AddingStream<>(this, a);
|
||||
@@ -119,6 +112,16 @@ public interface ProceduralStream<T> extends ProceduralLayer, Interpolated<T>
|
||||
return new CoordinateBitShiftRightStream<>(this, a);
|
||||
}
|
||||
|
||||
default ProceduralStream<T> synchronize()
|
||||
{
|
||||
return new SynchronizedStream<>(this);
|
||||
}
|
||||
|
||||
default ProceduralStream<T> semaphore(int permits)
|
||||
{
|
||||
return new SemaphoreStream<>(this, permits);
|
||||
}
|
||||
|
||||
default ProceduralStream<T> bitShiftCoordsLeft(int a)
|
||||
{
|
||||
return new CoordinateBitShiftLeftStream<>(this, a);
|
||||
@@ -134,6 +137,16 @@ public interface ProceduralStream<T> extends ProceduralLayer, Interpolated<T>
|
||||
return new MaxingStream<>(this, a);
|
||||
}
|
||||
|
||||
default ProceduralStream<T> slope()
|
||||
{
|
||||
return slope(1);
|
||||
}
|
||||
|
||||
default ProceduralStream<T> slope(int range)
|
||||
{
|
||||
return new SlopeStream<>(this, range);
|
||||
}
|
||||
|
||||
default ProceduralStream<T> max(double a)
|
||||
{
|
||||
return new MaxingStream<>(this, a);
|
||||
@@ -224,9 +237,9 @@ public interface ProceduralStream<T> extends ProceduralLayer, Interpolated<T>
|
||||
return new RoundingDoubleStream(this);
|
||||
}
|
||||
|
||||
default ProceduralStream<T> forceDouble()
|
||||
default ProceduralStream<Double> forceDouble()
|
||||
{
|
||||
return new ForceDoubleStream<T>(this);
|
||||
return new ForceDoubleStream(this);
|
||||
}
|
||||
|
||||
default ProceduralStream<Significance<T>> significance(double radius, int checks)
|
||||
@@ -246,7 +259,7 @@ public interface ProceduralStream<T> extends ProceduralLayer, Interpolated<T>
|
||||
|
||||
default <V> ProceduralStream<V> convert(Function<T, V> converter)
|
||||
{
|
||||
return new ConversionStream<T, V>(this, converter);
|
||||
return new ConversionStream<T,V>(this, converter);
|
||||
}
|
||||
|
||||
default <V> ProceduralStream<V> convertAware2D(Function3<T, Double, Double, V> converter)
|
||||
@@ -289,7 +302,17 @@ public interface ProceduralStream<T> extends ProceduralLayer, Interpolated<T>
|
||||
return new ZoomStream<T>(this, all, all, all);
|
||||
}
|
||||
|
||||
default <V> ProceduralStream<V> select(@SuppressWarnings("unchecked") V... types)
|
||||
default ProceduralStream<T> radial(double scale)
|
||||
{
|
||||
return new RadialStream<>(this, scale);
|
||||
}
|
||||
|
||||
default ProceduralStream<T> radial()
|
||||
{
|
||||
return radial(1D);
|
||||
}
|
||||
|
||||
default <V> ProceduralStream<V> select(V... types)
|
||||
{
|
||||
return new SelectionStream<V>(this, types);
|
||||
}
|
||||
@@ -472,10 +495,6 @@ public interface ProceduralStream<T> extends ProceduralLayer, Interpolated<T>
|
||||
fill3D(h, x, y, z, v, 4);
|
||||
}
|
||||
|
||||
public T get(double x, double z);
|
||||
|
||||
public T get(double x, double y, double z);
|
||||
|
||||
default double getDouble(double x, double z)
|
||||
{
|
||||
return toDouble(get(x, z));
|
||||
@@ -485,4 +504,12 @@ public interface ProceduralStream<T> extends ProceduralLayer, Interpolated<T>
|
||||
{
|
||||
return toDouble(get(x, y, z));
|
||||
}
|
||||
|
||||
public ProceduralStream<T> getTypedSource();
|
||||
|
||||
public ProceduralStream<?> getSource();
|
||||
|
||||
public T get(double x, double z);
|
||||
|
||||
public T get(double x, double y, double z);
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
|
||||
public class To3DStream<T> extends BasicLayer implements ProceduralStream<T>
|
||||
{
|
||||
private final ProceduralStream<T> stream;
|
||||
|
||||
public To3DStream(ProceduralStream<T> stream)
|
||||
{
|
||||
super();
|
||||
this.stream = stream;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double toDouble(T t)
|
||||
{
|
||||
return stream.toDouble(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromDouble(double d)
|
||||
{
|
||||
return stream.fromDouble(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double z)
|
||||
{
|
||||
return stream.get(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double y, double z)
|
||||
{
|
||||
return stream.fromDouble(stream.getDouble(x, z) >= y ? 1D : 0D);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
import com.volmit.iris.util.IrisInterpolation;
|
||||
|
||||
public class TriHermiteStream<T> extends BasicLayer implements ProceduralStream<T>, Interpolator<T>
|
||||
{
|
||||
private final ProceduralStream<T> stream;
|
||||
private final int rx;
|
||||
private final int ry;
|
||||
private final int rz;
|
||||
private final double tension;
|
||||
private final double bias;
|
||||
|
||||
public TriHermiteStream(ProceduralStream<T> stream, int rx, int ry, int rz, double tension, double bias)
|
||||
{
|
||||
this.stream = stream;
|
||||
this.rx = rx;
|
||||
this.ry = ry;
|
||||
this.rz = rz;
|
||||
this.tension = tension;
|
||||
this.bias = bias;
|
||||
}
|
||||
|
||||
public T interpolate(double x, double y, double z)
|
||||
{
|
||||
int fx = (int) Math.floor(x / rx);
|
||||
int fy = (int) Math.floor(y / ry);
|
||||
int fz = (int) Math.floor(z / rz);
|
||||
int x0 = (int) Math.round((fx - 1) * rx);
|
||||
int y0 = (int) Math.round((fy - 1) * ry);
|
||||
int z0 = (int) Math.round((fz - 1) * rz);
|
||||
int x1 = (int) Math.round(fx * rx);
|
||||
int y1 = (int) Math.round(fy * ry);
|
||||
int z1 = (int) Math.round(fz * rz);
|
||||
int x2 = (int) Math.round((fx + 1) * rx);
|
||||
int y2 = (int) Math.round((fy + 1) * ry);
|
||||
int z2 = (int) Math.round((fz + 1) * rz);
|
||||
int x3 = (int) Math.round((fx + 2) * rx);
|
||||
int y3 = (int) Math.round((fy + 2) * ry);
|
||||
int z3 = (int) Math.round((fz + 2) * rz);
|
||||
double px = IrisInterpolation.rangeScale(0, 1, x1, x2, x);
|
||||
double py = IrisInterpolation.rangeScale(0, 1, y1, y2, y);
|
||||
double pz = IrisInterpolation.rangeScale(0, 1, z1, z2, z);
|
||||
|
||||
//@builder
|
||||
return stream.fromDouble(IrisInterpolation.trihermite(
|
||||
stream.getDouble(x0, y0, z0),
|
||||
stream.getDouble(x0, y0,z1),
|
||||
stream.getDouble(x0, y0,z2),
|
||||
stream.getDouble(x0, y0,z3),
|
||||
stream.getDouble(x1, y0,z0),
|
||||
stream.getDouble(x1, y0,z1),
|
||||
stream.getDouble(x1, y0,z2),
|
||||
stream.getDouble(x1, y0,z3),
|
||||
stream.getDouble(x2, y0,z0),
|
||||
stream.getDouble(x2, y0,z1),
|
||||
stream.getDouble(x2, y0,z2),
|
||||
stream.getDouble(x2, y0,z3),
|
||||
stream.getDouble(x3, y0,z0),
|
||||
stream.getDouble(x3, y0,z1),
|
||||
stream.getDouble(x3, y0,z2),
|
||||
stream.getDouble(x3, y0,z3),
|
||||
stream.getDouble(x0, y1, z0),
|
||||
stream.getDouble(x0, y1,z1),
|
||||
stream.getDouble(x0, y1,z2),
|
||||
stream.getDouble(x0, y1,z3),
|
||||
stream.getDouble(x1, y1,z0),
|
||||
stream.getDouble(x1, y1,z1),
|
||||
stream.getDouble(x1, y1,z2),
|
||||
stream.getDouble(x1, y1,z3),
|
||||
stream.getDouble(x2, y1,z0),
|
||||
stream.getDouble(x2, y1,z1),
|
||||
stream.getDouble(x2, y1,z2),
|
||||
stream.getDouble(x2, y1,z3),
|
||||
stream.getDouble(x3, y1,z0),
|
||||
stream.getDouble(x3, y1,z1),
|
||||
stream.getDouble(x3, y1,z2),
|
||||
stream.getDouble(x3, y1,z3),
|
||||
stream.getDouble(x0, y2, z0),
|
||||
stream.getDouble(x0, y2,z1),
|
||||
stream.getDouble(x0, y2,z2),
|
||||
stream.getDouble(x0, y2,z3),
|
||||
stream.getDouble(x1, y2,z0),
|
||||
stream.getDouble(x1, y2,z1),
|
||||
stream.getDouble(x1, y2,z2),
|
||||
stream.getDouble(x1, y2,z3),
|
||||
stream.getDouble(x2, y2,z0),
|
||||
stream.getDouble(x2, y2,z1),
|
||||
stream.getDouble(x2, y2,z2),
|
||||
stream.getDouble(x2, y2,z3),
|
||||
stream.getDouble(x3, y2,z0),
|
||||
stream.getDouble(x3, y2,z1),
|
||||
stream.getDouble(x3, y2,z2),
|
||||
stream.getDouble(x3, y2,z3),
|
||||
stream.getDouble(x0, y3, z0),
|
||||
stream.getDouble(x0, y3,z1),
|
||||
stream.getDouble(x0, y3,z2),
|
||||
stream.getDouble(x0, y3,z3),
|
||||
stream.getDouble(x1, y3,z0),
|
||||
stream.getDouble(x1, y3,z1),
|
||||
stream.getDouble(x1, y3,z2),
|
||||
stream.getDouble(x1, y3,z3),
|
||||
stream.getDouble(x2, y3,z0),
|
||||
stream.getDouble(x2, y3,z1),
|
||||
stream.getDouble(x2, y3,z2),
|
||||
stream.getDouble(x2, y3,z3),
|
||||
stream.getDouble(x3, y3,z0),
|
||||
stream.getDouble(x3, y3,z1),
|
||||
stream.getDouble(x3, y3,z2),
|
||||
stream.getDouble(x3, y3,z3),
|
||||
px, pz, py, tension, bias));
|
||||
//@done
|
||||
}
|
||||
|
||||
@Override
|
||||
public double toDouble(T t)
|
||||
{
|
||||
return stream.toDouble(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromDouble(double d)
|
||||
{
|
||||
return stream.fromDouble(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double z)
|
||||
{
|
||||
return interpolate(x, 0, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double y, double z)
|
||||
{
|
||||
return interpolate(x, y, z);
|
||||
}
|
||||
}
|
||||
@@ -1,139 +0,0 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
import com.volmit.iris.util.IrisInterpolation;
|
||||
|
||||
public class TricubicStream<T> extends BasicLayer implements ProceduralStream<T>, Interpolator<T>
|
||||
{
|
||||
private final ProceduralStream<T> stream;
|
||||
private final int rx;
|
||||
private final int ry;
|
||||
private final int rz;
|
||||
|
||||
public TricubicStream(ProceduralStream<T> stream, int rx, int ry, int rz)
|
||||
{
|
||||
this.stream = stream;
|
||||
this.rx = rx;
|
||||
this.ry = ry;
|
||||
this.rz = rz;
|
||||
}
|
||||
|
||||
public T interpolate(double x, double y, double z)
|
||||
{
|
||||
int fx = (int) Math.floor(x / rx);
|
||||
int fy = (int) Math.floor(y / ry);
|
||||
int fz = (int) Math.floor(z / rz);
|
||||
int x0 = (int) Math.round((fx - 1) * rx);
|
||||
int y0 = (int) Math.round((fy - 1) * ry);
|
||||
int z0 = (int) Math.round((fz - 1) * rz);
|
||||
int x1 = (int) Math.round(fx * rx);
|
||||
int y1 = (int) Math.round(fy * ry);
|
||||
int z1 = (int) Math.round(fz * rz);
|
||||
int x2 = (int) Math.round((fx + 1) * rx);
|
||||
int y2 = (int) Math.round((fy + 1) * ry);
|
||||
int z2 = (int) Math.round((fz + 1) * rz);
|
||||
int x3 = (int) Math.round((fx + 2) * rx);
|
||||
int y3 = (int) Math.round((fy + 2) * ry);
|
||||
int z3 = (int) Math.round((fz + 2) * rz);
|
||||
double px = IrisInterpolation.rangeScale(0, 1, x1, x2, x);
|
||||
double py = IrisInterpolation.rangeScale(0, 1, y1, y2, y);
|
||||
double pz = IrisInterpolation.rangeScale(0, 1, z1, z2, z);
|
||||
|
||||
//@builder
|
||||
return stream.fromDouble(IrisInterpolation.tricubic(
|
||||
stream.getDouble(x0, y0, z0),
|
||||
stream.getDouble(x0, y0,z1),
|
||||
stream.getDouble(x0, y0,z2),
|
||||
stream.getDouble(x0, y0,z3),
|
||||
stream.getDouble(x1, y0,z0),
|
||||
stream.getDouble(x1, y0,z1),
|
||||
stream.getDouble(x1, y0,z2),
|
||||
stream.getDouble(x1, y0,z3),
|
||||
stream.getDouble(x2, y0,z0),
|
||||
stream.getDouble(x2, y0,z1),
|
||||
stream.getDouble(x2, y0,z2),
|
||||
stream.getDouble(x2, y0,z3),
|
||||
stream.getDouble(x3, y0,z0),
|
||||
stream.getDouble(x3, y0,z1),
|
||||
stream.getDouble(x3, y0,z2),
|
||||
stream.getDouble(x3, y0,z3),
|
||||
|
||||
stream.getDouble(x0, y1, z0),
|
||||
stream.getDouble(x0, y1,z1),
|
||||
stream.getDouble(x0, y1,z2),
|
||||
stream.getDouble(x0, y1,z3),
|
||||
stream.getDouble(x1, y1,z0),
|
||||
stream.getDouble(x1, y1,z1),
|
||||
stream.getDouble(x1, y1,z2),
|
||||
stream.getDouble(x1, y1,z3),
|
||||
stream.getDouble(x2, y1,z0),
|
||||
stream.getDouble(x2, y1,z1),
|
||||
stream.getDouble(x2, y1,z2),
|
||||
stream.getDouble(x2, y1,z3),
|
||||
stream.getDouble(x3, y1,z0),
|
||||
stream.getDouble(x3, y1,z1),
|
||||
stream.getDouble(x3, y1,z2),
|
||||
stream.getDouble(x3, y1,z3),
|
||||
|
||||
stream.getDouble(x0, y2, z0),
|
||||
stream.getDouble(x0, y2,z1),
|
||||
stream.getDouble(x0, y2,z2),
|
||||
stream.getDouble(x0, y2,z3),
|
||||
stream.getDouble(x1, y2,z0),
|
||||
stream.getDouble(x1, y2,z1),
|
||||
stream.getDouble(x1, y2,z2),
|
||||
stream.getDouble(x1, y2,z3),
|
||||
stream.getDouble(x2, y2,z0),
|
||||
stream.getDouble(x2, y2,z1),
|
||||
stream.getDouble(x2, y2,z2),
|
||||
stream.getDouble(x2, y2,z3),
|
||||
stream.getDouble(x3, y2,z0),
|
||||
stream.getDouble(x3, y2,z1),
|
||||
stream.getDouble(x3, y2,z2),
|
||||
stream.getDouble(x3, y2,z3),
|
||||
|
||||
stream.getDouble(x0, y3, z0),
|
||||
stream.getDouble(x0, y3,z1),
|
||||
stream.getDouble(x0, y3,z2),
|
||||
stream.getDouble(x0, y3,z3),
|
||||
stream.getDouble(x1, y3,z0),
|
||||
stream.getDouble(x1, y3,z1),
|
||||
stream.getDouble(x1, y3,z2),
|
||||
stream.getDouble(x1, y3,z3),
|
||||
stream.getDouble(x2, y3,z0),
|
||||
stream.getDouble(x2, y3,z1),
|
||||
stream.getDouble(x2, y3,z2),
|
||||
stream.getDouble(x2, y3,z3),
|
||||
stream.getDouble(x3, y3,z0),
|
||||
stream.getDouble(x3, y3,z1),
|
||||
stream.getDouble(x3, y3,z2),
|
||||
stream.getDouble(x3, y3,z3),
|
||||
px, pz, py));
|
||||
//@done
|
||||
}
|
||||
|
||||
@Override
|
||||
public double toDouble(T t)
|
||||
{
|
||||
return stream.toDouble(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromDouble(double d)
|
||||
{
|
||||
return stream.fromDouble(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double z)
|
||||
{
|
||||
return interpolate(x, 0, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double y, double z)
|
||||
{
|
||||
return interpolate(x, y, z);
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
|
||||
public class ZoomStream<T> extends BasicLayer implements ProceduralStream<T>
|
||||
{
|
||||
private final ProceduralStream<T> stream;
|
||||
private final double ox;
|
||||
private final double oy;
|
||||
private final double oz;
|
||||
|
||||
public ZoomStream(ProceduralStream<T> stream, double x, double y, double z)
|
||||
{
|
||||
super();
|
||||
this.stream = stream;
|
||||
this.ox = x;
|
||||
this.oy = y;
|
||||
this.oz = z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double toDouble(T t)
|
||||
{
|
||||
return stream.toDouble(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromDouble(double d)
|
||||
{
|
||||
return stream.fromDouble(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double z)
|
||||
{
|
||||
return stream.get(x / ox, z / oz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double y, double z)
|
||||
{
|
||||
return stream.get(x / ox, y / oy, z / oz);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,19 +1,17 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.arithmetic;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.BasicStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
import com.volmit.iris.util.Function2;
|
||||
import com.volmit.iris.util.Function3;
|
||||
|
||||
public class AddingStream<T> extends BasicLayer implements ProceduralStream<T>
|
||||
public class AddingStream<T> extends BasicStream<T>
|
||||
{
|
||||
private final ProceduralStream<T> stream;
|
||||
private final Function3<Double, Double, Double, Double> add;
|
||||
|
||||
public AddingStream(ProceduralStream<T> stream, Function3<Double, Double, Double, Double> add)
|
||||
{
|
||||
super();
|
||||
this.stream = stream;
|
||||
super(stream);
|
||||
this.add = add;
|
||||
}
|
||||
|
||||
@@ -30,25 +28,25 @@ public class AddingStream<T> extends BasicLayer implements ProceduralStream<T>
|
||||
@Override
|
||||
public double toDouble(T t)
|
||||
{
|
||||
return stream.toDouble(t);
|
||||
return getTypedSource().toDouble(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromDouble(double d)
|
||||
{
|
||||
return stream.fromDouble(d);
|
||||
return getTypedSource().fromDouble(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double z)
|
||||
{
|
||||
return fromDouble(add.apply(x, 0D, z) + stream.getDouble(x, z));
|
||||
return fromDouble(add.apply(x, 0D, z) + getTypedSource().getDouble(x, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double y, double z)
|
||||
{
|
||||
return fromDouble(add.apply(x, y, z) + stream.getDouble(x, y, z));
|
||||
return fromDouble(add.apply(x, y, z) + getTypedSource().getDouble(x, y, z));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.arithmetic;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.BasicStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
|
||||
public class ClampedStream<T> extends BasicStream<T> implements ProceduralStream<T>
|
||||
{
|
||||
private final double min;
|
||||
private final double max;
|
||||
|
||||
public ClampedStream(ProceduralStream<T> stream, double min, double max)
|
||||
{
|
||||
super(stream);
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double toDouble(T t)
|
||||
{
|
||||
return getTypedSource().toDouble(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromDouble(double d)
|
||||
{
|
||||
return getTypedSource().fromDouble(d);
|
||||
}
|
||||
|
||||
private double clamp(double v)
|
||||
{
|
||||
return Math.max(Math.min(v, max), min);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double z)
|
||||
{
|
||||
return fromDouble(clamp(getTypedSource().getDouble(x, z)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double y, double z)
|
||||
{
|
||||
return fromDouble(clamp(getTypedSource().getDouble(x, y, z)));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.arithmetic;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.BasicStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
|
||||
public class CoordinateBitShiftLeftStream<T> extends BasicStream<T> implements ProceduralStream<T>
|
||||
{
|
||||
private final int amount;
|
||||
|
||||
public CoordinateBitShiftLeftStream(ProceduralStream<T> stream, int amount)
|
||||
{
|
||||
super(stream);
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double toDouble(T t)
|
||||
{
|
||||
return getTypedSource().toDouble(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromDouble(double d)
|
||||
{
|
||||
return getTypedSource().fromDouble(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double z)
|
||||
{
|
||||
return getTypedSource().get((int) x << amount, (int) z << amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double y, double z)
|
||||
{
|
||||
return getTypedSource().get((int) x << amount, (int) y << amount, (int) z << amount);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.arithmetic;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.BasicStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
|
||||
public class CoordinateBitShiftRightStream<T> extends BasicStream<T> implements ProceduralStream<T>
|
||||
{
|
||||
private final int amount;
|
||||
|
||||
public CoordinateBitShiftRightStream(ProceduralStream<T> stream, int amount)
|
||||
{
|
||||
super(stream);
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double toDouble(T t)
|
||||
{
|
||||
return getTypedSource().toDouble(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromDouble(double d)
|
||||
{
|
||||
return getTypedSource().fromDouble(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double z)
|
||||
{
|
||||
return getTypedSource().get((int) x >> amount, (int) z >> amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double y, double z)
|
||||
{
|
||||
return getTypedSource().get((int) x >> amount, (int) y >> amount, (int) z >> amount);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,19 +1,17 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.arithmetic;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.BasicStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
import com.volmit.iris.util.Function2;
|
||||
import com.volmit.iris.util.Function3;
|
||||
|
||||
public class DividingStream<T> extends BasicLayer implements ProceduralStream<T>
|
||||
public class DividingStream<T> extends BasicStream<T> implements ProceduralStream<T>
|
||||
{
|
||||
private final ProceduralStream<T> stream;
|
||||
private final Function3<Double, Double, Double, Double> add;
|
||||
|
||||
public DividingStream(ProceduralStream<T> stream, Function3<Double, Double, Double, Double> add)
|
||||
{
|
||||
super();
|
||||
this.stream = stream;
|
||||
super(stream);
|
||||
this.add = add;
|
||||
}
|
||||
|
||||
@@ -30,24 +28,24 @@ public class DividingStream<T> extends BasicLayer implements ProceduralStream<T>
|
||||
@Override
|
||||
public double toDouble(T t)
|
||||
{
|
||||
return stream.toDouble(t);
|
||||
return getTypedSource().toDouble(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromDouble(double d)
|
||||
{
|
||||
return stream.fromDouble(d);
|
||||
return getTypedSource().fromDouble(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double z)
|
||||
{
|
||||
return fromDouble(stream.getDouble(x, z) / add.apply(x, 0D, z));
|
||||
return fromDouble(getTypedSource().getDouble(x, z) / add.apply(x, 0D, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double y, double z)
|
||||
{
|
||||
return fromDouble(stream.getDouble(x, y, z) / add.apply(x, y, z));
|
||||
return fromDouble(getTypedSource().getDouble(x, y, z) / add.apply(x, y, z));
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.arithmetic;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.BasicStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
|
||||
public class FittedStream<T> extends BasicLayer implements ProceduralStream<T>
|
||||
public class FittedStream<T> extends BasicStream<T> implements ProceduralStream<T>
|
||||
{
|
||||
private final ProceduralStream<T> stream;
|
||||
private final double min;
|
||||
private final double max;
|
||||
private final double inMin;
|
||||
@@ -13,8 +12,7 @@ public class FittedStream<T> extends BasicLayer implements ProceduralStream<T>
|
||||
|
||||
public FittedStream(ProceduralStream<T> stream, double inMin, double inMax, double min, double max)
|
||||
{
|
||||
super();
|
||||
this.stream = stream;
|
||||
super(stream);
|
||||
this.inMin = inMin;
|
||||
this.inMax = inMax;
|
||||
this.min = min;
|
||||
@@ -29,13 +27,13 @@ public class FittedStream<T> extends BasicLayer implements ProceduralStream<T>
|
||||
@Override
|
||||
public double toDouble(T t)
|
||||
{
|
||||
return stream.toDouble(t);
|
||||
return getTypedSource().toDouble(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromDouble(double d)
|
||||
{
|
||||
return stream.fromDouble(d);
|
||||
return getTypedSource().fromDouble(d);
|
||||
}
|
||||
|
||||
private double dlerp(double v)
|
||||
@@ -46,13 +44,13 @@ public class FittedStream<T> extends BasicLayer implements ProceduralStream<T>
|
||||
@Override
|
||||
public T get(double x, double z)
|
||||
{
|
||||
return fromDouble(dlerp(stream.getDouble(x, z)));
|
||||
return fromDouble(dlerp(getTypedSource().getDouble(x, z)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double y, double z)
|
||||
{
|
||||
return fromDouble(dlerp(stream.getDouble(x, y, z)));
|
||||
return fromDouble(dlerp(getTypedSource().getDouble(x, y, z)));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,19 +1,17 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.arithmetic;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.BasicStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
import com.volmit.iris.util.Function2;
|
||||
import com.volmit.iris.util.Function3;
|
||||
|
||||
public class MaxingStream<T> extends BasicLayer implements ProceduralStream<T>
|
||||
public class MaxingStream<T> extends BasicStream<T>
|
||||
{
|
||||
private final ProceduralStream<T> stream;
|
||||
private final Function3<Double, Double, Double, Double> add;
|
||||
|
||||
public MaxingStream(ProceduralStream<T> stream, Function3<Double, Double, Double, Double> add)
|
||||
{
|
||||
super();
|
||||
this.stream = stream;
|
||||
super(stream);
|
||||
this.add = add;
|
||||
}
|
||||
|
||||
@@ -30,25 +28,25 @@ public class MaxingStream<T> extends BasicLayer implements ProceduralStream<T>
|
||||
@Override
|
||||
public double toDouble(T t)
|
||||
{
|
||||
return stream.toDouble(t);
|
||||
return getTypedSource().toDouble(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromDouble(double d)
|
||||
{
|
||||
return stream.fromDouble(d);
|
||||
return getTypedSource().fromDouble(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double z)
|
||||
{
|
||||
return fromDouble(Math.max(add.apply(x, 0D, z), stream.getDouble(x, z)));
|
||||
return fromDouble(Math.max(add.apply(x, 0D, z), getTypedSource().getDouble(x, z)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double y, double z)
|
||||
{
|
||||
return fromDouble(Math.max(add.apply(x, y, z), stream.getDouble(x, y, z)));
|
||||
return fromDouble(Math.max(add.apply(x, y, z), getTypedSource().getDouble(x, y, z)));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,19 +1,17 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.arithmetic;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.BasicStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
import com.volmit.iris.util.Function2;
|
||||
import com.volmit.iris.util.Function3;
|
||||
|
||||
public class MinningStream<T> extends BasicLayer implements ProceduralStream<T>
|
||||
public class MinningStream<T> extends BasicStream<T>
|
||||
{
|
||||
private final ProceduralStream<T> stream;
|
||||
private final Function3<Double, Double, Double, Double> add;
|
||||
|
||||
public MinningStream(ProceduralStream<T> stream, Function3<Double, Double, Double, Double> add)
|
||||
{
|
||||
super();
|
||||
this.stream = stream;
|
||||
super(stream);
|
||||
this.add = add;
|
||||
}
|
||||
|
||||
@@ -30,25 +28,25 @@ public class MinningStream<T> extends BasicLayer implements ProceduralStream<T>
|
||||
@Override
|
||||
public double toDouble(T t)
|
||||
{
|
||||
return stream.toDouble(t);
|
||||
return getTypedSource().toDouble(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromDouble(double d)
|
||||
{
|
||||
return stream.fromDouble(d);
|
||||
return getTypedSource().fromDouble(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double z)
|
||||
{
|
||||
return fromDouble(Math.min(add.apply(x, 0D, z), stream.getDouble(x, z)));
|
||||
return fromDouble(Math.min(add.apply(x, 0D, z), getTypedSource().getDouble(x, z)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double y, double z)
|
||||
{
|
||||
return fromDouble(Math.min(add.apply(x, y, z), stream.getDouble(x, y, z)));
|
||||
return fromDouble(Math.min(add.apply(x, y, z), getTypedSource().getDouble(x, y, z)));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,19 +1,17 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.arithmetic;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.BasicStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
import com.volmit.iris.util.Function2;
|
||||
import com.volmit.iris.util.Function3;
|
||||
|
||||
public class ModuloStream<T> extends BasicLayer implements ProceduralStream<T>
|
||||
public class ModuloStream<T> extends BasicStream<T>
|
||||
{
|
||||
private final ProceduralStream<T> stream;
|
||||
private final Function3<Double, Double, Double, Double> add;
|
||||
|
||||
public ModuloStream(ProceduralStream<T> stream, Function3<Double, Double, Double, Double> add)
|
||||
{
|
||||
super();
|
||||
this.stream = stream;
|
||||
super(stream);
|
||||
this.add = add;
|
||||
}
|
||||
|
||||
@@ -30,24 +28,24 @@ public class ModuloStream<T> extends BasicLayer implements ProceduralStream<T>
|
||||
@Override
|
||||
public double toDouble(T t)
|
||||
{
|
||||
return stream.toDouble(t);
|
||||
return getTypedSource().toDouble(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromDouble(double d)
|
||||
{
|
||||
return stream.fromDouble(d);
|
||||
return getTypedSource().fromDouble(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double z)
|
||||
{
|
||||
return fromDouble(stream.getDouble(x, z) % add.apply(x, 0D, z));
|
||||
return fromDouble(getTypedSource().getDouble(x, z) % add.apply(x, 0D, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double y, double z)
|
||||
{
|
||||
return fromDouble(stream.getDouble(x, y, z) % add.apply(x, y, z));
|
||||
return fromDouble(getTypedSource().getDouble(x, y, z) % add.apply(x, y, z));
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,17 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.arithmetic;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.BasicStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
import com.volmit.iris.util.Function2;
|
||||
import com.volmit.iris.util.Function3;
|
||||
|
||||
public class MultiplyingStream<T> extends BasicLayer implements ProceduralStream<T>
|
||||
public class MultiplyingStream<T> extends BasicStream<T>
|
||||
{
|
||||
private final ProceduralStream<T> stream;
|
||||
private final Function3<Double, Double, Double, Double> add;
|
||||
|
||||
public MultiplyingStream(ProceduralStream<T> stream, Function3<Double, Double, Double, Double> add)
|
||||
{
|
||||
super();
|
||||
this.stream = stream;
|
||||
super(stream);
|
||||
this.add = add;
|
||||
}
|
||||
|
||||
@@ -30,24 +28,24 @@ public class MultiplyingStream<T> extends BasicLayer implements ProceduralStream
|
||||
@Override
|
||||
public double toDouble(T t)
|
||||
{
|
||||
return stream.toDouble(t);
|
||||
return getTypedSource().toDouble(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromDouble(double d)
|
||||
{
|
||||
return stream.fromDouble(d);
|
||||
return getTypedSource().fromDouble(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double z)
|
||||
{
|
||||
return fromDouble(stream.getDouble(x, z) * add.apply(x, 0D, z));
|
||||
return fromDouble(getTypedSource().getDouble(x, z) * add.apply(x, 0D, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double y, double z)
|
||||
{
|
||||
return fromDouble(stream.getDouble(x, y, z) * add.apply(x, y, z));
|
||||
return fromDouble(getTypedSource().getDouble(x, y, z) * add.apply(x, y, z));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.arithmetic;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.BasicStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
|
||||
public class OffsetStream<T> extends BasicStream<T> implements ProceduralStream<T>
|
||||
{
|
||||
private final double ox;
|
||||
private final double oy;
|
||||
private final double oz;
|
||||
|
||||
public OffsetStream(ProceduralStream<T> stream, double x, double y, double z)
|
||||
{
|
||||
super(stream);
|
||||
this.ox = x;
|
||||
this.oy = y;
|
||||
this.oz = z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double toDouble(T t)
|
||||
{
|
||||
return getTypedSource().toDouble(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromDouble(double d)
|
||||
{
|
||||
return getTypedSource().fromDouble(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double z)
|
||||
{
|
||||
return getTypedSource().get(x + ox, z + oz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double y, double z)
|
||||
{
|
||||
return getTypedSource().get(x + ox, y + oy, z + oz);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.arithmetic;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.BasicStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
|
||||
public class RadialStream<T> extends BasicStream<T> implements ProceduralStream<T>
|
||||
{
|
||||
private final double scale;
|
||||
|
||||
public RadialStream(ProceduralStream<T> stream)
|
||||
{
|
||||
this(stream, 1D);
|
||||
}
|
||||
|
||||
public RadialStream(ProceduralStream<T> stream, double scale)
|
||||
{
|
||||
super(stream);
|
||||
this.scale = scale;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double toDouble(T t)
|
||||
{
|
||||
return getTypedSource().toDouble(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromDouble(double d)
|
||||
{
|
||||
return getTypedSource().fromDouble(d);
|
||||
}
|
||||
|
||||
private double radii(double v)
|
||||
{
|
||||
return (v / (360D * scale)) % 360D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double z)
|
||||
{
|
||||
return fromDouble(radii(getTypedSource().getDouble(x, z)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double y, double z)
|
||||
{
|
||||
return fromDouble(radii(getTypedSource().getDouble(x, y, z)));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.arithmetic;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.BasicStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
|
||||
public class RoundingDoubleStream extends BasicLayer implements ProceduralStream<Double>
|
||||
public class RoundingDoubleStream extends BasicStream<Double>
|
||||
{
|
||||
private final ProceduralStream<?> stream;
|
||||
|
||||
@@ -16,7 +16,7 @@ public class RoundingDoubleStream extends BasicLayer implements ProceduralStream
|
||||
@Override
|
||||
public double toDouble(Double t)
|
||||
{
|
||||
return t.doubleValue();
|
||||
return t;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.arithmetic;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.BasicStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
|
||||
public class SlopeStream<T> extends BasicStream<T>
|
||||
{
|
||||
private final int range;
|
||||
|
||||
public SlopeStream(ProceduralStream<T> stream, int range)
|
||||
{
|
||||
super(stream);
|
||||
this.range = range;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double toDouble(T t)
|
||||
{
|
||||
return getTypedSource().toDouble(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromDouble(double d)
|
||||
{
|
||||
return getTypedSource().fromDouble(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double z)
|
||||
{
|
||||
double height = getTypedSource().getDouble(x, z);
|
||||
double dx = getTypedSource().getDouble(x + range, z) - height;
|
||||
double dy = getTypedSource().getDouble(x, z + range) - height;
|
||||
|
||||
return fromDouble(Math.sqrt(dx * dx + dy * dy));
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double y, double z)
|
||||
{
|
||||
double height = getTypedSource().getDouble(x, y, z);
|
||||
double dx = getTypedSource().getDouble(x + range,y, z) - height;
|
||||
double dy = getTypedSource().getDouble(x,y+range, z) - height;
|
||||
double dz = getTypedSource().getDouble(x,y, z + range) - height;
|
||||
|
||||
return fromDouble(Math.cbrt((dx * dx) + (dy * dy) + (dz * dz)));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,19 +1,17 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.arithmetic;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.BasicStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
import com.volmit.iris.util.Function2;
|
||||
import com.volmit.iris.util.Function3;
|
||||
|
||||
public class SubtractingStream<T> extends BasicLayer implements ProceduralStream<T>
|
||||
public class SubtractingStream<T> extends BasicStream<T>
|
||||
{
|
||||
private final ProceduralStream<T> stream;
|
||||
private final Function3<Double, Double, Double, Double> add;
|
||||
|
||||
public SubtractingStream(ProceduralStream<T> stream, Function3<Double, Double, Double, Double> add)
|
||||
{
|
||||
super();
|
||||
this.stream = stream;
|
||||
super(stream);
|
||||
this.add = add;
|
||||
}
|
||||
|
||||
@@ -30,24 +28,24 @@ public class SubtractingStream<T> extends BasicLayer implements ProceduralStream
|
||||
@Override
|
||||
public double toDouble(T t)
|
||||
{
|
||||
return stream.toDouble(t);
|
||||
return getTypedSource().toDouble(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromDouble(double d)
|
||||
{
|
||||
return stream.fromDouble(d);
|
||||
return getTypedSource().fromDouble(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double z)
|
||||
{
|
||||
return fromDouble(stream.getDouble(x, z) - add.apply(x, 0D, z));
|
||||
return fromDouble(getTypedSource().getDouble(x, z) - add.apply(x, 0D, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double y, double z)
|
||||
{
|
||||
return fromDouble(stream.getDouble(x, y, z) - add.apply(x, y, z));
|
||||
return fromDouble(getTypedSource().getDouble(x, y, z) - add.apply(x, y, z));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.arithmetic;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.BasicStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
|
||||
public class ZoomStream<T> extends BasicStream<T>
|
||||
{
|
||||
private final double ox;
|
||||
private final double oy;
|
||||
private final double oz;
|
||||
|
||||
public ZoomStream(ProceduralStream<T> stream, double x, double y, double z)
|
||||
{
|
||||
super(stream);
|
||||
this.ox = x;
|
||||
this.oy = y;
|
||||
this.oz = z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double toDouble(T t)
|
||||
{
|
||||
return getTypedSource().toDouble(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromDouble(double d)
|
||||
{
|
||||
return getTypedSource().fromDouble(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double z)
|
||||
{
|
||||
return getTypedSource().get(x / ox, z / oz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double y, double z)
|
||||
{
|
||||
return getTypedSource().get(x / ox, y / oy, z / oz);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,17 +1,17 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.convert;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.BasicStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
import com.volmit.iris.util.Function3;
|
||||
|
||||
public class AwareConversionStream2D<T, V> extends BasicLayer implements ProceduralStream<V>
|
||||
public class AwareConversionStream2D<T, V> extends BasicStream<V>
|
||||
{
|
||||
private final ProceduralStream<T> stream;
|
||||
private final Function3<T, Double, Double, V> converter;
|
||||
|
||||
public AwareConversionStream2D(ProceduralStream<T> stream, Function3<T, Double, Double, V> converter)
|
||||
{
|
||||
super();
|
||||
super(null);
|
||||
this.stream = stream;
|
||||
this.converter = converter;
|
||||
}
|
||||
@@ -21,7 +21,7 @@ public class AwareConversionStream2D<T, V> extends BasicLayer implements Procedu
|
||||
{
|
||||
if(t instanceof Double)
|
||||
{
|
||||
return (double) t;
|
||||
return (Double) t;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -33,6 +33,11 @@ public class AwareConversionStream2D<T, V> extends BasicLayer implements Procedu
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProceduralStream<?> getSource() {
|
||||
return stream;
|
||||
}
|
||||
|
||||
@Override
|
||||
public V get(double x, double z)
|
||||
{
|
||||
@@ -1,17 +1,17 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.convert;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.BasicStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
import com.volmit.iris.util.Function4;
|
||||
|
||||
public class AwareConversionStream3D<T, V> extends BasicLayer implements ProceduralStream<V>
|
||||
public class AwareConversionStream3D<T, V> extends BasicStream<V>
|
||||
{
|
||||
private final ProceduralStream<T> stream;
|
||||
private final Function4<T, Double, Double, Double, V> converter;
|
||||
|
||||
public AwareConversionStream3D(ProceduralStream<T> stream, Function4<T, Double, Double, Double, V> converter)
|
||||
{
|
||||
super();
|
||||
super(null);
|
||||
this.stream = stream;
|
||||
this.converter = converter;
|
||||
}
|
||||
@@ -21,7 +21,7 @@ public class AwareConversionStream3D<T, V> extends BasicLayer implements Procedu
|
||||
{
|
||||
if(t instanceof Double)
|
||||
{
|
||||
return (double) t;
|
||||
return (Double) t;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -31,6 +31,11 @@ public class AwareConversionStream3D<T, V> extends BasicLayer implements Procedu
|
||||
public V fromDouble(double d)
|
||||
{
|
||||
return null;
|
||||
|
||||
|
||||
}@Override
|
||||
public ProceduralStream<?> getSource() {
|
||||
return stream;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.convert;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.BasicLayer;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
import com.volmit.iris.util.KMap;
|
||||
|
||||
public class CachedConversionStream<T, V> extends BasicLayer implements ProceduralStream<V>
|
||||
@@ -32,6 +32,16 @@ public class CachedConversionStream<T, V> extends BasicLayer implements Procedur
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProceduralStream<V> getTypedSource() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProceduralStream<?> getSource() {
|
||||
return stream;
|
||||
}
|
||||
|
||||
@Override
|
||||
public V get(double x, double z)
|
||||
{
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.convert;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.BasicLayer;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
|
||||
public class ConversionStream<T, V> extends BasicLayer implements ProceduralStream<V>
|
||||
{
|
||||
@@ -22,7 +22,7 @@ public class ConversionStream<T, V> extends BasicLayer implements ProceduralStre
|
||||
{
|
||||
if(t instanceof Double)
|
||||
{
|
||||
return (double) t;
|
||||
return (Double) t;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -34,6 +34,16 @@ public class ConversionStream<T, V> extends BasicLayer implements ProceduralStre
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProceduralStream<V> getTypedSource() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProceduralStream<?> getSource() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public V get(double x, double z)
|
||||
{
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.convert;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.BasicStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
|
||||
public class ForceDoubleStream extends BasicStream<Double>
|
||||
{
|
||||
private ProceduralStream<?> stream;
|
||||
|
||||
public ForceDoubleStream(ProceduralStream<?> stream)
|
||||
{
|
||||
super(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double toDouble(Double t)
|
||||
{
|
||||
return t;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Double fromDouble(double d)
|
||||
{
|
||||
return d;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double get(double x, double z)
|
||||
{
|
||||
return stream.getDouble(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double get(double x, double y, double z)
|
||||
{
|
||||
return stream.getDouble(x, y, z);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.convert;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.BasicStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
|
||||
public class RoundingStream extends BasicLayer implements ProceduralStream<Integer>
|
||||
public class RoundingStream extends BasicStream<Integer>
|
||||
{
|
||||
private final ProceduralStream<?> stream;
|
||||
|
||||
@@ -41,5 +41,4 @@ public class RoundingStream extends BasicLayer implements ProceduralStream<Integ
|
||||
{
|
||||
return round(stream.getDouble(x, y, z));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.convert;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.BasicStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
|
||||
public class SelectionStream<T> extends BasicLayer implements ProceduralStream<T>
|
||||
public class SelectionStream<T> extends BasicStream<T>
|
||||
{
|
||||
private final ProceduralStream<Integer> stream;
|
||||
private final T[] options;
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.convert;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.ArraySignificance;
|
||||
import com.volmit.iris.gen.v2.scaffold.Significance;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.BasicStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
import com.volmit.iris.util.KList;
|
||||
|
||||
public class SignificanceStream<K extends Significance<T>, T> extends BasicLayer implements ProceduralStream<K>
|
||||
public class SignificanceStream<K extends Significance<T>, T> extends BasicStream<K>
|
||||
{
|
||||
private final ProceduralStream<T> stream;
|
||||
private final double radius;
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.convert;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.BasicStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
|
||||
public class To3DStream<T> extends BasicStream<T>
|
||||
{
|
||||
public To3DStream(ProceduralStream<T> stream)
|
||||
{
|
||||
super(stream);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double toDouble(T t)
|
||||
{
|
||||
return getTypedSource().toDouble(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromDouble(double d)
|
||||
{
|
||||
return getTypedSource().fromDouble(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double z)
|
||||
{
|
||||
return getTypedSource().get(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double y, double z)
|
||||
{
|
||||
return getTypedSource().fromDouble(getTypedSource().getDouble(x, z) >= y ? 1D : 0D);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.interpolation;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.BasicStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
import com.volmit.iris.util.IrisInterpolation;
|
||||
|
||||
public class BiHermiteStream<T> extends BasicLayer implements ProceduralStream<T>, Interpolator<T>
|
||||
public class BiHermiteStream<T> extends BasicStream<T> implements Interpolator<T>
|
||||
{
|
||||
private final ProceduralStream<T> stream;
|
||||
private final int rx;
|
||||
private final int ry;
|
||||
private final double tension;
|
||||
@@ -14,7 +13,7 @@ public class BiHermiteStream<T> extends BasicLayer implements ProceduralStream<T
|
||||
|
||||
public BiHermiteStream(ProceduralStream<T> stream, int rx, int ry, double tension, double bias)
|
||||
{
|
||||
this.stream = stream;
|
||||
super(stream);
|
||||
this.rx = rx;
|
||||
this.ry = ry;
|
||||
this.tension = tension;
|
||||
@@ -42,23 +41,23 @@ public class BiHermiteStream<T> extends BasicLayer implements ProceduralStream<T
|
||||
double pz = IrisInterpolation.rangeScale(0, 1, z1, z2, y);
|
||||
|
||||
//@builder
|
||||
return stream.fromDouble(IrisInterpolation.bihermite(
|
||||
stream.getDouble(x0, z0),
|
||||
stream.getDouble(x0, z1),
|
||||
stream.getDouble(x0, z2),
|
||||
stream.getDouble(x0, z3),
|
||||
stream.getDouble(x1, z0),
|
||||
stream.getDouble(x1, z1),
|
||||
stream.getDouble(x1, z2),
|
||||
stream.getDouble(x1, z3),
|
||||
stream.getDouble(x2, z0),
|
||||
stream.getDouble(x2, z1),
|
||||
stream.getDouble(x2, z2),
|
||||
stream.getDouble(x2, z3),
|
||||
stream.getDouble(x3, z0),
|
||||
stream.getDouble(x3, z1),
|
||||
stream.getDouble(x3, z2),
|
||||
stream.getDouble(x3, z3),
|
||||
return getTypedSource().fromDouble(IrisInterpolation.bihermite(
|
||||
getTypedSource().getDouble(x0, z0),
|
||||
getTypedSource().getDouble(x0, z1),
|
||||
getTypedSource().getDouble(x0, z2),
|
||||
getTypedSource().getDouble(x0, z3),
|
||||
getTypedSource().getDouble(x1, z0),
|
||||
getTypedSource().getDouble(x1, z1),
|
||||
getTypedSource().getDouble(x1, z2),
|
||||
getTypedSource().getDouble(x1, z3),
|
||||
getTypedSource().getDouble(x2, z0),
|
||||
getTypedSource().getDouble(x2, z1),
|
||||
getTypedSource().getDouble(x2, z2),
|
||||
getTypedSource().getDouble(x2, z3),
|
||||
getTypedSource().getDouble(x3, z0),
|
||||
getTypedSource().getDouble(x3, z1),
|
||||
getTypedSource().getDouble(x3, z2),
|
||||
getTypedSource().getDouble(x3, z3),
|
||||
px, pz, tension, bias));
|
||||
//@done
|
||||
}
|
||||
@@ -66,13 +65,13 @@ public class BiHermiteStream<T> extends BasicLayer implements ProceduralStream<T
|
||||
@Override
|
||||
public double toDouble(T t)
|
||||
{
|
||||
return stream.toDouble(t);
|
||||
return getTypedSource().toDouble(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromDouble(double d)
|
||||
{
|
||||
return stream.fromDouble(d);
|
||||
return getTypedSource().fromDouble(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1,24 +1,23 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.interpolation;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.BasicStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
|
||||
public class BiStarcastStream<T> extends BasicLayer implements ProceduralStream<T>, Interpolator<T>
|
||||
public class BiStarcastStream<T> extends BasicStream<T> implements Interpolator<T>
|
||||
{
|
||||
private ProceduralStream<T> stream;
|
||||
private int rad;
|
||||
private int checks;
|
||||
|
||||
public BiStarcastStream(ProceduralStream<T> stream, int rad, int checks)
|
||||
{
|
||||
this.stream = stream;
|
||||
super(stream);
|
||||
this.rad = rad;
|
||||
this.checks = checks;
|
||||
}
|
||||
|
||||
public T interpolate(double x, double y)
|
||||
{
|
||||
double m = (360 / checks);
|
||||
double m = (360D / checks);
|
||||
double v = 0;
|
||||
|
||||
for(int i = 0; i < 360; i += m)
|
||||
@@ -27,22 +26,22 @@ public class BiStarcastStream<T> extends BasicLayer implements ProceduralStream<
|
||||
double cos = Math.cos(Math.toRadians(i));
|
||||
double cx = x + ((rad * cos) - (rad * sin));
|
||||
double cz = y + ((rad * sin) + (rad * cos));
|
||||
v += stream.getDouble(cx, cz);
|
||||
v += getTypedSource().getDouble(cx, cz);
|
||||
}
|
||||
|
||||
return stream.fromDouble(v / checks);
|
||||
return getTypedSource().fromDouble(v / checks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double toDouble(T t)
|
||||
{
|
||||
return stream.toDouble(t);
|
||||
return getTypedSource().toDouble(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromDouble(double d)
|
||||
{
|
||||
return stream.fromDouble(d);
|
||||
return getTypedSource().fromDouble(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1,18 +1,17 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.interpolation;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.BasicStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
import com.volmit.iris.util.IrisInterpolation;
|
||||
|
||||
public class BicubicStream<T> extends BasicLayer implements ProceduralStream<T>, Interpolator<T>
|
||||
public class BicubicStream<T> extends BasicStream<T> implements Interpolator<T>
|
||||
{
|
||||
private final ProceduralStream<T> stream;
|
||||
private final int rx;
|
||||
private final int ry;
|
||||
|
||||
public BicubicStream(ProceduralStream<T> stream, int rx, int ry)
|
||||
{
|
||||
this.stream = stream;
|
||||
super(stream);
|
||||
this.rx = rx;
|
||||
this.ry = ry;
|
||||
}
|
||||
@@ -33,23 +32,23 @@ public class BicubicStream<T> extends BasicLayer implements ProceduralStream<T>,
|
||||
double pz = IrisInterpolation.rangeScale(0, 1, z1, z2, y);
|
||||
|
||||
//@builder
|
||||
return stream.fromDouble(IrisInterpolation.bicubic(
|
||||
stream.getDouble(x0, z0),
|
||||
stream.getDouble(x0, z1),
|
||||
stream.getDouble(x0, z2),
|
||||
stream.getDouble(x0, z3),
|
||||
stream.getDouble(x1, z0),
|
||||
stream.getDouble(x1, z1),
|
||||
stream.getDouble(x1, z2),
|
||||
stream.getDouble(x1, z3),
|
||||
stream.getDouble(x2, z0),
|
||||
stream.getDouble(x2, z1),
|
||||
stream.getDouble(x2, z2),
|
||||
stream.getDouble(x2, z3),
|
||||
stream.getDouble(x3, z0),
|
||||
stream.getDouble(x3, z1),
|
||||
stream.getDouble(x3, z2),
|
||||
stream.getDouble(x3, z3),
|
||||
return getTypedSource().fromDouble(IrisInterpolation.bicubic(
|
||||
getTypedSource().getDouble(x0, z0),
|
||||
getTypedSource().getDouble(x0, z1),
|
||||
getTypedSource().getDouble(x0, z2),
|
||||
getTypedSource().getDouble(x0, z3),
|
||||
getTypedSource().getDouble(x1, z0),
|
||||
getTypedSource().getDouble(x1, z1),
|
||||
getTypedSource().getDouble(x1, z2),
|
||||
getTypedSource().getDouble(x1, z3),
|
||||
getTypedSource().getDouble(x2, z0),
|
||||
getTypedSource().getDouble(x2, z1),
|
||||
getTypedSource().getDouble(x2, z2),
|
||||
getTypedSource().getDouble(x2, z3),
|
||||
getTypedSource().getDouble(x3, z0),
|
||||
getTypedSource().getDouble(x3, z1),
|
||||
getTypedSource().getDouble(x3, z2),
|
||||
getTypedSource().getDouble(x3, z3),
|
||||
px, pz));
|
||||
//@done
|
||||
}
|
||||
@@ -57,13 +56,13 @@ public class BicubicStream<T> extends BasicLayer implements ProceduralStream<T>,
|
||||
@Override
|
||||
public double toDouble(T t)
|
||||
{
|
||||
return stream.toDouble(t);
|
||||
return getTypedSource().toDouble(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromDouble(double d)
|
||||
{
|
||||
return stream.fromDouble(d);
|
||||
return getTypedSource().fromDouble(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1,18 +1,17 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.interpolation;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.BasicStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
import com.volmit.iris.util.IrisInterpolation;
|
||||
|
||||
public class BilinearStream<T> extends BasicLayer implements ProceduralStream<T>, Interpolator<T>
|
||||
public class BilinearStream<T> extends BasicStream<T> implements Interpolator<T>
|
||||
{
|
||||
private final ProceduralStream<T> stream;
|
||||
private final int rx;
|
||||
private final int ry;
|
||||
|
||||
public BilinearStream(ProceduralStream<T> stream, int rx, int ry)
|
||||
{
|
||||
this.stream = stream;
|
||||
super(stream);
|
||||
this.rx = rx;
|
||||
this.ry = ry;
|
||||
}
|
||||
@@ -29,11 +28,11 @@ public class BilinearStream<T> extends BasicLayer implements ProceduralStream<T>
|
||||
double pz = IrisInterpolation.rangeScale(0, 1, z1, z2, y);
|
||||
|
||||
//@builder
|
||||
return stream.fromDouble(IrisInterpolation.blerp(
|
||||
stream.getDouble(x1, z1),
|
||||
stream.getDouble(x2, z1),
|
||||
stream.getDouble(x1, z2),
|
||||
stream.getDouble(x2, z2),
|
||||
return getTypedSource().fromDouble(IrisInterpolation.blerp(
|
||||
getTypedSource().getDouble(x1, z1),
|
||||
getTypedSource().getDouble(x2, z1),
|
||||
getTypedSource().getDouble(x1, z2),
|
||||
getTypedSource().getDouble(x2, z2),
|
||||
px, pz));
|
||||
//@done
|
||||
}
|
||||
@@ -41,13 +40,13 @@ public class BilinearStream<T> extends BasicLayer implements ProceduralStream<T>
|
||||
@Override
|
||||
public double toDouble(T t)
|
||||
{
|
||||
return stream.toDouble(t);
|
||||
return getTypedSource().toDouble(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromDouble(double d)
|
||||
{
|
||||
return stream.fromDouble(d);
|
||||
return getTypedSource().fromDouble(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.interpolation;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
public interface Interpolated<T>
|
||||
@@ -1,24 +1,23 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.interpolation;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.BasicStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
import com.volmit.iris.object.InterpolationMethod;
|
||||
import com.volmit.iris.util.IrisInterpolation;
|
||||
import com.volmit.iris.util.NoiseProvider;
|
||||
|
||||
public class InterpolatingStream<T> extends BasicLayer implements ProceduralStream<T>, Interpolator<T>
|
||||
public class InterpolatingStream<T> extends BasicStream<T> implements Interpolator<T>
|
||||
{
|
||||
private final ProceduralStream<T> stream;
|
||||
private final InterpolationMethod type;
|
||||
private final NoiseProvider np;
|
||||
private final int rx;
|
||||
|
||||
public InterpolatingStream(ProceduralStream<T> stream, int rx, InterpolationMethod type)
|
||||
{
|
||||
super(stream);
|
||||
this.type = type;
|
||||
this.stream = stream;
|
||||
this.rx = rx;
|
||||
this.np = (xf, zf) -> stream.getDouble(xf, zf);
|
||||
this.np = (xf, zf) -> getTypedSource().getDouble(xf, zf);
|
||||
}
|
||||
|
||||
public T interpolate(double x, double y)
|
||||
@@ -29,13 +28,13 @@ public class InterpolatingStream<T> extends BasicLayer implements ProceduralStre
|
||||
@Override
|
||||
public double toDouble(T t)
|
||||
{
|
||||
return stream.toDouble(t);
|
||||
return getTypedSource().toDouble(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromDouble(double d)
|
||||
{
|
||||
return stream.fromDouble(d);
|
||||
return getTypedSource().fromDouble(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.interpolation;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
|
||||
public interface Interpolator<T>
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.interpolation;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
import com.volmit.iris.object.InterpolationMethod;
|
||||
|
||||
public class InterpolatorFactory<T>
|
||||
@@ -0,0 +1,139 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.interpolation;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.BasicStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
import com.volmit.iris.util.IrisInterpolation;
|
||||
|
||||
public class TriHermiteStream<T> extends BasicStream<T> implements Interpolator<T>
|
||||
{
|
||||
private final int rx;
|
||||
private final int ry;
|
||||
private final int rz;
|
||||
private final double tension;
|
||||
private final double bias;
|
||||
|
||||
public TriHermiteStream(ProceduralStream<T> stream, int rx, int ry, int rz, double tension, double bias)
|
||||
{
|
||||
super(stream);
|
||||
this.rx = rx;
|
||||
this.ry = ry;
|
||||
this.rz = rz;
|
||||
this.tension = tension;
|
||||
this.bias = bias;
|
||||
}
|
||||
|
||||
public T interpolate(double x, double y, double z)
|
||||
{
|
||||
int fx = (int) Math.floor(x / rx);
|
||||
int fy = (int) Math.floor(y / ry);
|
||||
int fz = (int) Math.floor(z / rz);
|
||||
int x0 = (int) Math.round((fx - 1) * rx);
|
||||
int y0 = (int) Math.round((fy - 1) * ry);
|
||||
int z0 = (int) Math.round((fz - 1) * rz);
|
||||
int x1 = (int) Math.round(fx * rx);
|
||||
int y1 = (int) Math.round(fy * ry);
|
||||
int z1 = (int) Math.round(fz * rz);
|
||||
int x2 = (int) Math.round((fx + 1) * rx);
|
||||
int y2 = (int) Math.round((fy + 1) * ry);
|
||||
int z2 = (int) Math.round((fz + 1) * rz);
|
||||
int x3 = (int) Math.round((fx + 2) * rx);
|
||||
int y3 = (int) Math.round((fy + 2) * ry);
|
||||
int z3 = (int) Math.round((fz + 2) * rz);
|
||||
double px = IrisInterpolation.rangeScale(0, 1, x1, x2, x);
|
||||
double py = IrisInterpolation.rangeScale(0, 1, y1, y2, y);
|
||||
double pz = IrisInterpolation.rangeScale(0, 1, z1, z2, z);
|
||||
|
||||
//@builder
|
||||
return getTypedSource().fromDouble(IrisInterpolation.trihermite(
|
||||
getTypedSource().getDouble(x0, y0, z0),
|
||||
getTypedSource().getDouble(x0, y0,z1),
|
||||
getTypedSource().getDouble(x0, y0,z2),
|
||||
getTypedSource().getDouble(x0, y0,z3),
|
||||
getTypedSource().getDouble(x1, y0,z0),
|
||||
getTypedSource().getDouble(x1, y0,z1),
|
||||
getTypedSource().getDouble(x1, y0,z2),
|
||||
getTypedSource().getDouble(x1, y0,z3),
|
||||
getTypedSource().getDouble(x2, y0,z0),
|
||||
getTypedSource().getDouble(x2, y0,z1),
|
||||
getTypedSource().getDouble(x2, y0,z2),
|
||||
getTypedSource().getDouble(x2, y0,z3),
|
||||
getTypedSource().getDouble(x3, y0,z0),
|
||||
getTypedSource().getDouble(x3, y0,z1),
|
||||
getTypedSource().getDouble(x3, y0,z2),
|
||||
getTypedSource().getDouble(x3, y0,z3),
|
||||
getTypedSource().getDouble(x0, y1, z0),
|
||||
getTypedSource().getDouble(x0, y1,z1),
|
||||
getTypedSource().getDouble(x0, y1,z2),
|
||||
getTypedSource().getDouble(x0, y1,z3),
|
||||
getTypedSource().getDouble(x1, y1,z0),
|
||||
getTypedSource().getDouble(x1, y1,z1),
|
||||
getTypedSource().getDouble(x1, y1,z2),
|
||||
getTypedSource().getDouble(x1, y1,z3),
|
||||
getTypedSource().getDouble(x2, y1,z0),
|
||||
getTypedSource().getDouble(x2, y1,z1),
|
||||
getTypedSource().getDouble(x2, y1,z2),
|
||||
getTypedSource().getDouble(x2, y1,z3),
|
||||
getTypedSource().getDouble(x3, y1,z0),
|
||||
getTypedSource().getDouble(x3, y1,z1),
|
||||
getTypedSource().getDouble(x3, y1,z2),
|
||||
getTypedSource().getDouble(x3, y1,z3),
|
||||
getTypedSource().getDouble(x0, y2, z0),
|
||||
getTypedSource().getDouble(x0, y2,z1),
|
||||
getTypedSource().getDouble(x0, y2,z2),
|
||||
getTypedSource().getDouble(x0, y2,z3),
|
||||
getTypedSource().getDouble(x1, y2,z0),
|
||||
getTypedSource().getDouble(x1, y2,z1),
|
||||
getTypedSource().getDouble(x1, y2,z2),
|
||||
getTypedSource().getDouble(x1, y2,z3),
|
||||
getTypedSource().getDouble(x2, y2,z0),
|
||||
getTypedSource().getDouble(x2, y2,z1),
|
||||
getTypedSource().getDouble(x2, y2,z2),
|
||||
getTypedSource().getDouble(x2, y2,z3),
|
||||
getTypedSource().getDouble(x3, y2,z0),
|
||||
getTypedSource().getDouble(x3, y2,z1),
|
||||
getTypedSource().getDouble(x3, y2,z2),
|
||||
getTypedSource().getDouble(x3, y2,z3),
|
||||
getTypedSource().getDouble(x0, y3, z0),
|
||||
getTypedSource().getDouble(x0, y3,z1),
|
||||
getTypedSource().getDouble(x0, y3,z2),
|
||||
getTypedSource().getDouble(x0, y3,z3),
|
||||
getTypedSource().getDouble(x1, y3,z0),
|
||||
getTypedSource().getDouble(x1, y3,z1),
|
||||
getTypedSource().getDouble(x1, y3,z2),
|
||||
getTypedSource().getDouble(x1, y3,z3),
|
||||
getTypedSource().getDouble(x2, y3,z0),
|
||||
getTypedSource().getDouble(x2, y3,z1),
|
||||
getTypedSource().getDouble(x2, y3,z2),
|
||||
getTypedSource().getDouble(x2, y3,z3),
|
||||
getTypedSource().getDouble(x3, y3,z0),
|
||||
getTypedSource().getDouble(x3, y3,z1),
|
||||
getTypedSource().getDouble(x3, y3,z2),
|
||||
getTypedSource().getDouble(x3, y3,z3),
|
||||
px, pz, py, tension, bias));
|
||||
//@done
|
||||
}
|
||||
|
||||
@Override
|
||||
public double toDouble(T t)
|
||||
{
|
||||
return getTypedSource().toDouble(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromDouble(double d)
|
||||
{
|
||||
return getTypedSource().fromDouble(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double z)
|
||||
{
|
||||
return interpolate(x, 0, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double y, double z)
|
||||
{
|
||||
return interpolate(x, y, z);
|
||||
}
|
||||
}
|
||||
@@ -1,24 +1,23 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.interpolation;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.BasicStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
|
||||
public class TriStarcastStream<T> extends BasicLayer implements ProceduralStream<T>, Interpolator<T>
|
||||
public class TriStarcastStream<T> extends BasicStream<T> implements Interpolator<T>
|
||||
{
|
||||
private ProceduralStream<T> stream;
|
||||
private int rad;
|
||||
private int checks;
|
||||
private final int rad;
|
||||
private final int checks;
|
||||
|
||||
public TriStarcastStream(ProceduralStream<T> stream, int rad, int checks)
|
||||
{
|
||||
this.stream = stream;
|
||||
super(stream);
|
||||
this.rad = rad;
|
||||
this.checks = checks;
|
||||
}
|
||||
|
||||
public T interpolate(double x, double y, double z)
|
||||
{
|
||||
double m = (360 / checks);
|
||||
double m = (360D / checks);
|
||||
double v = 0;
|
||||
|
||||
for(int i = 0; i < 360; i += m)
|
||||
@@ -28,22 +27,22 @@ public class TriStarcastStream<T> extends BasicLayer implements ProceduralStream
|
||||
double cx = x + ((rad * cos) - (rad * sin));
|
||||
double cy = y + ((rad * sin) + (rad * cos));
|
||||
double cz = z + ((rad * cos) - (rad * sin));
|
||||
v += stream.getDouble(cx, cy, cz);
|
||||
v += getTypedSource().getDouble(cx, cy, cz);
|
||||
}
|
||||
|
||||
return stream.fromDouble(v / checks);
|
||||
return getTypedSource().fromDouble(v / checks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double toDouble(T t)
|
||||
{
|
||||
return stream.toDouble(t);
|
||||
return getTypedSource().toDouble(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromDouble(double d)
|
||||
{
|
||||
return stream.fromDouble(d);
|
||||
return getTypedSource().fromDouble(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -0,0 +1,138 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.interpolation;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.BasicStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
import com.volmit.iris.util.IrisInterpolation;
|
||||
|
||||
public class TricubicStream<T> extends BasicStream<T> implements Interpolator<T>
|
||||
{
|
||||
private final int rx;
|
||||
private final int ry;
|
||||
private final int rz;
|
||||
|
||||
public TricubicStream(ProceduralStream<T> stream, int rx, int ry, int rz)
|
||||
{
|
||||
super(stream);
|
||||
this.rx = rx;
|
||||
this.ry = ry;
|
||||
this.rz = rz;
|
||||
}
|
||||
|
||||
public T interpolate(double x, double y, double z)
|
||||
{
|
||||
int fx = (int) Math.floor(x / rx);
|
||||
int fy = (int) Math.floor(y / ry);
|
||||
int fz = (int) Math.floor(z / rz);
|
||||
int x0 = (int) Math.round((fx - 1) * rx);
|
||||
int y0 = (int) Math.round((fy - 1) * ry);
|
||||
int z0 = (int) Math.round((fz - 1) * rz);
|
||||
int x1 = (int) Math.round(fx * rx);
|
||||
int y1 = (int) Math.round(fy * ry);
|
||||
int z1 = (int) Math.round(fz * rz);
|
||||
int x2 = (int) Math.round((fx + 1) * rx);
|
||||
int y2 = (int) Math.round((fy + 1) * ry);
|
||||
int z2 = (int) Math.round((fz + 1) * rz);
|
||||
int x3 = (int) Math.round((fx + 2) * rx);
|
||||
int y3 = (int) Math.round((fy + 2) * ry);
|
||||
int z3 = (int) Math.round((fz + 2) * rz);
|
||||
double px = IrisInterpolation.rangeScale(0, 1, x1, x2, x);
|
||||
double py = IrisInterpolation.rangeScale(0, 1, y1, y2, y);
|
||||
double pz = IrisInterpolation.rangeScale(0, 1, z1, z2, z);
|
||||
|
||||
//@builder
|
||||
return getTypedSource().fromDouble(IrisInterpolation.tricubic(
|
||||
getTypedSource().getDouble(x0, y0, z0),
|
||||
getTypedSource().getDouble(x0, y0,z1),
|
||||
getTypedSource().getDouble(x0, y0,z2),
|
||||
getTypedSource().getDouble(x0, y0,z3),
|
||||
getTypedSource().getDouble(x1, y0,z0),
|
||||
getTypedSource().getDouble(x1, y0,z1),
|
||||
getTypedSource().getDouble(x1, y0,z2),
|
||||
getTypedSource().getDouble(x1, y0,z3),
|
||||
getTypedSource().getDouble(x2, y0,z0),
|
||||
getTypedSource().getDouble(x2, y0,z1),
|
||||
getTypedSource().getDouble(x2, y0,z2),
|
||||
getTypedSource().getDouble(x2, y0,z3),
|
||||
getTypedSource().getDouble(x3, y0,z0),
|
||||
getTypedSource().getDouble(x3, y0,z1),
|
||||
getTypedSource().getDouble(x3, y0,z2),
|
||||
getTypedSource().getDouble(x3, y0,z3),
|
||||
|
||||
getTypedSource().getDouble(x0, y1, z0),
|
||||
getTypedSource().getDouble(x0, y1,z1),
|
||||
getTypedSource().getDouble(x0, y1,z2),
|
||||
getTypedSource().getDouble(x0, y1,z3),
|
||||
getTypedSource().getDouble(x1, y1,z0),
|
||||
getTypedSource().getDouble(x1, y1,z1),
|
||||
getTypedSource().getDouble(x1, y1,z2),
|
||||
getTypedSource().getDouble(x1, y1,z3),
|
||||
getTypedSource().getDouble(x2, y1,z0),
|
||||
getTypedSource().getDouble(x2, y1,z1),
|
||||
getTypedSource().getDouble(x2, y1,z2),
|
||||
getTypedSource().getDouble(x2, y1,z3),
|
||||
getTypedSource().getDouble(x3, y1,z0),
|
||||
getTypedSource().getDouble(x3, y1,z1),
|
||||
getTypedSource().getDouble(x3, y1,z2),
|
||||
getTypedSource().getDouble(x3, y1,z3),
|
||||
|
||||
getTypedSource().getDouble(x0, y2, z0),
|
||||
getTypedSource().getDouble(x0, y2,z1),
|
||||
getTypedSource().getDouble(x0, y2,z2),
|
||||
getTypedSource().getDouble(x0, y2,z3),
|
||||
getTypedSource().getDouble(x1, y2,z0),
|
||||
getTypedSource().getDouble(x1, y2,z1),
|
||||
getTypedSource().getDouble(x1, y2,z2),
|
||||
getTypedSource().getDouble(x1, y2,z3),
|
||||
getTypedSource().getDouble(x2, y2,z0),
|
||||
getTypedSource().getDouble(x2, y2,z1),
|
||||
getTypedSource().getDouble(x2, y2,z2),
|
||||
getTypedSource().getDouble(x2, y2,z3),
|
||||
getTypedSource().getDouble(x3, y2,z0),
|
||||
getTypedSource().getDouble(x3, y2,z1),
|
||||
getTypedSource().getDouble(x3, y2,z2),
|
||||
getTypedSource().getDouble(x3, y2,z3),
|
||||
|
||||
getTypedSource().getDouble(x0, y3, z0),
|
||||
getTypedSource().getDouble(x0, y3,z1),
|
||||
getTypedSource().getDouble(x0, y3,z2),
|
||||
getTypedSource().getDouble(x0, y3,z3),
|
||||
getTypedSource().getDouble(x1, y3,z0),
|
||||
getTypedSource().getDouble(x1, y3,z1),
|
||||
getTypedSource().getDouble(x1, y3,z2),
|
||||
getTypedSource().getDouble(x1, y3,z3),
|
||||
getTypedSource().getDouble(x2, y3,z0),
|
||||
getTypedSource().getDouble(x2, y3,z1),
|
||||
getTypedSource().getDouble(x2, y3,z2),
|
||||
getTypedSource().getDouble(x2, y3,z3),
|
||||
getTypedSource().getDouble(x3, y3,z0),
|
||||
getTypedSource().getDouble(x3, y3,z1),
|
||||
getTypedSource().getDouble(x3, y3,z2),
|
||||
getTypedSource().getDouble(x3, y3,z3),
|
||||
px, pz, py));
|
||||
//@done
|
||||
}
|
||||
|
||||
@Override
|
||||
public double toDouble(T t)
|
||||
{
|
||||
return getTypedSource().toDouble(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromDouble(double d)
|
||||
{
|
||||
return getTypedSource().fromDouble(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double z)
|
||||
{
|
||||
return interpolate(x, 0, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double y, double z)
|
||||
{
|
||||
return interpolate(x, y, z);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,18 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.interpolation;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.BasicStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
import com.volmit.iris.util.IrisInterpolation;
|
||||
|
||||
public class TrilinearStream<T> extends BasicLayer implements ProceduralStream<T>, Interpolator<T>
|
||||
public class TrilinearStream<T> extends BasicStream<T> implements Interpolator<T>
|
||||
{
|
||||
private final ProceduralStream<T> stream;
|
||||
private final int rx;
|
||||
private final int ry;
|
||||
private final int rz;
|
||||
|
||||
public TrilinearStream(ProceduralStream<T> stream, int rx, int ry, int rz)
|
||||
{
|
||||
this.stream = stream;
|
||||
super(stream);
|
||||
this.rx = rx;
|
||||
this.ry = ry;
|
||||
this.rz = rz;
|
||||
@@ -35,15 +34,15 @@ public class TrilinearStream<T> extends BasicLayer implements ProceduralStream<T
|
||||
double pz = IrisInterpolation.rangeScale(0, 1, z1, z2, z);
|
||||
|
||||
//@builder
|
||||
return stream.fromDouble(IrisInterpolation.trilerp(
|
||||
stream.getDouble(x1, y1, z1),
|
||||
stream.getDouble(x2, y1, z1),
|
||||
stream.getDouble(x1, y1, z2),
|
||||
stream.getDouble(x2, y1, z2),
|
||||
stream.getDouble(x1, y2, z1),
|
||||
stream.getDouble(x2, y2, z1),
|
||||
stream.getDouble(x1, y2, z2),
|
||||
stream.getDouble(x2, y2, z2),
|
||||
return getTypedSource().fromDouble(IrisInterpolation.trilerp(
|
||||
getTypedSource().getDouble(x1, y1, z1),
|
||||
getTypedSource().getDouble(x2, y1, z1),
|
||||
getTypedSource().getDouble(x1, y1, z2),
|
||||
getTypedSource().getDouble(x2, y1, z2),
|
||||
getTypedSource().getDouble(x1, y2, z1),
|
||||
getTypedSource().getDouble(x2, y2, z1),
|
||||
getTypedSource().getDouble(x1, y2, z2),
|
||||
getTypedSource().getDouble(x2, y2, z2),
|
||||
px, pz, py));
|
||||
//@done
|
||||
}
|
||||
@@ -51,13 +50,13 @@ public class TrilinearStream<T> extends BasicLayer implements ProceduralStream<T
|
||||
@Override
|
||||
public double toDouble(T t)
|
||||
{
|
||||
return stream.toDouble(t);
|
||||
return getTypedSource().toDouble(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromDouble(double d)
|
||||
{
|
||||
return stream.fromDouble(d);
|
||||
return getTypedSource().fromDouble(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.sources;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.BasicLayer;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
import com.volmit.iris.noise.CNG;
|
||||
|
||||
public class CNGStream extends BasicLayer implements ProceduralStream<Double>
|
||||
@@ -37,6 +37,16 @@ public class CNGStream extends BasicLayer implements ProceduralStream<Double>
|
||||
return d;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProceduralStream<Double> getTypedSource() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProceduralStream<?> getSource() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double get(double x, double z)
|
||||
{
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.sources;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.BasicStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.interpolation.Interpolated;
|
||||
import com.volmit.iris.util.Function2;
|
||||
import com.volmit.iris.util.Function3;
|
||||
|
||||
public class FunctionStream<T> extends BasicLayer implements ProceduralStream<T>
|
||||
public class FunctionStream<T> extends BasicStream<T>
|
||||
{
|
||||
private Function2<Double, Double, T> f2;
|
||||
private Function3<Double, Double, Double, T> f3;
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.utility;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import com.github.benmanes.caffeine.cache.LoadingCache;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.BasicStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
import com.volmit.iris.util.ChunkPosition;
|
||||
|
||||
public class CachedStream2D<T> extends BasicLayer implements ProceduralStream<T>
|
||||
public class CachedStream2D<T> extends BasicStream<T> implements ProceduralStream<T>
|
||||
{
|
||||
private final ProceduralStream<T> stream;
|
||||
private final LoadingCache<ChunkPosition, T> cache;
|
||||
@@ -0,0 +1,179 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.utility;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.BasicStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
import com.volmit.iris.util.Form;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.PrecisionStopwatch;
|
||||
import com.volmit.iris.util.RollingSequence;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class ProfiledStream<T> extends BasicStream<T>
|
||||
{
|
||||
public static final AtomicInteger ids = new AtomicInteger();
|
||||
private final int id;
|
||||
private final RollingSequence metrics;
|
||||
|
||||
public ProfiledStream(ProceduralStream<T> stream, int memory)
|
||||
{
|
||||
super(stream);
|
||||
this.metrics = new RollingSequence(memory);
|
||||
this.id = ids.getAndAdd(1);
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double toDouble(T t)
|
||||
{
|
||||
return getTypedSource().toDouble(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromDouble(double d)
|
||||
{
|
||||
return getTypedSource().fromDouble(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double z)
|
||||
{
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
T t = getTypedSource().get(x, z);
|
||||
try
|
||||
{
|
||||
metrics.put(p.getMilliseconds());
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double y, double z)
|
||||
{
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
T t = getTypedSource().get(x, y, z);
|
||||
try
|
||||
{
|
||||
metrics.put(p.getMilliseconds());
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
public RollingSequence getMetrics()
|
||||
{
|
||||
return metrics;
|
||||
}
|
||||
|
||||
public static void print(Consumer<String> printer, ProceduralStream<?> stream) {
|
||||
KList<ProfiledTail> tails = getTails(stream);
|
||||
int ind = tails.size();
|
||||
for(ProfiledTail i : tails)
|
||||
{
|
||||
printer.accept(Form.repeat(" ", ind) + i);
|
||||
ind--;
|
||||
}
|
||||
}
|
||||
|
||||
private static KList<ProceduralStream<?>> getAllChildren(ProceduralStream<?> s)
|
||||
{
|
||||
KList<ProceduralStream<?>> v = new KList<>();
|
||||
ProceduralStream<?> cursor = s;
|
||||
|
||||
for(int i = 0; i < 32; i++)
|
||||
{
|
||||
v.add(cursor);
|
||||
cursor = nextChuld(cursor);
|
||||
|
||||
if(cursor == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
private static ProceduralStream<?> nextChuld(ProceduralStream<?> s)
|
||||
{
|
||||
ProceduralStream<?> v = s.getTypedSource();
|
||||
return v == null ? s.getSource() : v;
|
||||
}
|
||||
|
||||
private static ProfiledTail getTail(ProceduralStream<?> t)
|
||||
{
|
||||
if(t instanceof ProfiledStream)
|
||||
{
|
||||
ProfiledStream<?> s = ((ProfiledStream<?>)t);
|
||||
|
||||
return new ProfiledTail(s.getId(), s.getMetrics(), s.getClass().getSimpleName().replaceAll("\\QStream\\E", ""));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static KList<ProfiledTail> getTails(ProceduralStream<?> t) {
|
||||
KList<ProfiledTail> tails = new KList<>();
|
||||
|
||||
for (ProceduralStream<?> v : getAllChildren(t)) {
|
||||
ProfiledTail p = getTail(v);
|
||||
|
||||
if (p != null) {
|
||||
tails.add(p);
|
||||
}
|
||||
}
|
||||
|
||||
if (tails.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
ProfiledTail cursor = tails.popLast();
|
||||
KList<ProfiledTail> tailx = new KList<>();
|
||||
tailx.add(cursor);
|
||||
|
||||
while(tails.isNotEmpty())
|
||||
{
|
||||
tailx.add(cursor);
|
||||
ProfiledTail parent = tails.popLast();
|
||||
parent.setChild(cursor);
|
||||
cursor = parent;
|
||||
tailx.add(cursor);
|
||||
}
|
||||
|
||||
return tailx;
|
||||
}
|
||||
|
||||
@Data
|
||||
private static class ProfiledTail
|
||||
{
|
||||
private final int id;
|
||||
private final RollingSequence metrics;
|
||||
private ProfiledTail child;
|
||||
private final String name;
|
||||
|
||||
public ProfiledTail(int id, RollingSequence metrics, String name) {
|
||||
this.id = id;
|
||||
this.metrics = metrics;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return id + "-" + name + ": " + Form.duration(metrics.getAverage(), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.utility;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.BasicStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
|
||||
import java.util.concurrent.Semaphore;
|
||||
|
||||
public class SemaphoreStream<T> extends BasicStream<T>
|
||||
{
|
||||
private final Semaphore semaphore;
|
||||
|
||||
public SemaphoreStream(ProceduralStream<T> stream, int permits)
|
||||
{
|
||||
super(stream);
|
||||
this.semaphore = new Semaphore(permits);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double toDouble(T t)
|
||||
{
|
||||
return getTypedSource().toDouble(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromDouble(double d)
|
||||
{
|
||||
return getTypedSource().fromDouble(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double z)
|
||||
{
|
||||
synchronized (getTypedSource())
|
||||
{
|
||||
return getTypedSource().get(x, z);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double y, double z)
|
||||
{
|
||||
synchronized (getTypedSource())
|
||||
{
|
||||
return getTypedSource().get(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.volmit.iris.gen.v2.scaffold.stream.utility;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.BasicStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
import com.volmit.iris.util.PrecisionStopwatch;
|
||||
import com.volmit.iris.util.RollingSequence;
|
||||
|
||||
public class SynchronizedStream<T> extends BasicStream<T>
|
||||
{
|
||||
public SynchronizedStream(ProceduralStream<T> stream)
|
||||
{
|
||||
super(stream);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double toDouble(T t)
|
||||
{
|
||||
return getTypedSource().toDouble(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromDouble(double d)
|
||||
{
|
||||
return getTypedSource().fromDouble(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double z)
|
||||
{
|
||||
synchronized (getTypedSource())
|
||||
{
|
||||
return getTypedSource().get(x, z);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double y, double z)
|
||||
{
|
||||
synchronized (getTypedSource())
|
||||
{
|
||||
return getTypedSource().get(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,9 @@ package com.volmit.iris.noise;
|
||||
import java.util.List;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.CNGStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.FittedStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.sources.CNGStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.arithmetic.FittedStream;
|
||||
import com.volmit.iris.util.IRare;
|
||||
import com.volmit.iris.util.IrisInterpolation;
|
||||
import com.volmit.iris.util.KList;
|
||||
@@ -345,8 +345,8 @@ public class CNG
|
||||
double scale = noscale ? 1 : this.bakedScale * this.scale;
|
||||
double f = noscale ? 0 : (fracture != null ? (fracture.noise(dim) - 0.5) * fscale : 0D);
|
||||
double x = dim.length > 0 ? dim[0] + f : 0D;
|
||||
double y = dim.length > 1 ? dim[1] + f : 0D;
|
||||
double z = dim.length > 2 ? dim[2] + f : 0D;
|
||||
double y = dim.length > 1 ? dim[1] + -f : 0D;
|
||||
double z = dim.length > 2 ? dim[2] + -f : 0D;
|
||||
double n = generator.noise(x * scale, y * scale, z * scale) * opacity;
|
||||
n = power != 1D ? (n < 0 ? -Math.pow(Math.abs(n), power) : Math.pow(n, power)) : n;
|
||||
double m = 1;
|
||||
|
||||
@@ -208,7 +208,7 @@ public class IrisBiome extends IrisRegistrant implements IRare
|
||||
|
||||
public double getGenLinkMax(String loadKey)
|
||||
{
|
||||
return genCacheMax.aquire(() ->
|
||||
Integer v = genCacheMax.aquire(() ->
|
||||
{
|
||||
KMap<String, Integer> l = new KMap<>();
|
||||
|
||||
@@ -218,12 +218,14 @@ public class IrisBiome extends IrisRegistrant implements IRare
|
||||
}
|
||||
|
||||
return l;
|
||||
}).compute(loadKey, (k, v) -> v != null ? v : 0);
|
||||
}).get(loadKey);
|
||||
|
||||
return v == null ? 0 : v;
|
||||
}
|
||||
|
||||
public double getGenLinkMin(String loadKey)
|
||||
{
|
||||
return genCacheMin.aquire(() ->
|
||||
Integer v = genCacheMin.aquire(() ->
|
||||
{
|
||||
KMap<String, Integer> l = new KMap<>();
|
||||
|
||||
@@ -233,7 +235,9 @@ public class IrisBiome extends IrisRegistrant implements IRare
|
||||
}
|
||||
|
||||
return l;
|
||||
}).compute(loadKey, (k, v) -> v != null ? v : 0);
|
||||
}).get(loadKey);
|
||||
|
||||
return v == null ? 0 : v;
|
||||
}
|
||||
|
||||
public IrisBiomeGeneratorLink getGenLink(String loadKey)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.volmit.iris.object;
|
||||
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.ProceduralStream;
|
||||
import com.volmit.iris.noise.CNG;
|
||||
import com.volmit.iris.noise.CNGFactory;
|
||||
import com.volmit.iris.noise.NoiseType;
|
||||
|
||||
Reference in New Issue
Block a user