mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-19 02:36:59 +00:00
Bitshifting streams
This commit is contained in:
parent
695cf24861
commit
59eda04949
@ -12,6 +12,8 @@ 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;
|
||||
@ -82,6 +84,46 @@ public interface ProceduralStream<T> extends ProceduralLayer, Interpolated<T>
|
||||
return new AddingStream<>(this, a);
|
||||
}
|
||||
|
||||
default ProceduralStream<T> blockToChunkCoords()
|
||||
{
|
||||
return bitShiftCoordsRight(4);
|
||||
}
|
||||
|
||||
default ProceduralStream<T> chunkToRegionCoords()
|
||||
{
|
||||
return bitShiftCoordsRight(5);
|
||||
}
|
||||
|
||||
default ProceduralStream<T> blockToRegionCoords()
|
||||
{
|
||||
return blockToChunkCoords().chunkToRegionCoords();
|
||||
}
|
||||
|
||||
default ProceduralStream<T> regionToBlockCoords()
|
||||
{
|
||||
return regionToChunkCoords().chunkToBlockCoords();
|
||||
}
|
||||
|
||||
default ProceduralStream<T> regionToChunkCoords()
|
||||
{
|
||||
return bitShiftCoordsLeft(5);
|
||||
}
|
||||
|
||||
default ProceduralStream<T> chunkToBlockCoords()
|
||||
{
|
||||
return bitShiftCoordsLeft(4);
|
||||
}
|
||||
|
||||
default ProceduralStream<T> bitShiftCoordsRight(int a)
|
||||
{
|
||||
return new CoordinateBitShiftRightStream<>(this, a);
|
||||
}
|
||||
|
||||
default ProceduralStream<T> bitShiftCoordsLeft(int a)
|
||||
{
|
||||
return new CoordinateBitShiftLeftStream<>(this, a);
|
||||
}
|
||||
|
||||
default ProceduralStream<T> max(Function3<Double, Double, Double, Double> a)
|
||||
{
|
||||
return new MaxingStream<>(this, a);
|
||||
|
@ -0,0 +1,42 @@
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
@ -2,10 +2,15 @@ package com.volmit.iris.gen.v2.scaffold.stream;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
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>
|
||||
{
|
||||
public static final Interpolated<BlockData> BLOCK_DATA = of((t) -> 0D, (t) -> null);
|
||||
public static final Interpolated<RNG> RNG = of((t) -> 0D, (t) -> null);
|
||||
public static final Interpolated<Double> DOUBLE = of((t) -> t, (t) -> t);
|
||||
public static final Interpolated<Integer> INT = of((t) -> Double.valueOf(t), (t) -> t.intValue());
|
||||
public static final Interpolated<Long> LONG = of((t) -> Double.valueOf(t), (t) -> t.longValue());
|
||||
|
Loading…
x
Reference in New Issue
Block a user