Optimization

This commit is contained in:
Daniel Mills committed 2020-09-02 21:06:01 -04:00
1 parent e6b59bc16d
commit 9aa6d1c0fc
19 files changed
+242 -307

No files matched your search

@@ -28,7 +28,6 @@ import com.volmit.iris.util.IrisLock;
import com.volmit.iris.util.IrisStructureResult; import com.volmit.iris.util.IrisStructureResult;
import com.volmit.iris.util.KList; import com.volmit.iris.util.KList;
import com.volmit.iris.util.KMap; import com.volmit.iris.util.KMap;
import com.volmit.iris.util.NastyRunnable;
import com.volmit.iris.util.PrecisionStopwatch; import com.volmit.iris.util.PrecisionStopwatch;
import com.volmit.iris.util.RNG; import com.volmit.iris.util.RNG;
@@ -45,7 +44,6 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
private MasterLock masterLock; private MasterLock masterLock;
private IrisLock flock = new IrisLock("ParallaxLock"); private IrisLock flock = new IrisLock("ParallaxLock");
private IrisLock lock = new IrisLock("ParallaxLock"); private IrisLock lock = new IrisLock("ParallaxLock");
private IrisLock lockq = new IrisLock("ParallaxQueueLock");
private GenLayerUpdate glUpdate; private GenLayerUpdate glUpdate;
private GenLayerText glText; private GenLayerText glText;
private int sliverBuffer; private int sliverBuffer;
@@ -230,7 +228,6 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
{ {
String key = "par." + x + "." + z; String key = "par." + x + "." + z;
ChunkPosition rad = getDimension().getParallaxSize(this); ChunkPosition rad = getDimension().getParallaxSize(this);
KList<NastyRunnable> q = new KList<>();
for(int ii = x - (rad.getX() / 2); ii <= x + (rad.getX() / 2); ii++) for(int ii = x - (rad.getX() / 2); ii <= x + (rad.getX() / 2); ii++)
{ {
@@ -275,12 +272,7 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
for(IrisObjectPlacement m : k.getObjects()) for(IrisObjectPlacement m : k.getObjects())
{ {
int gg = g++; int gg = g++;
lockq.lock(); placeObject(m, i, j, random.nextParallelRNG((34 * ((i * 30) + (j * 30) + gg) * i * j) + i - j + 1569962));
q.add(() ->
{
placeObject(m, i, j, random.nextParallelRNG((34 * ((i * 30) + (j * 30) + gg) * i * j) + i - j + 1569962));
});
lockq.unlock();
} }
continue searching; continue searching;
@@ -292,63 +284,33 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
for(IrisTextPlacement k : getDimension().getText()) for(IrisTextPlacement k : getDimension().getText())
{ {
lockq.lock(); k.place(this, random.nextParallelRNG(-7228 + (34 * ((i * 30) + (j * 30)) * i * j) + i - j + 1569962), i, j);
q.add(() ->
{
k.place(this, random.nextParallelRNG(-7228 + (34 * ((i * 30) + (j * 30)) * i * j) + i - j + 1569962), i, j);
});
lockq.unlock();
} }
for(IrisTextPlacement k : r.getText()) for(IrisTextPlacement k : r.getText())
{ {
lockq.lock(); k.place(this, random.nextParallelRNG(-4228 + -7228 + (34 * ((i * 30) + (j * 30)) * i * j) + i - j + 1569962), i, j);
q.add(() ->
{
k.place(this, random.nextParallelRNG(-4228 + -7228 + (34 * ((i * 30) + (j * 30)) * i * j) + i - j + 1569962), i, j);
});
lockq.unlock();
} }
for(IrisTextPlacement k : b.getText()) for(IrisTextPlacement k : b.getText())
{ {
lockq.lock(); k.place(this, random.nextParallelRNG(-22228 + -4228 + -7228 + (34 * ((i * 30) + (j * 30)) * i * j) + i - j + 1569962), i, j);
q.add(() ->
{
k.place(this, random.nextParallelRNG(-22228 + -4228 + -7228 + (34 * ((i * 30) + (j * 30)) * i * j) + i - j + 1569962), i, j);
});
lockq.unlock();
} }
for(IrisStructurePlacement k : r.getStructures()) for(IrisStructurePlacement k : r.getStructures())
{ {
lockq.lock(); k.place(this, random.nextParallelRNG(2228), i, j);
q.add(() ->
{
k.place(this, random.nextParallelRNG(2228), i, j);
});
lockq.unlock();
} }
for(IrisStructurePlacement k : b.getStructures()) for(IrisStructurePlacement k : b.getStructures())
{ {
lockq.lock(); k.place(this, random.nextParallelRNG(-22228), i, j);
q.add(() ->
{
k.place(this, random.nextParallelRNG(-22228), i, j);
});
lockq.unlock();
} }
for(IrisObjectPlacement k : b.getObjects()) for(IrisObjectPlacement k : b.getObjects())
{ {
int gg = g++; int gg = g++;
lockq.lock(); placeObject(k, i, j, random.nextParallelRNG((34 * ((i * 30) + (j * 30) + gg) * i * j) + i - j + 3569222));
q.add(() ->
{
placeObject(k, i, j, random.nextParallelRNG((34 * ((i * 30) + (j * 30) + gg) * i * j) + i - j + 3569222));
});
lockq.unlock();
} }
if(getDimension().isCaves()) if(getDimension().isCaves())
@@ -371,12 +333,7 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
for(IrisObjectPlacement k : biome.getObjects()) for(IrisObjectPlacement k : biome.getObjects())
{ {
int gg = g++; int gg = g++;
lockq.lock(); placeCaveObject(k, i, j, random.nextParallelRNG((34 * ((i * 30) + (j * 30) + gg) * i * j) + i - j + 1869322));
q.add(() ->
{
placeCaveObject(k, i, j, random.nextParallelRNG((34 * ((i * 30) + (j * 30) + gg) * i * j) + i - j + 1869322));
});
lockq.unlock();
} }
} }
}); });
@@ -386,14 +343,6 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
} }
getAccelerant().waitFor(key); getAccelerant().waitFor(key);
lockq.lock();
for(NastyRunnable i : q)
{
getAccelerant().queue(key + "-obj", i);
}
lockq.unlock();
getAccelerant().waitFor(key + "-obj");
} }
public void placeObject(IrisObjectPlacement o, int x, int z, RNG rng) public void placeObject(IrisObjectPlacement o, int x, int z, RNG rng)
@@ -37,7 +37,7 @@ public abstract class ParallelChunkGenerator extends DimensionChunkGenerator
{ {
threads = tc; threads = tc;
GroupedExecutor e = accelerant; GroupedExecutor e = accelerant;
accelerant = new GroupedExecutor(threads, Thread.NORM_PRIORITY, "Iris Generator - " + world.getName()); accelerant = new GroupedExecutor(threads, Thread.MAX_PRIORITY, "Iris Generator - " + world.getName());
Iris.executors.add(accelerant); Iris.executors.add(accelerant);
if(e != null) if(e != null)
@@ -90,8 +90,7 @@ public abstract class ParallelChunkGenerator extends DimensionChunkGenerator
int j = jj; int j = jj;
int wz = (z * 16) + j; int wz = (z * 16) + j;
AtomicSliver sliver = map.getSliver(i, j); AtomicSliver sliver = map.getSliver(i, j);
getAccelerant().queue(key, () ->
accelerant.queue(key, () ->
{ {
try try
{ {
@@ -200,10 +200,10 @@ public class GenLayerBiome extends GenLayer
double x = bx / iris.getDimension().getBiomeZoom(); double x = bx / iris.getDimension().getBiomeZoom();
double z = bz / iris.getDimension().getBiomeZoom(); double z = bz / iris.getDimension().getBiomeZoom();
if(!parent.getRealChildren(iris).isEmpty()) if(parent.getRealChildren(iris).isNotEmpty())
{ {
CNG childCell = parent.getChildrenGenerator(rng, 123, parent.getChildShrinkFactor()); CNG childCell = parent.getChildrenGenerator(rng, 123, parent.getChildShrinkFactor());
KList<IrisBiome> chx = parent.getRealChildren(iris).copy(); // TODO Cache KList<IrisBiome> chx = parent.getRealChildren(iris).copy();
chx.add(parent); chx.add(parent);
IrisBiome biome = childCell.fitRarity(chx, x, z); IrisBiome biome = childCell.fitRarity(chx, x, z);
biome.setInferredType(parent.getInferredType()); biome.setInferredType(parent.getInferredType());
@@ -40,9 +40,9 @@ public class GenLayerCave extends GenLayer
} }
KList<CaveResult> result = new KList<>(); KList<CaveResult> result = new KList<>();
gg.SetNoiseType(NoiseType.Cellular); gg.setNoiseType(NoiseType.Cellular);
gg.SetCellularReturnType(CellularReturnType.Distance2Sub); gg.setCellularReturnType(CellularReturnType.Distance2Sub);
gg.SetCellularDistanceFunction(CellularDistanceFunction.Natural); gg.setCellularDistanceFunction(CellularDistanceFunction.Natural);
for(int i = 0; i < iris.getDimension().getCaveLayers().size(); i++) for(int i = 0; i < iris.getDimension().getCaveLayers().size(); i++)
{ {
@@ -27,13 +27,13 @@ public class CellGenerator
RNG rx = rng.nextParallelRNG(8735652); RNG rx = rng.nextParallelRNG(8735652);
int s = rx.nextInt(); int s = rx.nextInt();
fn = new FastNoise(s); fn = new FastNoise(s);
fn.SetNoiseType(FastNoise.NoiseType.Cellular); fn.setNoiseType(FastNoise.NoiseType.Cellular);
fn.SetCellularReturnType(FastNoise.CellularReturnType.CellValue); fn.setCellularReturnType(FastNoise.CellularReturnType.CellValue);
fn.SetCellularDistanceFunction(FastNoise.CellularDistanceFunction.Natural); fn.setCellularDistanceFunction(FastNoise.CellularDistanceFunction.Natural);
fd = new FastNoise(s); fd = new FastNoise(s);
fd.SetNoiseType(FastNoise.NoiseType.Cellular); fd.setNoiseType(FastNoise.NoiseType.Cellular);
fd.SetCellularReturnType(FastNoise.CellularReturnType.Distance2Sub); fd.setCellularReturnType(FastNoise.CellularReturnType.Distance2Sub);
fd.SetCellularDistanceFunction(FastNoise.CellularDistanceFunction.Natural); fd.setCellularDistanceFunction(FastNoise.CellularDistanceFunction.Natural);
} }
public float getDistance(double x, double z) public float getDistance(double x, double z)
@@ -7,9 +7,9 @@ public class CellHeightNoise implements NoiseGenerator {
public CellHeightNoise(long seed) { public CellHeightNoise(long seed) {
this.n = new FastNoise((int) seed); this.n = new FastNoise((int) seed);
n.SetNoiseType(FastNoise.NoiseType.Cellular); n.setNoiseType(FastNoise.NoiseType.Cellular);
n.SetCellularReturnType(FastNoise.CellularReturnType.Distance2Sub); n.setCellularReturnType(FastNoise.CellularReturnType.Distance2Sub);
n.SetCellularDistanceFunction(FastNoise.CellularDistanceFunction.Natural); n.setCellularDistanceFunction(FastNoise.CellularDistanceFunction.Natural);
} }
private double filter(double noise) { private double filter(double noise) {
@@ -1,27 +1,32 @@
package com.volmit.iris.noise; package com.volmit.iris.noise;
public class CellularNoise implements NoiseGenerator { public class CellularNoise implements NoiseGenerator
{
private final FastNoise n; private final FastNoise n;
public CellularNoise(long seed) { public CellularNoise(long seed)
{
this.n = new FastNoise((int) seed); this.n = new FastNoise((int) seed);
n.SetNoiseType(FastNoise.NoiseType.Cellular); n.setNoiseType(FastNoise.NoiseType.Cellular);
n.SetCellularReturnType(FastNoise.CellularReturnType.CellValue); n.setCellularReturnType(FastNoise.CellularReturnType.CellValue);
n.SetCellularDistanceFunction(FastNoise.CellularDistanceFunction.Natural); n.setCellularDistanceFunction(FastNoise.CellularDistanceFunction.Natural);
} }
@Override @Override
public double noise(double x) { public double noise(double x)
{
return (n.GetCellular((float) x, 0) / 2D) + 0.5D; return (n.GetCellular((float) x, 0) / 2D) + 0.5D;
} }
@Override @Override
public double noise(double x, double z) { public double noise(double x, double z)
{
return (n.GetCellular((float) x, (float) z) / 2D) + 0.5D; return (n.GetCellular((float) x, (float) z) / 2D) + 0.5D;
} }
@Override @Override
public double noise(double x, double y, double z) { public double noise(double x, double y, double z)
{
return (n.GetCellular((float) x, (float) y, (float) z) / 2D) + 0.5D; return (n.GetCellular((float) x, (float) y, (float) z) / 2D) + 0.5D;
} }
} }
+184 -184
View File
@@ -81,7 +81,7 @@ public class FastNoise
private int m_seed = 1337; private int m_seed = 1337;
private float m_frequency = (float) 0.01; private float m_frequency = (float) 0.01;
private Interp m_interp = Interp.Quintic; private Interp m_interp = Interp.Linear;
private NoiseType m_noiseType = NoiseType.Simplex; private NoiseType m_noiseType = NoiseType.Simplex;
private int m_octaves = 3; private int m_octaves = 3;
@@ -105,31 +105,31 @@ public class FastNoise
public FastNoise(int seed) public FastNoise(int seed)
{ {
m_seed = seed; m_seed = seed;
CalculateFractalBounding(); calculateFractalBounding();
} }
// Returns a 0 float/double // Returns a 0 float/double
public static float GetDecimalType() public static float getDecimalType()
{ {
return 0; return 0;
} }
// Returns the seed used by this object // Returns the seed used by this object
public int GetSeed() public int getSeed()
{ {
return m_seed; return m_seed;
} }
// Sets seed used for all noise types // Sets seed used for all noise types
// Default: 1337 // Default: 1337
public void SetSeed(int seed) public void setSeed(int seed)
{ {
m_seed = seed; m_seed = seed;
} }
// Sets frequency for all noise types // Sets frequency for all noise types
// Default: 0.01 // Default: 0.01
public void SetFrequency(float frequency) public void setFrequency(float frequency)
{ {
m_frequency = frequency; m_frequency = frequency;
} }
@@ -141,44 +141,44 @@ public class FastNoise
// - Quintic // - Quintic
// Used in Value, Gradient Noise and Position Perturbing // Used in Value, Gradient Noise and Position Perturbing
// Default: Quintic // Default: Quintic
public void SetInterp(Interp interp) public void setInterp(Interp interp)
{ {
m_interp = interp; m_interp = interp;
} }
// Sets noise return type of GetNoise(...) // Sets noise return type of GetNoise(...)
// Default: Simplex // Default: Simplex
public void SetNoiseType(NoiseType noiseType) public void setNoiseType(NoiseType noiseType)
{ {
m_noiseType = noiseType; m_noiseType = noiseType;
} }
// Sets octave count for all fractal noise types // Sets octave count for all fractal noise types
// Default: 3 // Default: 3
public void SetFractalOctaves(int octaves) public void setFractalOctaves(int octaves)
{ {
m_octaves = octaves; m_octaves = octaves;
CalculateFractalBounding(); calculateFractalBounding();
} }
// Sets octave lacunarity for all fractal noise types // Sets octave lacunarity for all fractal noise types
// Default: 2.0 // Default: 2.0
public void SetFractalLacunarity(float lacunarity) public void setFractalLacunarity(float lacunarity)
{ {
m_lacunarity = lacunarity; m_lacunarity = lacunarity;
} }
// Sets octave gain for all fractal noise types // Sets octave gain for all fractal noise types
// Default: 0.5 // Default: 0.5
public void SetFractalGain(float gain) public void setFractalGain(float gain)
{ {
m_gain = gain; m_gain = gain;
CalculateFractalBounding(); calculateFractalBounding();
} }
// Sets method for combining octaves in all fractal noise types // Sets method for combining octaves in all fractal noise types
// Default: FBM // Default: FBM
public void SetFractalType(FractalType fractalType) public void setFractalType(FractalType fractalType)
{ {
m_fractalType = fractalType; m_fractalType = fractalType;
} }
@@ -187,14 +187,14 @@ public class FastNoise
// Note: NoiseLookup requires another FastNoise object be set with // Note: NoiseLookup requires another FastNoise object be set with
// SetCellularNoiseLookup() to function // SetCellularNoiseLookup() to function
// Default: CellValue // Default: CellValue
public void SetCellularDistanceFunction(CellularDistanceFunction cellularDistanceFunction) public void setCellularDistanceFunction(CellularDistanceFunction cellularDistanceFunction)
{ {
m_cellularDistanceFunction = cellularDistanceFunction; m_cellularDistanceFunction = cellularDistanceFunction;
} }
// Sets distance function used in cellular noise calculations // Sets distance function used in cellular noise calculations
// Default: Euclidean // Default: Euclidean
public void SetCellularReturnType(CellularReturnType cellularReturnType) public void setCellularReturnType(CellularReturnType cellularReturnType)
{ {
m_cellularReturnType = cellularReturnType; m_cellularReturnType = cellularReturnType;
} }
@@ -202,7 +202,7 @@ public class FastNoise
// Noise used to calculate a cell value if cellular return type is NoiseLookup // Noise used to calculate a cell value if cellular return type is NoiseLookup
// The lookup value is acquired through GetNoise() so ensure you SetNoiseType() // The lookup value is acquired through GetNoise() so ensure you SetNoiseType()
// on the noise lookup, value, gradient or simplex is recommended // on the noise lookup, value, gradient or simplex is recommended
public void SetCellularNoiseLookup(FastNoise noise) public void setCellularNoiseLookup(FastNoise noise)
{ {
m_cellularNoiseLookup = noise; m_cellularNoiseLookup = noise;
} }
@@ -210,7 +210,7 @@ public class FastNoise
// Sets the maximum perturb distance from original location when using // Sets the maximum perturb distance from original location when using
// GradientPerturb{Fractal}(...) // GradientPerturb{Fractal}(...)
// Default: 1.0 // Default: 1.0
public void SetGradientPerturbAmp(float gradientPerturbAmp) public void setGradientPerturbAmp(float gradientPerturbAmp)
{ {
m_gradientPerturbAmp = gradientPerturbAmp / (float) 0.45; m_gradientPerturbAmp = gradientPerturbAmp / (float) 0.45;
} }
@@ -250,38 +250,38 @@ public class FastNoise
private static final Float3[] CELL_3D = {new Float3(0.1453787434f, -0.4149781685f, -0.0956981749f), new Float3(-0.01242829687f, -0.1457918398f, -0.4255470325f), new Float3(0.2877979582f, -0.02606483451f, -0.3449535616f), new Float3(-0.07732986802f, 0.2377094325f, 0.3741848704f), new Float3(0.1107205875f, -0.3552302079f, -0.2530858567f), new Float3(0.2755209141f, 0.2640521179f, -0.238463215f), new Float3(0.294168941f, 0.1526064594f, 0.3044271714f), new Float3(0.4000921098f, -0.2034056362f, 0.03244149937f), new Float3(-0.1697304074f, 0.3970864695f, -0.1265461359f), new Float3(-0.1483224484f, -0.3859694688f, 0.1775613147f), new Float3(0.2623596946f, -0.2354852944f, 0.2796677792f), new Float3(-0.2709003183f, 0.3505271138f, -0.07901746678f), new Float3(-0.03516550699f, 0.3885234328f, 0.2243054374f), new Float3(-0.1267712655f, 0.1920044036f, 0.3867342179f), new Float3(0.02952021915f, 0.4409685861f, 0.08470692262f), new Float3(-0.2806854217f, -0.266996757f, 0.2289725438f), new Float3(-0.171159547f, 0.2141185563f, 0.3568720405f), new Float3(0.2113227183f, 0.3902405947f, -0.07453178509f), new Float3(-0.1024352839f, 0.2128044156f, -0.3830421561f), new Float3(-0.3304249877f, -0.1566986703f, 0.2622305365f), new Float3(0.2091111325f, 0.3133278055f, -0.2461670583f), new Float3(0.344678154f, -0.1944240454f, -0.2142341261f), new Float3(0.1984478035f, -0.3214342325f, -0.2445373252f), new Float3(-0.2929008603f, 0.2262915116f, 0.2559320961f), new Float3(-0.1617332831f, 0.006314769776f, -0.4198838754f), new Float3(-0.3582060271f, -0.148303178f, -0.2284613961f), new Float3(-0.1852067326f, -0.3454119342f, -0.2211087107f), new Float3(0.3046301062f, 0.1026310383f, 0.314908508f), new Float3(-0.03816768434f, -0.2551766358f, -0.3686842991f), new Float3(-0.4084952196f, 0.1805950793f, 0.05492788837f), new Float3(-0.02687443361f, -0.2749741471f, 0.3551999201f), new Float3(-0.03801098351f, 0.3277859044f, 0.3059600725f), new Float3(0.2371120802f, 0.2900386767f, -0.2493099024f), new Float3(0.4447660503f, 0.03946930643f, 0.05590469027f), new Float3(0.01985147278f, -0.01503183293f, -0.4493105419f), new Float3(0.4274339143f, 0.03345994256f, -0.1366772882f), new Float3(-0.2072988631f, 0.2871414597f, -0.2776273824f), new Float3(-0.3791240978f, 0.1281177671f, 0.2057929936f), new Float3(-0.2098721267f, -0.1007087278f, -0.3851122467f), new Float3(0.01582798878f, 0.4263894424f, 0.1429738373f), new Float3(-0.1888129464f, -0.3160996813f, -0.2587096108f), new Float3(0.1612988974f, -0.1974805082f, -0.3707885038f), new Float3(-0.08974491322f, 0.229148752f, -0.3767448739f), new Float3(0.07041229526f, 0.4150230285f, -0.1590534329f), new Float3(-0.1082925611f, -0.1586061639f, 0.4069604477f), new Float3(0.2474100658f, -0.3309414609f, 0.1782302128f), new Float3(-0.1068836661f, -0.2701644537f, -0.3436379634f), new Float3(0.2396452163f, 0.06803600538f, -0.3747549496f), new Float3(-0.3063886072f, 0.2597428179f, 0.2028785103f), new Float3(0.1593342891f, -0.3114350249f, -0.2830561951f), new Float3(0.2709690528f, 0.1412648683f, -0.3303331794f), new Float3(-0.1519780427f, 0.3623355133f, 0.2193527988f), new Float3(0.1699773681f, 0.3456012883f, 0.2327390037f), new Float3(-0.1986155616f, 0.3836276443f, -0.1260225743f), new Float3(-0.1887482106f, -0.2050154888f, -0.353330953f), new Float3(0.2659103394f, 0.3015631259f, -0.2021172246f), new Float3(-0.08838976154f, -0.4288819642f, -0.1036702021f), new Float3(-0.04201869311f, 0.3099592485f, 0.3235115047f), new Float3(-0.3230334656f, 0.201549922f, -0.2398478873f), new Float3(0.2612720941f, 0.2759854499f, -0.2409749453f), new Float3(0.385713046f, 0.2193460345f, 0.07491837764f), new Float3(0.07654967953f, 0.3721732183f, 0.241095919f), new Float3(0.4317038818f, -0.02577753072f, 0.1243675091f), new Float3(-0.2890436293f, -0.3418179959f, -0.04598084447f), new Float3(-0.2201947582f, 0.383023377f, -0.08548310451f), new Float3(0.4161322773f, -0.1669634289f, -0.03817251927f), new Float3(0.2204718095f, 0.02654238946f, -0.391391981f), new Float3(-0.1040307469f, 0.3890079625f, -0.2008741118f), new Float3(-0.1432122615f, 0.371614387f, -0.2095065525f), new Float3(0.3978380468f, -0.06206669342f, 0.2009293758f), new Float3(-0.2599274663f, 0.2616724959f, -0.2578084893f), new Float3(0.4032618332f, -0.1124593585f, 0.1650235939f), new Float3(-0.08953470255f, -0.3048244735f, 0.3186935478f), new Float3(0.118937202f, -0.2875221847f, 0.325092195f), new Float3(0.02167047076f, -0.03284630549f, -0.4482761547f), new Float3(-0.3411343612f, 0.2500031105f, 0.1537068389f), new Float3(0.3162964612f, 0.3082064153f, -0.08640228117f), new Float3(0.2355138889f, -0.3439334267f, -0.1695376245f), new Float3(-0.02874541518f, -0.3955933019f, 0.2125550295f), new Float3(-0.2461455173f, 0.02020282325f, -0.3761704803f), new Float3(0.04208029445f, -0.4470439576f, 0.02968078139f), new Float3(0.2727458746f, 0.2288471896f, -0.2752065618f), new Float3(-0.1347522818f, -0.02720848277f, -0.4284874806f), new Float3(0.3829624424f, 0.1231931484f, -0.2016512234f), new Float3(-0.Line truncated private static final Float3[] CELL_3D = {new Float3(0.1453787434f, -0.4149781685f, -0.0956981749f), new Float3(-0.01242829687f, -0.1457918398f, -0.4255470325f), new Float3(0.2877979582f, -0.02606483451f, -0.3449535616f), new Float3(-0.07732986802f, 0.2377094325f, 0.3741848704f), new Float3(0.1107205875f, -0.3552302079f, -0.2530858567f), new Float3(0.2755209141f, 0.2640521179f, -0.238463215f), new Float3(0.294168941f, 0.1526064594f, 0.3044271714f), new Float3(0.4000921098f, -0.2034056362f, 0.03244149937f), new Float3(-0.1697304074f, 0.3970864695f, -0.1265461359f), new Float3(-0.1483224484f, -0.3859694688f, 0.1775613147f), new Float3(0.2623596946f, -0.2354852944f, 0.2796677792f), new Float3(-0.2709003183f, 0.3505271138f, -0.07901746678f), new Float3(-0.03516550699f, 0.3885234328f, 0.2243054374f), new Float3(-0.1267712655f, 0.1920044036f, 0.3867342179f), new Float3(0.02952021915f, 0.4409685861f, 0.08470692262f), new Float3(-0.2806854217f, -0.266996757f, 0.2289725438f), new Float3(-0.171159547f, 0.2141185563f, 0.3568720405f), new Float3(0.2113227183f, 0.3902405947f, -0.07453178509f), new Float3(-0.1024352839f, 0.2128044156f, -0.3830421561f), new Float3(-0.3304249877f, -0.1566986703f, 0.2622305365f), new Float3(0.2091111325f, 0.3133278055f, -0.2461670583f), new Float3(0.344678154f, -0.1944240454f, -0.2142341261f), new Float3(0.1984478035f, -0.3214342325f, -0.2445373252f), new Float3(-0.2929008603f, 0.2262915116f, 0.2559320961f), new Float3(-0.1617332831f, 0.006314769776f, -0.4198838754f), new Float3(-0.3582060271f, -0.148303178f, -0.2284613961f), new Float3(-0.1852067326f, -0.3454119342f, -0.2211087107f), new Float3(0.3046301062f, 0.1026310383f, 0.314908508f), new Float3(-0.03816768434f, -0.2551766358f, -0.3686842991f), new Float3(-0.4084952196f, 0.1805950793f, 0.05492788837f), new Float3(-0.02687443361f, -0.2749741471f, 0.3551999201f), new Float3(-0.03801098351f, 0.3277859044f, 0.3059600725f), new Float3(0.2371120802f, 0.2900386767f, -0.2493099024f), new Float3(0.4447660503f, 0.03946930643f, 0.05590469027f), new Float3(0.01985147278f, -0.01503183293f, -0.4493105419f), new Float3(0.4274339143f, 0.03345994256f, -0.1366772882f), new Float3(-0.2072988631f, 0.2871414597f, -0.2776273824f), new Float3(-0.3791240978f, 0.1281177671f, 0.2057929936f), new Float3(-0.2098721267f, -0.1007087278f, -0.3851122467f), new Float3(0.01582798878f, 0.4263894424f, 0.1429738373f), new Float3(-0.1888129464f, -0.3160996813f, -0.2587096108f), new Float3(0.1612988974f, -0.1974805082f, -0.3707885038f), new Float3(-0.08974491322f, 0.229148752f, -0.3767448739f), new Float3(0.07041229526f, 0.4150230285f, -0.1590534329f), new Float3(-0.1082925611f, -0.1586061639f, 0.4069604477f), new Float3(0.2474100658f, -0.3309414609f, 0.1782302128f), new Float3(-0.1068836661f, -0.2701644537f, -0.3436379634f), new Float3(0.2396452163f, 0.06803600538f, -0.3747549496f), new Float3(-0.3063886072f, 0.2597428179f, 0.2028785103f), new Float3(0.1593342891f, -0.3114350249f, -0.2830561951f), new Float3(0.2709690528f, 0.1412648683f, -0.3303331794f), new Float3(-0.1519780427f, 0.3623355133f, 0.2193527988f), new Float3(0.1699773681f, 0.3456012883f, 0.2327390037f), new Float3(-0.1986155616f, 0.3836276443f, -0.1260225743f), new Float3(-0.1887482106f, -0.2050154888f, -0.353330953f), new Float3(0.2659103394f, 0.3015631259f, -0.2021172246f), new Float3(-0.08838976154f, -0.4288819642f, -0.1036702021f), new Float3(-0.04201869311f, 0.3099592485f, 0.3235115047f), new Float3(-0.3230334656f, 0.201549922f, -0.2398478873f), new Float3(0.2612720941f, 0.2759854499f, -0.2409749453f), new Float3(0.385713046f, 0.2193460345f, 0.07491837764f), new Float3(0.07654967953f, 0.3721732183f, 0.241095919f), new Float3(0.4317038818f, -0.02577753072f, 0.1243675091f), new Float3(-0.2890436293f, -0.3418179959f, -0.04598084447f), new Float3(-0.2201947582f, 0.383023377f, -0.08548310451f), new Float3(0.4161322773f, -0.1669634289f, -0.03817251927f), new Float3(0.2204718095f, 0.02654238946f, -0.391391981f), new Float3(-0.1040307469f, 0.3890079625f, -0.2008741118f), new Float3(-0.1432122615f, 0.371614387f, -0.2095065525f), new Float3(0.3978380468f, -0.06206669342f, 0.2009293758f), new Float3(-0.2599274663f, 0.2616724959f, -0.2578084893f), new Float3(0.4032618332f, -0.1124593585f, 0.1650235939f), new Float3(-0.08953470255f, -0.3048244735f, 0.3186935478f), new Float3(0.118937202f, -0.2875221847f, 0.325092195f), new Float3(0.02167047076f, -0.03284630549f, -0.4482761547f), new Float3(-0.3411343612f, 0.2500031105f, 0.1537068389f), new Float3(0.3162964612f, 0.3082064153f, -0.08640228117f), new Float3(0.2355138889f, -0.3439334267f, -0.1695376245f), new Float3(-0.02874541518f, -0.3955933019f, 0.2125550295f), new Float3(-0.2461455173f, 0.02020282325f, -0.3761704803f), new Float3(0.04208029445f, -0.4470439576f, 0.02968078139f), new Float3(0.2727458746f, 0.2288471896f, -0.2752065618f), new Float3(-0.1347522818f, -0.02720848277f, -0.4284874806f), new Float3(0.3829624424f, 0.1231931484f, -0.2016512234f), new Float3(-0.Line truncated
}; };
private static int FastFloor(float f) private static int fastFloor(float f)
{ {
return (f >= 0 ? (int) f : (int) f - 1); return (f >= 0 ? (int) f : (int) f - 1);
} }
private static int FastRound(float f) private static int fastRound(float f)
{ {
return (f >= 0) ? (int) (f + (float) 0.5) : (int) (f - (float) 0.5); return (f >= 0) ? (int) (f + (float) 0.5) : (int) (f - (float) 0.5);
} }
private static float Lerp(float a, float b, float t) private static float lerp(float a, float b, float t)
{ {
return a + t * (b - a); return a + t * (b - a);
} }
private static float InterpHermiteFunc(float t) private static float interpHermiteFunc(float t)
{ {
return t * t * (3 - 2 * t); return t * t * (3 - 2 * t);
} }
private static float InterpQuinticFunc(float t) private static float interpQuinticFunc(float t)
{ {
return t * t * t * (t * (t * 6 - 15) + 10); return t * t * t * (t * (t * 6 - 15) + 10);
} }
private static float CubicLerp(float a, float b, float c, float d, float t) private static float cubicLerp(float a, float b, float c, float d, float t)
{ {
float p = (d - c) - (a - b); float p = (d - c) - (a - b);
return t * t * t * p + t * t * ((a - b) - p) + t * (c - a) + b; return t * t * t * p + t * t * ((a - b) - p) + t * (c - a) + b;
} }
private void CalculateFractalBounding() private void calculateFractalBounding()
{ {
float amp = m_gain; float amp = m_gain;
float ampFractal = 1; float ampFractal = 1;
@@ -303,7 +303,7 @@ public class FastNoise
private final static long Y_PRIME_L = 31337; private final static long Y_PRIME_L = 31337;
private final static long Z_PRIME_L = 6971; private final static long Z_PRIME_L = 6971;
private static int Hash2D(int seed, int x, int y) private static int hash2D(int seed, int x, int y)
{ {
int hash = seed; int hash = seed;
hash ^= X_PRIME * x; hash ^= X_PRIME * x;
@@ -315,7 +315,7 @@ public class FastNoise
return hash; return hash;
} }
private static int Hash3D(int seed, int x, int y, int z) private static int hash3D(int seed, int x, int y, int z)
{ {
int hash = seed; int hash = seed;
hash ^= X_PRIME * x; hash ^= X_PRIME * x;
@@ -328,7 +328,7 @@ public class FastNoise
return hash; return hash;
} }
public static int Hash4D(int seed, int x, int y, int z, int w) public static int hash4D(int seed, int x, int y, int z, int w)
{ {
int hash = seed; int hash = seed;
hash ^= X_PRIME * x; hash ^= X_PRIME * x;
@@ -342,7 +342,7 @@ public class FastNoise
return hash; return hash;
} }
private static float ValCoord2D(int seed, int x, int y) private static float valCoord2D(int seed, int x, int y)
{ {
int n = seed; int n = seed;
n ^= X_PRIME * x; n ^= X_PRIME * x;
@@ -351,7 +351,7 @@ public class FastNoise
return (n * n * n * 60493) / (float) 2147483648.0; return (n * n * n * 60493) / (float) 2147483648.0;
} }
private static double DValCoord2D(int seed, long x, long y) private static double dValCoord2D(int seed, long x, long y)
{ {
long n = seed; long n = seed;
n ^= X_PRIME_L * x; n ^= X_PRIME_L * x;
@@ -360,7 +360,7 @@ public class FastNoise
return ((n * n * n * 60493L) / (double) Long.MAX_VALUE); return ((n * n * n * 60493L) / (double) Long.MAX_VALUE);
} }
private static double DValCoord3D(int seed, long x, long y, long z) private static double dValCoord3D(int seed, long x, long y, long z)
{ {
long n = seed; long n = seed;
n ^= X_PRIME_L * x; n ^= X_PRIME_L * x;
@@ -370,7 +370,7 @@ public class FastNoise
return ((n * n * n * 60493L) / (double) Long.MAX_VALUE); return ((n * n * n * 60493L) / (double) Long.MAX_VALUE);
} }
private static float ValCoord3D(int seed, int x, int y, int z) private static float valCoord3D(int seed, int x, int y, int z)
{ {
int n = seed; int n = seed;
n ^= X_PRIME * x; n ^= X_PRIME * x;
@@ -380,7 +380,7 @@ public class FastNoise
return (n * n * n * 60493) / (float) 2147483648.0; return (n * n * n * 60493) / (float) 2147483648.0;
} }
private static float ValCoord4D(int seed, int x, int y, int z, int w) private static float valCoord4D(int seed, int x, int y, int z, int w)
{ {
int n = seed; int n = seed;
n ^= X_PRIME * x; n ^= X_PRIME * x;
@@ -638,7 +638,7 @@ public class FastNoise
int zi = FloatCast2Int(z); int zi = FloatCast2Int(z);
int wi = FloatCast2Int(w); int wi = FloatCast2Int(w);
return ValCoord4D(m_seed, xi, yi, zi, wi); return valCoord4D(m_seed, xi, yi, zi, wi);
} }
public float GetWhiteNoise(float x, float y, float z) public float GetWhiteNoise(float x, float y, float z)
@@ -647,7 +647,7 @@ public class FastNoise
int yi = FloatCast2Int(y); int yi = FloatCast2Int(y);
int zi = FloatCast2Int(z); int zi = FloatCast2Int(z);
return ValCoord3D(m_seed, xi, yi, zi); return valCoord3D(m_seed, xi, yi, zi);
} }
public float GetWhiteNoise(float x, float y) public float GetWhiteNoise(float x, float y)
@@ -655,7 +655,7 @@ public class FastNoise
int xi = FloatCast2Int(x); int xi = FloatCast2Int(x);
int yi = FloatCast2Int(y); int yi = FloatCast2Int(y);
return ValCoord2D(m_seed, xi, yi); return valCoord2D(m_seed, xi, yi);
} }
public double DGetWhiteNoise(double x, double y, double z) public double DGetWhiteNoise(double x, double y, double z)
@@ -664,7 +664,7 @@ public class FastNoise
long yi = DoubleCast2Long(y); long yi = DoubleCast2Long(y);
long zi = DoubleCast2Long(z); long zi = DoubleCast2Long(z);
return DValCoord3D(m_seed, xi, yi, zi); return dValCoord3D(m_seed, xi, yi, zi);
} }
public double DGetWhiteNoise(double x, double y) public double DGetWhiteNoise(double x, double y)
@@ -672,22 +672,22 @@ public class FastNoise
long xi = DoubleCast2Long(x); long xi = DoubleCast2Long(x);
long yi = DoubleCast2Long(y); long yi = DoubleCast2Long(y);
return DValCoord2D(m_seed, xi, yi); return dValCoord2D(m_seed, xi, yi);
} }
public float GetWhiteNoiseInt(int x, int y, int z, int w) public float GetWhiteNoiseInt(int x, int y, int z, int w)
{ {
return ValCoord4D(m_seed, x, y, z, w); return valCoord4D(m_seed, x, y, z, w);
} }
public float GetWhiteNoiseInt(int x, int y, int z) public float GetWhiteNoiseInt(int x, int y, int z)
{ {
return ValCoord3D(m_seed, x, y, z); return valCoord3D(m_seed, x, y, z);
} }
public float GetWhiteNoiseInt(int x, int y) public float GetWhiteNoiseInt(int x, int y)
{ {
return ValCoord2D(m_seed, x, y); return valCoord2D(m_seed, x, y);
} }
// Value Noise // Value Noise
@@ -774,9 +774,9 @@ public class FastNoise
private float SingleValue(int seed, float x, float y, float z) private float SingleValue(int seed, float x, float y, float z)
{ {
int x0 = FastFloor(x); int x0 = fastFloor(x);
int y0 = FastFloor(y); int y0 = fastFloor(y);
int z0 = FastFloor(z); int z0 = fastFloor(z);
int x1 = x0 + 1; int x1 = x0 + 1;
int y1 = y0 + 1; int y1 = y0 + 1;
int z1 = z0 + 1; int z1 = z0 + 1;
@@ -791,26 +791,26 @@ public class FastNoise
zs = z - z0; zs = z - z0;
break; break;
case Hermite: case Hermite:
xs = InterpHermiteFunc(x - x0); xs = interpHermiteFunc(x - x0);
ys = InterpHermiteFunc(y - y0); ys = interpHermiteFunc(y - y0);
zs = InterpHermiteFunc(z - z0); zs = interpHermiteFunc(z - z0);
break; break;
case Quintic: case Quintic:
xs = InterpQuinticFunc(x - x0); xs = interpQuinticFunc(x - x0);
ys = InterpQuinticFunc(y - y0); ys = interpQuinticFunc(y - y0);
zs = InterpQuinticFunc(z - z0); zs = interpQuinticFunc(z - z0);
break; break;
} }
float xf00 = Lerp(ValCoord3D(seed, x0, y0, z0), ValCoord3D(seed, x1, y0, z0), xs); float xf00 = lerp(valCoord3D(seed, x0, y0, z0), valCoord3D(seed, x1, y0, z0), xs);
float xf10 = Lerp(ValCoord3D(seed, x0, y1, z0), ValCoord3D(seed, x1, y1, z0), xs); float xf10 = lerp(valCoord3D(seed, x0, y1, z0), valCoord3D(seed, x1, y1, z0), xs);
float xf01 = Lerp(ValCoord3D(seed, x0, y0, z1), ValCoord3D(seed, x1, y0, z1), xs); float xf01 = lerp(valCoord3D(seed, x0, y0, z1), valCoord3D(seed, x1, y0, z1), xs);
float xf11 = Lerp(ValCoord3D(seed, x0, y1, z1), ValCoord3D(seed, x1, y1, z1), xs); float xf11 = lerp(valCoord3D(seed, x0, y1, z1), valCoord3D(seed, x1, y1, z1), xs);
float yf0 = Lerp(xf00, xf10, ys); float yf0 = lerp(xf00, xf10, ys);
float yf1 = Lerp(xf01, xf11, ys); float yf1 = lerp(xf01, xf11, ys);
return Lerp(yf0, yf1, zs); return lerp(yf0, yf1, zs);
} }
public float GetValueFractal(float x, float y) public float GetValueFractal(float x, float y)
@@ -891,8 +891,8 @@ public class FastNoise
private float SingleValue(int seed, float x, float y) private float SingleValue(int seed, float x, float y)
{ {
int x0 = FastFloor(x); int x0 = fastFloor(x);
int y0 = FastFloor(y); int y0 = fastFloor(y);
int x1 = x0 + 1; int x1 = x0 + 1;
int y1 = y0 + 1; int y1 = y0 + 1;
@@ -905,19 +905,19 @@ public class FastNoise
ys = y - y0; ys = y - y0;
break; break;
case Hermite: case Hermite:
xs = InterpHermiteFunc(x - x0); xs = interpHermiteFunc(x - x0);
ys = InterpHermiteFunc(y - y0); ys = interpHermiteFunc(y - y0);
break; break;
case Quintic: case Quintic:
xs = InterpQuinticFunc(x - x0); xs = interpQuinticFunc(x - x0);
ys = InterpQuinticFunc(y - y0); ys = interpQuinticFunc(y - y0);
break; break;
} }
float xf0 = Lerp(ValCoord2D(seed, x0, y0), ValCoord2D(seed, x1, y0), xs); float xf0 = lerp(valCoord2D(seed, x0, y0), valCoord2D(seed, x1, y0), xs);
float xf1 = Lerp(ValCoord2D(seed, x0, y1), ValCoord2D(seed, x1, y1), xs); float xf1 = lerp(valCoord2D(seed, x0, y1), valCoord2D(seed, x1, y1), xs);
return Lerp(xf0, xf1, ys); return lerp(xf0, xf1, ys);
} }
// Gradient Noise // Gradient Noise
@@ -1004,9 +1004,9 @@ public class FastNoise
private float SinglePerlin(int seed, float x, float y, float z) private float SinglePerlin(int seed, float x, float y, float z)
{ {
int x0 = FastFloor(x); int x0 = fastFloor(x);
int y0 = FastFloor(y); int y0 = fastFloor(y);
int z0 = FastFloor(z); int z0 = fastFloor(z);
int x1 = x0 + 1; int x1 = x0 + 1;
int y1 = y0 + 1; int y1 = y0 + 1;
int z1 = z0 + 1; int z1 = z0 + 1;
@@ -1021,14 +1021,14 @@ public class FastNoise
zs = z - z0; zs = z - z0;
break; break;
case Hermite: case Hermite:
xs = InterpHermiteFunc(x - x0); xs = interpHermiteFunc(x - x0);
ys = InterpHermiteFunc(y - y0); ys = interpHermiteFunc(y - y0);
zs = InterpHermiteFunc(z - z0); zs = interpHermiteFunc(z - z0);
break; break;
case Quintic: case Quintic:
xs = InterpQuinticFunc(x - x0); xs = interpQuinticFunc(x - x0);
ys = InterpQuinticFunc(y - y0); ys = interpQuinticFunc(y - y0);
zs = InterpQuinticFunc(z - z0); zs = interpQuinticFunc(z - z0);
break; break;
} }
@@ -1039,15 +1039,15 @@ public class FastNoise
float yd1 = yd0 - 1; float yd1 = yd0 - 1;
float zd1 = zd0 - 1; float zd1 = zd0 - 1;
float xf00 = Lerp(GradCoord3D(seed, x0, y0, z0, xd0, yd0, zd0), GradCoord3D(seed, x1, y0, z0, xd1, yd0, zd0), xs); float xf00 = lerp(GradCoord3D(seed, x0, y0, z0, xd0, yd0, zd0), GradCoord3D(seed, x1, y0, z0, xd1, yd0, zd0), xs);
float xf10 = Lerp(GradCoord3D(seed, x0, y1, z0, xd0, yd1, zd0), GradCoord3D(seed, x1, y1, z0, xd1, yd1, zd0), xs); float xf10 = lerp(GradCoord3D(seed, x0, y1, z0, xd0, yd1, zd0), GradCoord3D(seed, x1, y1, z0, xd1, yd1, zd0), xs);
float xf01 = Lerp(GradCoord3D(seed, x0, y0, z1, xd0, yd0, zd1), GradCoord3D(seed, x1, y0, z1, xd1, yd0, zd1), xs); float xf01 = lerp(GradCoord3D(seed, x0, y0, z1, xd0, yd0, zd1), GradCoord3D(seed, x1, y0, z1, xd1, yd0, zd1), xs);
float xf11 = Lerp(GradCoord3D(seed, x0, y1, z1, xd0, yd1, zd1), GradCoord3D(seed, x1, y1, z1, xd1, yd1, zd1), xs); float xf11 = lerp(GradCoord3D(seed, x0, y1, z1, xd0, yd1, zd1), GradCoord3D(seed, x1, y1, z1, xd1, yd1, zd1), xs);
float yf0 = Lerp(xf00, xf10, ys); float yf0 = lerp(xf00, xf10, ys);
float yf1 = Lerp(xf01, xf11, ys); float yf1 = lerp(xf01, xf11, ys);
return Lerp(yf0, yf1, zs); return lerp(yf0, yf1, zs);
} }
public float GetPerlinFractal(float x, float y) public float GetPerlinFractal(float x, float y)
@@ -1129,8 +1129,8 @@ public class FastNoise
private float SinglePerlin(int seed, float x, float y) private float SinglePerlin(int seed, float x, float y)
{ {
int x0 = FastFloor(x); int x0 = fastFloor(x);
int y0 = FastFloor(y); int y0 = fastFloor(y);
int x1 = x0 + 1; int x1 = x0 + 1;
int y1 = y0 + 1; int y1 = y0 + 1;
@@ -1143,12 +1143,12 @@ public class FastNoise
ys = y - y0; ys = y - y0;
break; break;
case Hermite: case Hermite:
xs = InterpHermiteFunc(x - x0); xs = interpHermiteFunc(x - x0);
ys = InterpHermiteFunc(y - y0); ys = interpHermiteFunc(y - y0);
break; break;
case Quintic: case Quintic:
xs = InterpQuinticFunc(x - x0); xs = interpQuinticFunc(x - x0);
ys = InterpQuinticFunc(y - y0); ys = interpQuinticFunc(y - y0);
break; break;
} }
@@ -1157,10 +1157,10 @@ public class FastNoise
float xd1 = xd0 - 1; float xd1 = xd0 - 1;
float yd1 = yd0 - 1; float yd1 = yd0 - 1;
float xf0 = Lerp(GradCoord2D(seed, x0, y0, xd0, yd0), GradCoord2D(seed, x1, y0, xd1, yd0), xs); float xf0 = lerp(GradCoord2D(seed, x0, y0, xd0, yd0), GradCoord2D(seed, x1, y0, xd1, yd0), xs);
float xf1 = Lerp(GradCoord2D(seed, x0, y1, xd0, yd1), GradCoord2D(seed, x1, y1, xd1, yd1), xs); float xf1 = lerp(GradCoord2D(seed, x0, y1, xd0, yd1), GradCoord2D(seed, x1, y1, xd1, yd1), xs);
return Lerp(xf0, xf1, ys); return lerp(xf0, xf1, ys);
} }
// Simplex Noise // Simplex Noise
@@ -1252,9 +1252,9 @@ public class FastNoise
private float SingleSimplex(int seed, float x, float y, float z) private float SingleSimplex(int seed, float x, float y, float z)
{ {
float t = (x + y + z) * F3; float t = (x + y + z) * F3;
int i = FastFloor(x + t); int i = fastFloor(x + t);
int j = FastFloor(y + t); int j = fastFloor(y + t);
int k = FastFloor(z + t); int k = fastFloor(z + t);
t = (i + j + k) * G3; t = (i + j + k) * G3;
float x0 = x - (i - t); float x0 = x - (i - t);
@@ -1459,8 +1459,8 @@ public class FastNoise
private float SingleSimplex(int seed, float x, float y) private float SingleSimplex(int seed, float x, float y)
{ {
float t = (x + y) * F2; float t = (x + y) * F2;
int i = FastFloor(x + t); int i = fastFloor(x + t);
int j = FastFloor(y + t); int j = fastFloor(y + t);
t = (i + j) * G2; t = (i + j) * G2;
float X0 = i - t; float X0 = i - t;
@@ -1533,10 +1533,10 @@ public class FastNoise
{ {
float n0, n1, n2, n3, n4; float n0, n1, n2, n3, n4;
float t = (x + y + z + w) * F4; float t = (x + y + z + w) * F4;
int i = FastFloor(x + t); int i = fastFloor(x + t);
int j = FastFloor(y + t); int j = fastFloor(y + t);
int k = FastFloor(z + t); int k = fastFloor(z + t);
int l = FastFloor(w + t); int l = fastFloor(w + t);
t = (i + j + k + l) * G4; t = (i + j + k + l) * G4;
float X0 = i - t; float X0 = i - t;
float Y0 = j - t; float Y0 = j - t;
@@ -1718,9 +1718,9 @@ public class FastNoise
private float SingleCubic(int seed, float x, float y, float z) private float SingleCubic(int seed, float x, float y, float z)
{ {
int x1 = FastFloor(x); int x1 = fastFloor(x);
int y1 = FastFloor(y); int y1 = fastFloor(y);
int z1 = FastFloor(z); int z1 = fastFloor(z);
int x0 = x1 - 1; int x0 = x1 - 1;
int y0 = y1 - 1; int y0 = y1 - 1;
@@ -1736,7 +1736,7 @@ public class FastNoise
float ys = y - (float) y1; float ys = y - (float) y1;
float zs = z - (float) z1; float zs = z - (float) z1;
return CubicLerp(CubicLerp(CubicLerp(ValCoord3D(seed, x0, y0, z0), ValCoord3D(seed, x1, y0, z0), ValCoord3D(seed, x2, y0, z0), ValCoord3D(seed, x3, y0, z0), xs), CubicLerp(ValCoord3D(seed, x0, y1, z0), ValCoord3D(seed, x1, y1, z0), ValCoord3D(seed, x2, y1, z0), ValCoord3D(seed, x3, y1, z0), xs), CubicLerp(ValCoord3D(seed, x0, y2, z0), ValCoord3D(seed, x1, y2, z0), ValCoord3D(seed, x2, y2, z0), ValCoord3D(seed, x3, y2, z0), xs), CubicLerp(ValCoord3D(seed, x0, y3, z0), ValCoord3D(seed, x1, y3, z0), ValCoord3D(seed, x2, y3, z0), ValCoord3D(seed, x3, y3, z0), xs), ys), CubicLerp(CubicLerp(ValCoord3D(seed, x0, y0, z1), ValCoord3D(seed, x1, y0, z1), ValCoord3D(seed, x2, y0, z1), ValCoord3D(seed, x3, y0, z1), xs), CubicLerp(ValCoord3D(seed, x0, y1, z1), ValCoord3D(seed, x1, y1, z1), ValCoord3D(seed, x2, y1, z1), ValCoord3D(seed, x3, y1, z1), xs), CubicLerp(ValCoord3D(seed, x0, y2, z1), ValCoord3D(seed, x1, y2, z1), ValCoord3D(seed, x2, y2, z1), ValCoord3D(seed, x3, y2, z1), xs), CubicLerp(ValCoord3D(seed, x0, y3, z1), ValCoord3D(seed, x1, y3, z1), ValCoord3D(seed, x2, y3, z1), ValCoord3D(seed, x3, y3, z1), xs), ys), CubicLerp(CubicLerp(ValCoord3D(seed, x0, y0, z2), ValCoord3D(seed, x1, y0, z2), ValCoord3D(seed, x2, y0, z2), ValCoord3D(seed, x3, y0, z2), xs), CubicLerp(ValCoord3D(seed, x0, y1, z2), ValCoord3D(seed, x1, y1, z2), ValCoord3D(seed, x2, y1, z2), ValCoord3D(seed, x3, y1, z2), xs), CubicLerp(ValCoord3D(seed, x0, y2, z2), ValCoord3D(seed, x1, y2, z2), ValCoord3D(seed, x2, y2, z2), ValCoord3D(seed, x3, y2, z2), xs), CubicLerp(ValCoord3D(seed, x0, y3, z2), ValCoord3D(seed, x1, y3, z2), ValCoord3D(seed, x2, y3, z2), ValCoord3D(seed, x3, y3, z2), xs), ys), CubicLerp(CubicLerp(ValCoord3D(seed, x0, y0, z3), ValCoord3D(seed, x1, y0, z3), ValCoord3D(seed, x2, y0, z3), ValCoord3D(seed, x3, y0, z3), xs), CubicLerp(ValCoord3D(seed, x0, y1, z3), ValCoord3D(seed, x1, y1, z3), ValCoord3D(seed, x2, y1, z3), ValCoord3D(seed, x3, y1, z3), xs), CubicLerp(ValCoord3D(seed, x0, y2, z3), ValCoord3D(seed, x1, y2, z3), ValCoord3D(seed, x2, y2, z3), ValCoord3D(seed, x3, y2, z3), xs), CubicLerp(ValCoord3D(seed, x0, y3, z3), ValCoord3D(seed, x1, y3, z3), ValCoord3D(seed, x2, y3, z3), ValCoord3D(seed, x3, y3, z3), xs), ys), zs) * CUBIC_3D_BOUNDING; return cubicLerp(cubicLerp(cubicLerp(valCoord3D(seed, x0, y0, z0), valCoord3D(seed, x1, y0, z0), valCoord3D(seed, x2, y0, z0), valCoord3D(seed, x3, y0, z0), xs), cubicLerp(valCoord3D(seed, x0, y1, z0), valCoord3D(seed, x1, y1, z0), valCoord3D(seed, x2, y1, z0), valCoord3D(seed, x3, y1, z0), xs), cubicLerp(valCoord3D(seed, x0, y2, z0), valCoord3D(seed, x1, y2, z0), valCoord3D(seed, x2, y2, z0), valCoord3D(seed, x3, y2, z0), xs), cubicLerp(valCoord3D(seed, x0, y3, z0), valCoord3D(seed, x1, y3, z0), valCoord3D(seed, x2, y3, z0), valCoord3D(seed, x3, y3, z0), xs), ys), cubicLerp(cubicLerp(valCoord3D(seed, x0, y0, z1), valCoord3D(seed, x1, y0, z1), valCoord3D(seed, x2, y0, z1), valCoord3D(seed, x3, y0, z1), xs), cubicLerp(valCoord3D(seed, x0, y1, z1), valCoord3D(seed, x1, y1, z1), valCoord3D(seed, x2, y1, z1), valCoord3D(seed, x3, y1, z1), xs), cubicLerp(valCoord3D(seed, x0, y2, z1), valCoord3D(seed, x1, y2, z1), valCoord3D(seed, x2, y2, z1), valCoord3D(seed, x3, y2, z1), xs), cubicLerp(valCoord3D(seed, x0, y3, z1), valCoord3D(seed, x1, y3, z1), valCoord3D(seed, x2, y3, z1), valCoord3D(seed, x3, y3, z1), xs), ys), cubicLerp(cubicLerp(valCoord3D(seed, x0, y0, z2), valCoord3D(seed, x1, y0, z2), valCoord3D(seed, x2, y0, z2), valCoord3D(seed, x3, y0, z2), xs), cubicLerp(valCoord3D(seed, x0, y1, z2), valCoord3D(seed, x1, y1, z2), valCoord3D(seed, x2, y1, z2), valCoord3D(seed, x3, y1, z2), xs), cubicLerp(valCoord3D(seed, x0, y2, z2), valCoord3D(seed, x1, y2, z2), valCoord3D(seed, x2, y2, z2), valCoord3D(seed, x3, y2, z2), xs), cubicLerp(valCoord3D(seed, x0, y3, z2), valCoord3D(seed, x1, y3, z2), valCoord3D(seed, x2, y3, z2), valCoord3D(seed, x3, y3, z2), xs), ys), cubicLerp(cubicLerp(valCoord3D(seed, x0, y0, z3), valCoord3D(seed, x1, y0, z3), valCoord3D(seed, x2, y0, z3), valCoord3D(seed, x3, y0, z3), xs), cubicLerp(valCoord3D(seed, x0, y1, z3), valCoord3D(seed, x1, y1, z3), valCoord3D(seed, x2, y1, z3), valCoord3D(seed, x3, y1, z3), xs), cubicLerp(valCoord3D(seed, x0, y2, z3), valCoord3D(seed, x1, y2, z3), valCoord3D(seed, x2, y2, z3), valCoord3D(seed, x3, y2, z3), xs), cubicLerp(valCoord3D(seed, x0, y3, z3), valCoord3D(seed, x1, y3, z3), valCoord3D(seed, x2, y3, z3), valCoord3D(seed, x3, y3, z3), xs), ys), zs) * CUBIC_3D_BOUNDING;
} }
public float GetCubicFractal(float x, float y) public float GetCubicFractal(float x, float y)
@@ -1826,8 +1826,8 @@ public class FastNoise
private float SingleCubic(int seed, float x, float y) private float SingleCubic(int seed, float x, float y)
{ {
int x1 = FastFloor(x); int x1 = fastFloor(x);
int y1 = FastFloor(y); int y1 = fastFloor(y);
int x0 = x1 - 1; int x0 = x1 - 1;
int y0 = y1 - 1; int y0 = y1 - 1;
@@ -1839,7 +1839,7 @@ public class FastNoise
float xs = x - (float) x1; float xs = x - (float) x1;
float ys = y - (float) y1; float ys = y - (float) y1;
return CubicLerp(CubicLerp(ValCoord2D(seed, x0, y0), ValCoord2D(seed, x1, y0), ValCoord2D(seed, x2, y0), ValCoord2D(seed, x3, y0), xs), CubicLerp(ValCoord2D(seed, x0, y1), ValCoord2D(seed, x1, y1), ValCoord2D(seed, x2, y1), ValCoord2D(seed, x3, y1), xs), CubicLerp(ValCoord2D(seed, x0, y2), ValCoord2D(seed, x1, y2), ValCoord2D(seed, x2, y2), ValCoord2D(seed, x3, y2), xs), CubicLerp(ValCoord2D(seed, x0, y3), ValCoord2D(seed, x1, y3), ValCoord2D(seed, x2, y3), ValCoord2D(seed, x3, y3), xs), ys) * CUBIC_2D_BOUNDING; return cubicLerp(cubicLerp(valCoord2D(seed, x0, y0), valCoord2D(seed, x1, y0), valCoord2D(seed, x2, y0), valCoord2D(seed, x3, y0), xs), cubicLerp(valCoord2D(seed, x0, y1), valCoord2D(seed, x1, y1), valCoord2D(seed, x2, y1), valCoord2D(seed, x3, y1), xs), cubicLerp(valCoord2D(seed, x0, y2), valCoord2D(seed, x1, y2), valCoord2D(seed, x2, y2), valCoord2D(seed, x3, y2), xs), cubicLerp(valCoord2D(seed, x0, y3), valCoord2D(seed, x1, y3), valCoord2D(seed, x2, y3), valCoord2D(seed, x3, y3), xs), ys) * CUBIC_2D_BOUNDING;
} }
// Cellular Noise // Cellular Noise
@@ -1862,9 +1862,9 @@ public class FastNoise
private float SingleCellular(float x, float y, float z) private float SingleCellular(float x, float y, float z)
{ {
int xr = FastRound(x); int xr = fastRound(x);
int yr = FastRound(y); int yr = fastRound(y);
int zr = FastRound(z); int zr = fastRound(z);
float distance = 999999; float distance = 999999;
int xc = 0, yc = 0, zc = 0; int xc = 0, yc = 0, zc = 0;
@@ -1878,7 +1878,7 @@ public class FastNoise
{ {
for(int zi = zr - 1; zi <= zr + 1; zi++) for(int zi = zr - 1; zi <= zr + 1; zi++)
{ {
Float3 vec = CELL_3D[Hash3D(m_seed, xi, yi, zi) & 255]; Float3 vec = CELL_3D[hash3D(m_seed, xi, yi, zi) & 255];
float vecX = xi - x + vec.x; float vecX = xi - x + vec.x;
float vecY = yi - y + vec.y; float vecY = yi - y + vec.y;
@@ -1904,7 +1904,7 @@ public class FastNoise
{ {
for(int zi = zr - 1; zi <= zr + 1; zi++) for(int zi = zr - 1; zi <= zr + 1; zi++)
{ {
Float3 vec = CELL_3D[Hash3D(m_seed, xi, yi, zi) & 255]; Float3 vec = CELL_3D[hash3D(m_seed, xi, yi, zi) & 255];
float vecX = xi - x + vec.x; float vecX = xi - x + vec.x;
float vecY = yi - y + vec.y; float vecY = yi - y + vec.y;
@@ -1930,7 +1930,7 @@ public class FastNoise
{ {
for(int zi = zr - 1; zi <= zr + 1; zi++) for(int zi = zr - 1; zi <= zr + 1; zi++)
{ {
Float3 vec = CELL_3D[Hash3D(m_seed, xi, yi, zi) & 255]; Float3 vec = CELL_3D[hash3D(m_seed, xi, yi, zi) & 255];
float vecX = xi - x + vec.x; float vecX = xi - x + vec.x;
float vecY = yi - y + vec.y; float vecY = yi - y + vec.y;
@@ -1954,10 +1954,10 @@ public class FastNoise
switch(m_cellularReturnType) switch(m_cellularReturnType)
{ {
case CellValue: case CellValue:
return ValCoord3D(0, xc, yc, zc); return valCoord3D(0, xc, yc, zc);
case NoiseLookup: case NoiseLookup:
Float3 vec = CELL_3D[Hash3D(m_seed, xc, yc, zc) & 255]; Float3 vec = CELL_3D[hash3D(m_seed, xc, yc, zc) & 255];
return m_cellularNoiseLookup.GetNoise(xc + vec.x, yc + vec.y, zc + vec.z); return m_cellularNoiseLookup.GetNoise(xc + vec.x, yc + vec.y, zc + vec.z);
case Distance: case Distance:
@@ -1969,9 +1969,9 @@ public class FastNoise
private float SingleCellular2Edge(float x, float y, float z) private float SingleCellular2Edge(float x, float y, float z)
{ {
int xr = FastRound(x); int xr = fastRound(x);
int yr = FastRound(y); int yr = fastRound(y);
int zr = FastRound(z); int zr = fastRound(z);
float distance = 999999; float distance = 999999;
float distance2 = 999999; float distance2 = 999999;
@@ -1985,7 +1985,7 @@ public class FastNoise
{ {
for(int zi = zr - 1; zi <= zr + 1; zi++) for(int zi = zr - 1; zi <= zr + 1; zi++)
{ {
Float3 vec = CELL_3D[Hash3D(m_seed, xi, yi, zi) & 255]; Float3 vec = CELL_3D[hash3D(m_seed, xi, yi, zi) & 255];
float vecX = xi - x + vec.x; float vecX = xi - x + vec.x;
float vecY = yi - y + vec.y; float vecY = yi - y + vec.y;
@@ -2006,7 +2006,7 @@ public class FastNoise
{ {
for(int zi = zr - 1; zi <= zr + 1; zi++) for(int zi = zr - 1; zi <= zr + 1; zi++)
{ {
Float3 vec = CELL_3D[Hash3D(m_seed, xi, yi, zi) & 255]; Float3 vec = CELL_3D[hash3D(m_seed, xi, yi, zi) & 255];
float vecX = xi - x + vec.x; float vecX = xi - x + vec.x;
float vecY = yi - y + vec.y; float vecY = yi - y + vec.y;
@@ -2027,7 +2027,7 @@ public class FastNoise
{ {
for(int zi = zr - 1; zi <= zr + 1; zi++) for(int zi = zr - 1; zi <= zr + 1; zi++)
{ {
Float3 vec = CELL_3D[Hash3D(m_seed, xi, yi, zi) & 255]; Float3 vec = CELL_3D[hash3D(m_seed, xi, yi, zi) & 255];
float vecX = xi - x + vec.x; float vecX = xi - x + vec.x;
float vecY = yi - y + vec.y; float vecY = yi - y + vec.y;
@@ -2080,8 +2080,8 @@ public class FastNoise
private float SingleCellular(float x, float y) private float SingleCellular(float x, float y)
{ {
int xr = FastRound(x); int xr = fastRound(x);
int yr = FastRound(y); int yr = fastRound(y);
float distance = 999999; float distance = 999999;
int xc = 0, yc = 0; int xc = 0, yc = 0;
@@ -2094,7 +2094,7 @@ public class FastNoise
{ {
for(int yi = yr - 1; yi <= yr + 1; yi++) for(int yi = yr - 1; yi <= yr + 1; yi++)
{ {
Float2 vec = CELL_2D[Hash2D(m_seed, xi, yi) & 255]; Float2 vec = CELL_2D[hash2D(m_seed, xi, yi) & 255];
float vecX = xi - x + vec.x; float vecX = xi - x + vec.x;
float vecY = yi - y + vec.y; float vecY = yi - y + vec.y;
@@ -2115,7 +2115,7 @@ public class FastNoise
{ {
for(int yi = yr - 1; yi <= yr + 1; yi++) for(int yi = yr - 1; yi <= yr + 1; yi++)
{ {
Float2 vec = CELL_2D[Hash2D(m_seed, xi, yi) & 255]; Float2 vec = CELL_2D[hash2D(m_seed, xi, yi) & 255];
float vecX = xi - x + vec.x; float vecX = xi - x + vec.x;
float vecY = yi - y + vec.y; float vecY = yi - y + vec.y;
@@ -2136,7 +2136,7 @@ public class FastNoise
{ {
for(int yi = yr - 1; yi <= yr + 1; yi++) for(int yi = yr - 1; yi <= yr + 1; yi++)
{ {
Float2 vec = CELL_2D[Hash2D(m_seed, xi, yi) & 255]; Float2 vec = CELL_2D[hash2D(m_seed, xi, yi) & 255];
float vecX = xi - x + vec.x; float vecX = xi - x + vec.x;
float vecY = yi - y + vec.y; float vecY = yi - y + vec.y;
@@ -2157,10 +2157,10 @@ public class FastNoise
switch(m_cellularReturnType) switch(m_cellularReturnType)
{ {
case CellValue: case CellValue:
return ValCoord2D(0, xc, yc); return valCoord2D(0, xc, yc);
case NoiseLookup: case NoiseLookup:
Float2 vec = CELL_2D[Hash2D(m_seed, xc, yc) & 255]; Float2 vec = CELL_2D[hash2D(m_seed, xc, yc) & 255];
return m_cellularNoiseLookup.GetNoise(xc + vec.x, yc + vec.y); return m_cellularNoiseLookup.GetNoise(xc + vec.x, yc + vec.y);
case Distance: case Distance:
@@ -2172,8 +2172,8 @@ public class FastNoise
private float SingleCellular2Edge(float x, float y) private float SingleCellular2Edge(float x, float y)
{ {
int xr = FastRound(x); int xr = fastRound(x);
int yr = FastRound(y); int yr = fastRound(y);
float distance = 999999; float distance = 999999;
float distance2 = 999999; float distance2 = 999999;
@@ -2186,7 +2186,7 @@ public class FastNoise
{ {
for(int yi = yr - 1; yi <= yr + 1; yi++) for(int yi = yr - 1; yi <= yr + 1; yi++)
{ {
Float2 vec = CELL_2D[Hash2D(m_seed, xi, yi) & 255]; Float2 vec = CELL_2D[hash2D(m_seed, xi, yi) & 255];
float vecX = xi - x + vec.x; float vecX = xi - x + vec.x;
float vecY = yi - y + vec.y; float vecY = yi - y + vec.y;
@@ -2203,7 +2203,7 @@ public class FastNoise
{ {
for(int yi = yr - 1; yi <= yr + 1; yi++) for(int yi = yr - 1; yi <= yr + 1; yi++)
{ {
Float2 vec = CELL_2D[Hash2D(m_seed, xi, yi) & 255]; Float2 vec = CELL_2D[hash2D(m_seed, xi, yi) & 255];
float vecX = xi - x + vec.x; float vecX = xi - x + vec.x;
float vecY = yi - y + vec.y; float vecY = yi - y + vec.y;
@@ -2220,7 +2220,7 @@ public class FastNoise
{ {
for(int yi = yr - 1; yi <= yr + 1; yi++) for(int yi = yr - 1; yi <= yr + 1; yi++)
{ {
Float2 vec = CELL_2D[Hash2D(m_seed, xi, yi) & 255]; Float2 vec = CELL_2D[hash2D(m_seed, xi, yi) & 255];
float vecX = xi - x + vec.x; float vecX = xi - x + vec.x;
float vecY = yi - y + vec.y; float vecY = yi - y + vec.y;
@@ -2278,9 +2278,9 @@ public class FastNoise
float yf = v3.y * frequency; float yf = v3.y * frequency;
float zf = v3.z * frequency; float zf = v3.z * frequency;
int x0 = FastFloor(xf); int x0 = fastFloor(xf);
int y0 = FastFloor(yf); int y0 = fastFloor(yf);
int z0 = FastFloor(zf); int z0 = fastFloor(zf);
int x1 = x0 + 1; int x1 = x0 + 1;
int y1 = y0 + 1; int y1 = y0 + 1;
int z1 = z0 + 1; int z1 = z0 + 1;
@@ -2295,52 +2295,52 @@ public class FastNoise
zs = zf - z0; zs = zf - z0;
break; break;
case Hermite: case Hermite:
xs = InterpHermiteFunc(xf - x0); xs = interpHermiteFunc(xf - x0);
ys = InterpHermiteFunc(yf - y0); ys = interpHermiteFunc(yf - y0);
zs = InterpHermiteFunc(zf - z0); zs = interpHermiteFunc(zf - z0);
break; break;
case Quintic: case Quintic:
xs = InterpQuinticFunc(xf - x0); xs = interpQuinticFunc(xf - x0);
ys = InterpQuinticFunc(yf - y0); ys = interpQuinticFunc(yf - y0);
zs = InterpQuinticFunc(zf - z0); zs = interpQuinticFunc(zf - z0);
break; break;
} }
Float3 vec0 = CELL_3D[Hash3D(seed, x0, y0, z0) & 255]; Float3 vec0 = CELL_3D[hash3D(seed, x0, y0, z0) & 255];
Float3 vec1 = CELL_3D[Hash3D(seed, x1, y0, z0) & 255]; Float3 vec1 = CELL_3D[hash3D(seed, x1, y0, z0) & 255];
float lx0x = Lerp(vec0.x, vec1.x, xs); float lx0x = lerp(vec0.x, vec1.x, xs);
float ly0x = Lerp(vec0.y, vec1.y, xs); float ly0x = lerp(vec0.y, vec1.y, xs);
float lz0x = Lerp(vec0.z, vec1.z, xs); float lz0x = lerp(vec0.z, vec1.z, xs);
vec0 = CELL_3D[Hash3D(seed, x0, y1, z0) & 255]; vec0 = CELL_3D[hash3D(seed, x0, y1, z0) & 255];
vec1 = CELL_3D[Hash3D(seed, x1, y1, z0) & 255]; vec1 = CELL_3D[hash3D(seed, x1, y1, z0) & 255];
float lx1x = Lerp(vec0.x, vec1.x, xs); float lx1x = lerp(vec0.x, vec1.x, xs);
float ly1x = Lerp(vec0.y, vec1.y, xs); float ly1x = lerp(vec0.y, vec1.y, xs);
float lz1x = Lerp(vec0.z, vec1.z, xs); float lz1x = lerp(vec0.z, vec1.z, xs);
float lx0y = Lerp(lx0x, lx1x, ys); float lx0y = lerp(lx0x, lx1x, ys);
float ly0y = Lerp(ly0x, ly1x, ys); float ly0y = lerp(ly0x, ly1x, ys);
float lz0y = Lerp(lz0x, lz1x, ys); float lz0y = lerp(lz0x, lz1x, ys);
vec0 = CELL_3D[Hash3D(seed, x0, y0, z1) & 255]; vec0 = CELL_3D[hash3D(seed, x0, y0, z1) & 255];
vec1 = CELL_3D[Hash3D(seed, x1, y0, z1) & 255]; vec1 = CELL_3D[hash3D(seed, x1, y0, z1) & 255];
lx0x = Lerp(vec0.x, vec1.x, xs); lx0x = lerp(vec0.x, vec1.x, xs);
ly0x = Lerp(vec0.y, vec1.y, xs); ly0x = lerp(vec0.y, vec1.y, xs);
lz0x = Lerp(vec0.z, vec1.z, xs); lz0x = lerp(vec0.z, vec1.z, xs);
vec0 = CELL_3D[Hash3D(seed, x0, y1, z1) & 255]; vec0 = CELL_3D[hash3D(seed, x0, y1, z1) & 255];
vec1 = CELL_3D[Hash3D(seed, x1, y1, z1) & 255]; vec1 = CELL_3D[hash3D(seed, x1, y1, z1) & 255];
lx1x = Lerp(vec0.x, vec1.x, xs); lx1x = lerp(vec0.x, vec1.x, xs);
ly1x = Lerp(vec0.y, vec1.y, xs); ly1x = lerp(vec0.y, vec1.y, xs);
lz1x = Lerp(vec0.z, vec1.z, xs); lz1x = lerp(vec0.z, vec1.z, xs);
v3.x += Lerp(lx0y, Lerp(lx0x, lx1x, ys), zs) * perturbAmp; v3.x += lerp(lx0y, lerp(lx0x, lx1x, ys), zs) * perturbAmp;
v3.y += Lerp(ly0y, Lerp(ly0x, ly1x, ys), zs) * perturbAmp; v3.y += lerp(ly0y, lerp(ly0x, ly1x, ys), zs) * perturbAmp;
v3.z += Lerp(lz0y, Lerp(lz0x, lz1x, ys), zs) * perturbAmp; v3.z += lerp(lz0y, lerp(lz0x, lz1x, ys), zs) * perturbAmp;
} }
public void GradientPerturb(Vector2f v2) public void GradientPerturb(Vector2f v2)
@@ -2369,8 +2369,8 @@ public class FastNoise
float xf = v2.x * frequency; float xf = v2.x * frequency;
float yf = v2.y * frequency; float yf = v2.y * frequency;
int x0 = FastFloor(xf); int x0 = fastFloor(xf);
int y0 = FastFloor(yf); int y0 = fastFloor(yf);
int x1 = x0 + 1; int x1 = x0 + 1;
int y1 = y0 + 1; int y1 = y0 + 1;
@@ -2383,29 +2383,29 @@ public class FastNoise
ys = yf - y0; ys = yf - y0;
break; break;
case Hermite: case Hermite:
xs = InterpHermiteFunc(xf - x0); xs = interpHermiteFunc(xf - x0);
ys = InterpHermiteFunc(yf - y0); ys = interpHermiteFunc(yf - y0);
break; break;
case Quintic: case Quintic:
xs = InterpQuinticFunc(xf - x0); xs = interpQuinticFunc(xf - x0);
ys = InterpQuinticFunc(yf - y0); ys = interpQuinticFunc(yf - y0);
break; break;
} }
Float2 vec0 = CELL_2D[Hash2D(seed, x0, y0) & 255]; Float2 vec0 = CELL_2D[hash2D(seed, x0, y0) & 255];
Float2 vec1 = CELL_2D[Hash2D(seed, x1, y0) & 255]; Float2 vec1 = CELL_2D[hash2D(seed, x1, y0) & 255];
float lx0x = Lerp(vec0.x, vec1.x, xs); float lx0x = lerp(vec0.x, vec1.x, xs);
float ly0x = Lerp(vec0.y, vec1.y, xs); float ly0x = lerp(vec0.y, vec1.y, xs);
vec0 = CELL_2D[Hash2D(seed, x0, y1) & 255]; vec0 = CELL_2D[hash2D(seed, x0, y1) & 255];
vec1 = CELL_2D[Hash2D(seed, x1, y1) & 255]; vec1 = CELL_2D[hash2D(seed, x1, y1) & 255];
float lx1x = Lerp(vec0.x, vec1.x, xs); float lx1x = lerp(vec0.x, vec1.x, xs);
float ly1x = Lerp(vec0.y, vec1.y, xs); float ly1x = lerp(vec0.y, vec1.y, xs);
v2.x += Lerp(lx0x, lx1x, ys) * perturbAmp; v2.x += lerp(lx0x, lx1x, ys) * perturbAmp;
v2.y += Lerp(ly0x, ly1x, ys) * perturbAmp; v2.y += lerp(ly0x, ly1x, ys) * perturbAmp;
} }
} }
@@ -8,8 +8,8 @@ public class FractalBillowPerlinNoise implements NoiseGenerator, OctaveNoise {
public FractalBillowPerlinNoise(long seed) { public FractalBillowPerlinNoise(long seed) {
this.n = new FastNoise(new RNG(seed).imax()); this.n = new FastNoise(new RNG(seed).imax());
n.SetFractalOctaves(1); n.setFractalOctaves(1);
n.SetFractalType(FractalType.Billow); n.setFractalType(FractalType.Billow);
} }
public double f(double v) { public double f(double v) {
@@ -33,6 +33,6 @@ public class FractalBillowPerlinNoise implements NoiseGenerator, OctaveNoise {
@Override @Override
public void setOctaves(int o) { public void setOctaves(int o) {
n.SetFractalOctaves(o); n.setFractalOctaves(o);
} }
} }
@@ -8,8 +8,8 @@ public class FractalBillowSimplexNoise implements NoiseGenerator, OctaveNoise {
public FractalBillowSimplexNoise(long seed) { public FractalBillowSimplexNoise(long seed) {
this.n = new FastNoise(new RNG(seed).imax()); this.n = new FastNoise(new RNG(seed).imax());
n.SetFractalOctaves(1); n.setFractalOctaves(1);
n.SetFractalType(FractalType.Billow); n.setFractalType(FractalType.Billow);
} }
public double f(double v) { public double f(double v) {
@@ -33,6 +33,6 @@ public class FractalBillowSimplexNoise implements NoiseGenerator, OctaveNoise {
@Override @Override
public void setOctaves(int o) { public void setOctaves(int o) {
n.SetFractalOctaves(o); n.setFractalOctaves(o);
} }
} }
@@ -7,7 +7,7 @@ public class FractalCubicNoise implements NoiseGenerator {
public FractalCubicNoise(long seed) { public FractalCubicNoise(long seed) {
this.n = new FastNoise((int) seed); this.n = new FastNoise((int) seed);
n.SetFractalType(FractalType.Billow); n.setFractalType(FractalType.Billow);
} }
private double f(double n) { private double f(double n) {
@@ -8,8 +8,8 @@ public class FractalFBMSimplexNoise implements NoiseGenerator, OctaveNoise {
public FractalFBMSimplexNoise(long seed) { public FractalFBMSimplexNoise(long seed) {
this.n = new FastNoise(new RNG(seed).imax()); this.n = new FastNoise(new RNG(seed).imax());
n.SetFractalOctaves(1); n.setFractalOctaves(1);
n.SetFractalType(FractalType.FBM); n.setFractalType(FractalType.FBM);
} }
public double f(double v) { public double f(double v) {
@@ -33,6 +33,6 @@ public class FractalFBMSimplexNoise implements NoiseGenerator, OctaveNoise {
@Override @Override
public void setOctaves(int o) { public void setOctaves(int o) {
n.SetFractalOctaves(o); n.setFractalOctaves(o);
} }
} }
@@ -8,8 +8,8 @@ public class FractalRigidMultiSimplexNoise implements NoiseGenerator, OctaveNois
public FractalRigidMultiSimplexNoise(long seed) { public FractalRigidMultiSimplexNoise(long seed) {
this.n = new FastNoise(new RNG(seed).imax()); this.n = new FastNoise(new RNG(seed).imax());
n.SetFractalOctaves(1); n.setFractalOctaves(1);
n.SetFractalType(FractalType.RigidMulti); n.setFractalType(FractalType.RigidMulti);
} }
public double f(double v) { public double f(double v) {
@@ -33,6 +33,6 @@ public class FractalRigidMultiSimplexNoise implements NoiseGenerator, OctaveNois
@Override @Override
public void setOctaves(int o) { public void setOctaves(int o) {
n.SetFractalOctaves(o); n.setFractalOctaves(o);
} }
} }
@@ -5,9 +5,9 @@ public class GlobNoise implements NoiseGenerator {
public GlobNoise(long seed) { public GlobNoise(long seed) {
this.n = new FastNoise((int) seed); this.n = new FastNoise((int) seed);
n.SetNoiseType(FastNoise.NoiseType.Cellular); n.setNoiseType(FastNoise.NoiseType.Cellular);
n.SetCellularReturnType(FastNoise.CellularReturnType.Distance2Div); n.setCellularReturnType(FastNoise.CellularReturnType.Distance2Div);
n.SetCellularDistanceFunction(FastNoise.CellularDistanceFunction.Natural); n.setCellularDistanceFunction(FastNoise.CellularDistanceFunction.Natural);
} }
private double f(double n) private double f(double n)
@@ -8,7 +8,7 @@ public class PerlinNoise implements NoiseGenerator, OctaveNoise {
public PerlinNoise(long seed) { public PerlinNoise(long seed) {
this.n = new FastNoise(new RNG(seed).imax()); this.n = new FastNoise(new RNG(seed).imax());
n.SetNoiseType(FastNoise.NoiseType.Perlin); n.setNoiseType(FastNoise.NoiseType.Perlin);
octaves = 1; octaves = 1;
} }
@@ -8,7 +8,7 @@ public class SimplexNoise implements NoiseGenerator, OctaveNoise {
public SimplexNoise(long seed) { public SimplexNoise(long seed) {
this.n = new FastNoise(new RNG(seed).imax()); this.n = new FastNoise(new RNG(seed).imax());
n.SetNoiseType(FastNoise.NoiseType.Simplex); n.setNoiseType(FastNoise.NoiseType.Simplex);
octaves = 1; octaves = 1;
} }
@@ -7,9 +7,9 @@ public class VascularNoise implements NoiseGenerator {
public VascularNoise(long seed) { public VascularNoise(long seed) {
this.n = new FastNoise((int) seed); this.n = new FastNoise((int) seed);
n.SetNoiseType(FastNoise.NoiseType.Cellular); n.setNoiseType(FastNoise.NoiseType.Cellular);
n.SetCellularReturnType(FastNoise.CellularReturnType.Distance2Sub); n.setCellularReturnType(FastNoise.CellularReturnType.Distance2Sub);
n.SetCellularDistanceFunction(FastNoise.CellularDistanceFunction.Natural); n.setCellularDistanceFunction(FastNoise.CellularDistanceFunction.Natural);
} }
private double filter(double noise) { private double filter(double noise) {
@@ -31,7 +31,6 @@ import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
public class IrisObject extends IrisRegistrant public class IrisObject extends IrisRegistrant
{ {
private static final Material SNOW = Material.SNOW;
private static final BlockData AIR = B.getBlockData("CAVE_AIR"); private static final BlockData AIR = B.getBlockData("CAVE_AIR");
private static final BlockData[] SNOW_LAYERS = new BlockData[] {B.getBlockData("minecraft:snow[layers=1]"), B.getBlockData("minecraft:snow[layers=2]"), B.getBlockData("minecraft:snow[layers=3]"), B.getBlockData("minecraft:snow[layers=4]"), B.getBlockData("minecraft:snow[layers=5]"), B.getBlockData("minecraft:snow[layers=6]"), B.getBlockData("minecraft:snow[layers=7]"), B.getBlockData("minecraft:snow[layers=8]")}; private static final BlockData[] SNOW_LAYERS = new BlockData[] {B.getBlockData("minecraft:snow[layers=1]"), B.getBlockData("minecraft:snow[layers=2]"), B.getBlockData("minecraft:snow[layers=3]"), B.getBlockData("minecraft:snow[layers=4]"), B.getBlockData("minecraft:snow[layers=5]"), B.getBlockData("minecraft:snow[layers=6]"), B.getBlockData("minecraft:snow[layers=7]"), B.getBlockData("minecraft:snow[layers=8]")};
public static boolean shitty = false; public static boolean shitty = false;
@@ -469,12 +468,6 @@ public class IrisObject extends IrisRegistrant
if(config.getSnow() > 0) if(config.getSnow() > 0)
{ {
BlockData bd = placer.get(vx, vy, vz);
if(bd != null && bd.getMaterial().equals(SNOW))
{
continue;
}
int height = rngx.i(0, (int) (config.getSnow() * 7)); int height = rngx.i(0, (int) (config.getSnow() * 7));
placer.set(vx, vy + 1, vz, SNOW_LAYERS[Math.max(Math.min(height, 7), 0)]); placer.set(vx, vy + 1, vz, SNOW_LAYERS[Math.max(Math.min(height, 7), 0)]);
} }
@@ -6,8 +6,6 @@ import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinPool.ForkJoinWorkerThreadFactory; import java.util.concurrent.ForkJoinPool.ForkJoinWorkerThreadFactory;
import java.util.concurrent.ForkJoinWorkerThread; import java.util.concurrent.ForkJoinWorkerThread;
import com.volmit.iris.Iris;
public class GroupedExecutor public class GroupedExecutor
{ {
private int xc; private int xc;
@@ -73,21 +71,12 @@ public class GroupedExecutor
return; return;
} }
PrecisionStopwatch s = PrecisionStopwatch.start();
while(true) while(true)
{ {
if(mirror.get(g) == 0) if(mirror.get(g) == 0)
{ {
break; break;
} }
if(s.getMilliseconds() > 30000)
{
Iris.warn("Couldn't unlock grouped task: " + g + "! Clearing Task Group Forcibly and timing out!");
mirror.remove(g);
break;
}
} }
} }