From 9aa6d1c0fc9364659e6a74eed944bfc7946fb69c Mon Sep 17 00:00:00 2001 From: Daniel Mills Date: Wed, 2 Sep 2020 21:06:01 -0400 Subject: [PATCH] Optimization --- .../iris/gen/ParallaxChunkGenerator.java | 67 +--- .../iris/gen/ParallelChunkGenerator.java | 5 +- .../volmit/iris/gen/layer/GenLayerBiome.java | 4 +- .../volmit/iris/gen/layer/GenLayerCave.java | 6 +- .../com/volmit/iris/noise/CellGenerator.java | 12 +- .../volmit/iris/noise/CellHeightNoise.java | 6 +- .../com/volmit/iris/noise/CellularNoise.java | 21 +- .../java/com/volmit/iris/noise/FastNoise.java | 368 +++++++++--------- .../iris/noise/FractalBillowPerlinNoise.java | 6 +- .../iris/noise/FractalBillowSimplexNoise.java | 6 +- .../volmit/iris/noise/FractalCubicNoise.java | 2 +- .../iris/noise/FractalFBMSimplexNoise.java | 6 +- .../noise/FractalRigidMultiSimplexNoise.java | 6 +- .../java/com/volmit/iris/noise/GlobNoise.java | 6 +- .../com/volmit/iris/noise/PerlinNoise.java | 2 +- .../com/volmit/iris/noise/SimplexNoise.java | 2 +- .../com/volmit/iris/noise/VascularNoise.java | 6 +- .../com/volmit/iris/object/IrisObject.java | 7 - .../com/volmit/iris/util/GroupedExecutor.java | 11 - 19 files changed, 242 insertions(+), 307 deletions(-) diff --git a/src/main/java/com/volmit/iris/gen/ParallaxChunkGenerator.java b/src/main/java/com/volmit/iris/gen/ParallaxChunkGenerator.java index 8343adb26..e39c08353 100644 --- a/src/main/java/com/volmit/iris/gen/ParallaxChunkGenerator.java +++ b/src/main/java/com/volmit/iris/gen/ParallaxChunkGenerator.java @@ -28,7 +28,6 @@ import com.volmit.iris.util.IrisLock; import com.volmit.iris.util.IrisStructureResult; import com.volmit.iris.util.KList; import com.volmit.iris.util.KMap; -import com.volmit.iris.util.NastyRunnable; import com.volmit.iris.util.PrecisionStopwatch; import com.volmit.iris.util.RNG; @@ -45,7 +44,6 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple private MasterLock masterLock; private IrisLock flock = new IrisLock("ParallaxLock"); private IrisLock lock = new IrisLock("ParallaxLock"); - private IrisLock lockq = new IrisLock("ParallaxQueueLock"); private GenLayerUpdate glUpdate; private GenLayerText glText; private int sliverBuffer; @@ -230,7 +228,6 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple { String key = "par." + x + "." + z; ChunkPosition rad = getDimension().getParallaxSize(this); - KList q = new KList<>(); 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()) { int gg = g++; - lockq.lock(); - q.add(() -> - { - placeObject(m, i, j, random.nextParallelRNG((34 * ((i * 30) + (j * 30) + gg) * i * j) + i - j + 1569962)); - }); - lockq.unlock(); + placeObject(m, i, j, random.nextParallelRNG((34 * ((i * 30) + (j * 30) + gg) * i * j) + i - j + 1569962)); } continue searching; @@ -292,63 +284,33 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple for(IrisTextPlacement k : getDimension().getText()) { - lockq.lock(); - q.add(() -> - { - k.place(this, random.nextParallelRNG(-7228 + (34 * ((i * 30) + (j * 30)) * i * j) + i - j + 1569962), i, j); - }); - lockq.unlock(); + k.place(this, random.nextParallelRNG(-7228 + (34 * ((i * 30) + (j * 30)) * i * j) + i - j + 1569962), i, j); } for(IrisTextPlacement k : r.getText()) { - lockq.lock(); - q.add(() -> - { - k.place(this, random.nextParallelRNG(-4228 + -7228 + (34 * ((i * 30) + (j * 30)) * i * j) + i - j + 1569962), i, j); - }); - lockq.unlock(); + k.place(this, random.nextParallelRNG(-4228 + -7228 + (34 * ((i * 30) + (j * 30)) * i * j) + i - j + 1569962), i, j); } for(IrisTextPlacement k : b.getText()) { - lockq.lock(); - q.add(() -> - { - k.place(this, random.nextParallelRNG(-22228 + -4228 + -7228 + (34 * ((i * 30) + (j * 30)) * i * j) + i - j + 1569962), i, j); - }); - lockq.unlock(); + k.place(this, random.nextParallelRNG(-22228 + -4228 + -7228 + (34 * ((i * 30) + (j * 30)) * i * j) + i - j + 1569962), i, j); } for(IrisStructurePlacement k : r.getStructures()) { - lockq.lock(); - q.add(() -> - { - k.place(this, random.nextParallelRNG(2228), i, j); - }); - lockq.unlock(); + k.place(this, random.nextParallelRNG(2228), i, j); } for(IrisStructurePlacement k : b.getStructures()) { - lockq.lock(); - q.add(() -> - { - k.place(this, random.nextParallelRNG(-22228), i, j); - }); - lockq.unlock(); + k.place(this, random.nextParallelRNG(-22228), i, j); } for(IrisObjectPlacement k : b.getObjects()) { int gg = g++; - lockq.lock(); - q.add(() -> - { - placeObject(k, i, j, random.nextParallelRNG((34 * ((i * 30) + (j * 30) + gg) * i * j) + i - j + 3569222)); - }); - lockq.unlock(); + placeObject(k, i, j, random.nextParallelRNG((34 * ((i * 30) + (j * 30) + gg) * i * j) + i - j + 3569222)); } if(getDimension().isCaves()) @@ -371,12 +333,7 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple for(IrisObjectPlacement k : biome.getObjects()) { int gg = g++; - lockq.lock(); - q.add(() -> - { - placeCaveObject(k, i, j, random.nextParallelRNG((34 * ((i * 30) + (j * 30) + gg) * i * j) + i - j + 1869322)); - }); - lockq.unlock(); + placeCaveObject(k, i, j, random.nextParallelRNG((34 * ((i * 30) + (j * 30) + gg) * i * j) + i - j + 1869322)); } } }); @@ -386,14 +343,6 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple } 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) diff --git a/src/main/java/com/volmit/iris/gen/ParallelChunkGenerator.java b/src/main/java/com/volmit/iris/gen/ParallelChunkGenerator.java index 881daa79d..943454fde 100644 --- a/src/main/java/com/volmit/iris/gen/ParallelChunkGenerator.java +++ b/src/main/java/com/volmit/iris/gen/ParallelChunkGenerator.java @@ -37,7 +37,7 @@ public abstract class ParallelChunkGenerator extends DimensionChunkGenerator { threads = tc; 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); if(e != null) @@ -90,8 +90,7 @@ public abstract class ParallelChunkGenerator extends DimensionChunkGenerator int j = jj; int wz = (z * 16) + j; AtomicSliver sliver = map.getSliver(i, j); - - accelerant.queue(key, () -> + getAccelerant().queue(key, () -> { try { diff --git a/src/main/java/com/volmit/iris/gen/layer/GenLayerBiome.java b/src/main/java/com/volmit/iris/gen/layer/GenLayerBiome.java index d241c0968..9ee3bab83 100644 --- a/src/main/java/com/volmit/iris/gen/layer/GenLayerBiome.java +++ b/src/main/java/com/volmit/iris/gen/layer/GenLayerBiome.java @@ -200,10 +200,10 @@ public class GenLayerBiome extends GenLayer double x = bx / 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()); - KList chx = parent.getRealChildren(iris).copy(); // TODO Cache + KList chx = parent.getRealChildren(iris).copy(); chx.add(parent); IrisBiome biome = childCell.fitRarity(chx, x, z); biome.setInferredType(parent.getInferredType()); diff --git a/src/main/java/com/volmit/iris/gen/layer/GenLayerCave.java b/src/main/java/com/volmit/iris/gen/layer/GenLayerCave.java index 69518d63f..2778dfd07 100644 --- a/src/main/java/com/volmit/iris/gen/layer/GenLayerCave.java +++ b/src/main/java/com/volmit/iris/gen/layer/GenLayerCave.java @@ -40,9 +40,9 @@ public class GenLayerCave extends GenLayer } KList result = new KList<>(); - gg.SetNoiseType(NoiseType.Cellular); - gg.SetCellularReturnType(CellularReturnType.Distance2Sub); - gg.SetCellularDistanceFunction(CellularDistanceFunction.Natural); + gg.setNoiseType(NoiseType.Cellular); + gg.setCellularReturnType(CellularReturnType.Distance2Sub); + gg.setCellularDistanceFunction(CellularDistanceFunction.Natural); for(int i = 0; i < iris.getDimension().getCaveLayers().size(); i++) { diff --git a/src/main/java/com/volmit/iris/noise/CellGenerator.java b/src/main/java/com/volmit/iris/noise/CellGenerator.java index 7c3131171..315657909 100644 --- a/src/main/java/com/volmit/iris/noise/CellGenerator.java +++ b/src/main/java/com/volmit/iris/noise/CellGenerator.java @@ -27,13 +27,13 @@ public class CellGenerator RNG rx = rng.nextParallelRNG(8735652); int s = rx.nextInt(); fn = new FastNoise(s); - fn.SetNoiseType(FastNoise.NoiseType.Cellular); - fn.SetCellularReturnType(FastNoise.CellularReturnType.CellValue); - fn.SetCellularDistanceFunction(FastNoise.CellularDistanceFunction.Natural); + fn.setNoiseType(FastNoise.NoiseType.Cellular); + fn.setCellularReturnType(FastNoise.CellularReturnType.CellValue); + fn.setCellularDistanceFunction(FastNoise.CellularDistanceFunction.Natural); fd = new FastNoise(s); - fd.SetNoiseType(FastNoise.NoiseType.Cellular); - fd.SetCellularReturnType(FastNoise.CellularReturnType.Distance2Sub); - fd.SetCellularDistanceFunction(FastNoise.CellularDistanceFunction.Natural); + fd.setNoiseType(FastNoise.NoiseType.Cellular); + fd.setCellularReturnType(FastNoise.CellularReturnType.Distance2Sub); + fd.setCellularDistanceFunction(FastNoise.CellularDistanceFunction.Natural); } public float getDistance(double x, double z) diff --git a/src/main/java/com/volmit/iris/noise/CellHeightNoise.java b/src/main/java/com/volmit/iris/noise/CellHeightNoise.java index 5938de989..e304c4d89 100644 --- a/src/main/java/com/volmit/iris/noise/CellHeightNoise.java +++ b/src/main/java/com/volmit/iris/noise/CellHeightNoise.java @@ -7,9 +7,9 @@ public class CellHeightNoise implements NoiseGenerator { public CellHeightNoise(long seed) { this.n = new FastNoise((int) seed); - n.SetNoiseType(FastNoise.NoiseType.Cellular); - n.SetCellularReturnType(FastNoise.CellularReturnType.Distance2Sub); - n.SetCellularDistanceFunction(FastNoise.CellularDistanceFunction.Natural); + n.setNoiseType(FastNoise.NoiseType.Cellular); + n.setCellularReturnType(FastNoise.CellularReturnType.Distance2Sub); + n.setCellularDistanceFunction(FastNoise.CellularDistanceFunction.Natural); } private double filter(double noise) { diff --git a/src/main/java/com/volmit/iris/noise/CellularNoise.java b/src/main/java/com/volmit/iris/noise/CellularNoise.java index acc895179..bf81be884 100644 --- a/src/main/java/com/volmit/iris/noise/CellularNoise.java +++ b/src/main/java/com/volmit/iris/noise/CellularNoise.java @@ -1,27 +1,32 @@ package com.volmit.iris.noise; -public class CellularNoise implements NoiseGenerator { +public class CellularNoise implements NoiseGenerator +{ private final FastNoise n; - public CellularNoise(long seed) { + public CellularNoise(long seed) + { this.n = new FastNoise((int) seed); - n.SetNoiseType(FastNoise.NoiseType.Cellular); - n.SetCellularReturnType(FastNoise.CellularReturnType.CellValue); - n.SetCellularDistanceFunction(FastNoise.CellularDistanceFunction.Natural); + n.setNoiseType(FastNoise.NoiseType.Cellular); + n.setCellularReturnType(FastNoise.CellularReturnType.CellValue); + n.setCellularDistanceFunction(FastNoise.CellularDistanceFunction.Natural); } @Override - public double noise(double x) { + public double noise(double x) + { return (n.GetCellular((float) x, 0) / 2D) + 0.5D; } @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; } @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; } } diff --git a/src/main/java/com/volmit/iris/noise/FastNoise.java b/src/main/java/com/volmit/iris/noise/FastNoise.java index 359b97fa3..97084efd0 100644 --- a/src/main/java/com/volmit/iris/noise/FastNoise.java +++ b/src/main/java/com/volmit/iris/noise/FastNoise.java @@ -81,7 +81,7 @@ public class FastNoise private int m_seed = 1337; 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 int m_octaves = 3; @@ -105,31 +105,31 @@ public class FastNoise public FastNoise(int seed) { m_seed = seed; - CalculateFractalBounding(); + calculateFractalBounding(); } // Returns a 0 float/double - public static float GetDecimalType() + public static float getDecimalType() { return 0; } // Returns the seed used by this object - public int GetSeed() + public int getSeed() { return m_seed; } // Sets seed used for all noise types // Default: 1337 - public void SetSeed(int seed) + public void setSeed(int seed) { m_seed = seed; } // Sets frequency for all noise types // Default: 0.01 - public void SetFrequency(float frequency) + public void setFrequency(float frequency) { m_frequency = frequency; } @@ -141,44 +141,44 @@ public class FastNoise // - Quintic // Used in Value, Gradient Noise and Position Perturbing // Default: Quintic - public void SetInterp(Interp interp) + public void setInterp(Interp interp) { m_interp = interp; } // Sets noise return type of GetNoise(...) // Default: Simplex - public void SetNoiseType(NoiseType noiseType) + public void setNoiseType(NoiseType noiseType) { m_noiseType = noiseType; } // Sets octave count for all fractal noise types // Default: 3 - public void SetFractalOctaves(int octaves) + public void setFractalOctaves(int octaves) { m_octaves = octaves; - CalculateFractalBounding(); + calculateFractalBounding(); } // Sets octave lacunarity for all fractal noise types // Default: 2.0 - public void SetFractalLacunarity(float lacunarity) + public void setFractalLacunarity(float lacunarity) { m_lacunarity = lacunarity; } // Sets octave gain for all fractal noise types // Default: 0.5 - public void SetFractalGain(float gain) + public void setFractalGain(float gain) { m_gain = gain; - CalculateFractalBounding(); + calculateFractalBounding(); } // Sets method for combining octaves in all fractal noise types // Default: FBM - public void SetFractalType(FractalType fractalType) + public void setFractalType(FractalType fractalType) { m_fractalType = fractalType; } @@ -187,14 +187,14 @@ public class FastNoise // Note: NoiseLookup requires another FastNoise object be set with // SetCellularNoiseLookup() to function // Default: CellValue - public void SetCellularDistanceFunction(CellularDistanceFunction cellularDistanceFunction) + public void setCellularDistanceFunction(CellularDistanceFunction cellularDistanceFunction) { m_cellularDistanceFunction = cellularDistanceFunction; } // Sets distance function used in cellular noise calculations // Default: Euclidean - public void SetCellularReturnType(CellularReturnType cellularReturnType) + public void setCellularReturnType(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 // The lookup value is acquired through GetNoise() so ensure you SetNoiseType() // on the noise lookup, value, gradient or simplex is recommended - public void SetCellularNoiseLookup(FastNoise noise) + public void setCellularNoiseLookup(FastNoise noise) { m_cellularNoiseLookup = noise; } @@ -210,7 +210,7 @@ public class FastNoise // Sets the maximum perturb distance from original location when using // GradientPerturb{Fractal}(...) // Default: 1.0 - public void SetGradientPerturbAmp(float gradientPerturbAmp) + public void setGradientPerturbAmp(float gradientPerturbAmp) { 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.3547613644f, 0.1271702173f, 0.2459107769f), new Float3(0.2305790207f, 0.3063895591f, 0.2354968222f), new Float3(-0.08323845599f, -0.1922245118f, 0.3982726409f), new Float3(0.2993663085f, -0.2619918095f, -0.2103333191f), new Float3(-0.2154865723f, 0.2706747713f, 0.287751117f), new Float3(0.01683355354f, -0.2680655787f, -0.3610505186f), new Float3(0.05240429123f, 0.4335128183f, -0.1087217856f), new Float3(0.00940104872f, -0.4472890582f, 0.04841609928f), new Float3(0.3465688735f, 0.01141914583f, -0.2868093776f), new Float3(-0.3706867948f, -0.2551104378f, 0.003156692623f), new Float3(0.2741169781f, 0.2139972417f, -0.2855959784f), new Float3(0.06413433865f, 0.1708718512f, 0.4113266307f), new Float3(-0.388187972f, -0.03973280434f, -0.2241236325f), new Float3(0.06419469312f, -0.2803682491f, 0.3460819069f), new Float3(-0.1986120739f, -0.3391173584f, 0.2192091725f), new Float3(-0.203203009f, -0.3871641506f, 0.1063600375f), new Float3(-0.1389736354f, -0.2775901578f, -0.3257760473f), new Float3(-0.06555641638f, 0.342253257f, -0.2847192729f), new Float3(-0.2529246486f, -0.2904227915f, 0.2327739768f), new Float3(0.1444476522f, 0.1069184044f, 0.4125570634f), new Float3(-0.3643780054f, -0.2447099973f, -0.09922543227f), new Float3(0.4286142488f, -0.1358496089f, -0.01829506817f), new Float3(0.165872923f, -0.3136808464f, -0.2767498872f), new Float3(0.2219610524f, -0.3658139958f, 0.1393320198f), new Float3(0.04322940318f, -0.3832730794f, 0.2318037215f), new Float3(-0.08481269795f, -0.4404869674f, -0.03574965489f), new Float3(0.1822082075f, -0.3953259299f, 0.1140946023f), new Float3(-0.3269323334f, 0.3036542563f, 0.05838957105f), new Float3(-0.4080485344f, 0.04227858267f, -0.184956522f), new Float3(0.2676025294f, -0.01299671652f, 0.36155217f), new Float3(0.3024892441f, -0.1009990293f, -0.3174892964f), new Float3(0.1448494052f, 0.425921681f, -0.0104580805f), new Float3(0.4198402157f, 0.08062320474f, 0.1404780841f), new Float3(-0.3008872161f, -0.333040905f, -0.03241355801f), new Float3(0.3639310428f, -0.1291284382f, -0.2310412139f), new Float3(0.3295806598f, 0.0184175994f, -0.3058388149f), new Float3(0.2776259487f, -0.2974929052f, -0.1921504723f), new Float3(0.4149000507f, -0.144793182f, -0.09691688386f), new Float3(0.145016715f, -0.0398992945f, 0.4241205002f), new Float3(0.09299023471f, -0.299732164f, -0.3225111565f), new Float3(0.1028907093f, -0.361266869f, 0.247789732f), new Float3(0.2683057049f, -0.07076041213f, -0.3542668666f), new Float3(-0.4227307273f, -0.07933161816f, -0.1323073187f), new Float3(-0.1781224702f, 0.1806857196f, -0.3716517945f), new Float3(0.4390788626f, -0.02841848598f, -0.09435116353f), new Float3(0.2972583585f, 0.2382799621f, -0.2394997452f), new Float3(-0.1707002821f, 0.2215845691f, 0.3525077196f), new Float3(0.3806686614f, 0.1471852559f, -0.1895464869f), new Float3(-0.1751445661f, -0.274887877f, 0.3102596268f), new Float3(-0.2227237566f, -0.2316778837f, 0.3149912482f), new Float3(0.1369633021f, 0.1341343041f, -0.4071228836f), new Float3(-0.3529503428f, -0.2472893463f, -0.129514612f), new Float3(-0.2590744185f, -0.2985577559f, -0.2150435121f), new Float3(-0.3784019401f, 0.2199816631f, -0.1044989934f), new Float3(-0.05635805671f, 0.1485737441f, 0.4210102279f), new Float3(0.3251428613f, 0.09666046873f, -0.2957006485f), new Float3(-0.4190995804f, 0.1406751354f, -0.08405978803f), new Float3(-0.3253150961f, -0.3080335042f, -0.04225456877f), new Float3(0.2857945863f, -0.05796152095f, 0.3427271751f), new Float3(-0.2733604046f, 0.1973770973f, -0.2980207554f), new Float3(0.219003657f, 0.2410037886f, -0.3105713639f), new Float3(0.3182767252f, -0.271342949f, 0.1660509868f), new Float3(-0.03222023115f, -0.3331161506f, -0.300824678f), new Float3(-0.3087780231f, 0.1992794134f, -0.2596995338f), new Float3(-0.06487611647f, -0.4311322747f, 0.1114273361f), new Float3(0.3921171432f, -0.06294284106f, -0.2116183942f), new Float3(-0.1606404506f, -0.358928121f, -0.2187812825f), new Float3(-0.03767771199f, -0.2290351443f, 0.3855169162f), new Float3(0.1394866832f, -0.3602213994f, 0.2308332918f), new Float3(-0.4345093872f, 0.005751117145f, 0.1169124335f), new Float3(-0.1044637494f, 0.4168128432f, -0.1336202785f), new Float3(0.2658727501f, 0.2551943237f, 0.2582393035f), new Float3(0.2051461999f, 0.1975390727f, 0.3484154868f), new Float3(-0.266085566f, 0.23483312f, 0.2766800993f), new Float3(0.07849405464f, -0.3300346342f, -0.2956616708f), new Float3(-0.2160686338f, 0.05376451292f, -0.3910546287f), new Float3(-0.185779186f, 0.2148499206f, 0.3490352499f), new Float3(0.02492421743f, -0.3229954284f, -0.3123343347f), new Float3(-0.120167831f, 0.4017266681f, 0.1633259825f), new Float3(-0.02160084693f, -0.06885389554f, 0.4441762538f), new Float3(0.2597670064f, 0.3096300784f, 0.1978643903f), new Float3(-0.1611553854f, -0.09823036005f, 0.4085091653f), new Float3(-0.3278896792f, 0.1461670309f, 0.2713366126f), new Float3(0.2822734956f, 0.03754421121f, -0.3484423997f), new Float3(0.03169341113f, 0.347405252f, -0.2842624114f), new Float3(0.2202613604f, -0.3460788041f, -0.1849713341f), new Float3(0.2933396046f, 0.3031973659f, 0.1565989581f), new Float3(-0.3194922995f, 0.2453752201f, -0.200538455f), new Float3(-0.3441586045f, -0.1698856132f, -0.2349334659f), new Float3(0.2703645948f, -0.3574277231f, 0.04060059933f), new Float3(0.2298568861f, 0.3744156221f, 0.0973588921f), new Float3(0.09326603877f, -0.3170108894f, 0.3054595587f), new Float3(-0.1116165319f, -0.2985018719f, 0.3177080142f), new Float3(0.2172907365f, -0.3460005203f, -0.1885958001f), new Float3(0.1991339479f, 0.3820341668f, -0.1299829458f), new Float3(-0.0541918155f, -0.2103145071f, 0.39412061f), new Float3(0.08871336998f, 0.2012117383f, 0.3926114802f), new Float3(0.2787673278f, 0.3505404674f, 0.04370535101f), new Float3(-0.322166438f, 0.3067213525f, 0.06804996813f), new Float3(-0.4277366384f, 0.132066775f, 0.04582286686f), new Float3(0.240131882f, -0.1612516055f, 0.344723946f), new Float3(0.1448607981f, -0.2387819045f, 0.3528435224f), new Float3(-0.3837065682f, -0.2206398454f, 0.08116235683f), new Float3(-0.4382627882f, -0.09082753406f, -0.04664855374f), new Float3(-0.37728353f, 0.05445141085f, 0.2391488697f), new Float3(0.1259579313f, 0.348394558f, 0.2554522098f), new Float3(-0.1406285511f, -0.270877371f, -0.3306796947f), new Float3(-0.1580694418f, 0.4162931958f, -0.06491553533f), new Float3(0.2477612106f, -0.2927867412f, -0.2353514536f), new Float3(0.2916132853f, 0.3312535401f, 0.08793624968f), new Float3(0.07365265219f, -0.1666159848f, 0.411478311f), new Float3(-0.26126526f, -0.2422237692f, 0.2748965434f), new Float3(-0.3721862032f, 0.252790166f, 0.008634938242f), new Float3(-0.3691191571f, -0.255281188f, 0.03290232422f), new Float3(0.2278441737f, -0.3358364886f, 0.1944244981f), new Float3(0.363398169f, -0.2310190248f, 0.1306597909f), new Float3(-0.304231482f, -0.2698452035f, 0.1926830856f), new Float3(-0.3199312232f, 0.316332536f, -0.008816977938f), new Float3(0.2874852279f, 0.1642275508f, -0.304764754f), new Float3(-0.1451096801f, 0.3277541114f, -0.2720669462f), new Float3(0.3220090754f, 0.0511344108f, 0.3101538769f), new Float3(-0.1247400865f, -0.04333605335f, -0.4301882115f), new Float3(-0.2829555867f, -0.3056190617f, -0.1703910946f), new Float3(0.1069384374f, 0.3491024667f, -0.2630430352f), new Float3(-0.1420661144f, -0.3055376754f, -0.2982682484f), new Float3(-0.250548338f, 0.3156466809f, -0.2002316239f), new Float3(0.3265787872f, 0.1871229129f, 0.2466400438f), new Float3(0.07646097258f, -0.3026690852f, 0.324106687f), new Float3(0.3451771584f, 0.2757120714f, -0.0856480183f), new Float3(0.298137964f, 0.2852657134f, 0.179547284f), new Float3(0.2812250376f, 0.3466716415f, 0.05684409612f), new Float3(0.4390345476f, -0.09790429955f, -0.01278335452f), new Float3(0.2148373234f, 0.1850172527f, 0.3494474791f), new Float3(0.2595421179f, -0.07946825393f, 0.3589187731f), new Float3(0.3182823114f, -0.307355516f, -0.08203022006f), new Float3(-0.4089859285f, -0.04647718411f, 0.1818526372f), new Float3(-0.2826749061f, 0.07417482322f, 0.3421885344f), new Float3(0.3483864637f, 0.225442246f, -0.1740766085f), new Float3(-0.3226415069f, -0.1420585388f, -0.2796816575f), new Float3(0.4330734858f, -0.118868561f, -0.02859407492f), new Float3(-0.08717822568f, -0.3909896417f, -0.2050050172f), new Float3(-0.2149678299f, 0.3939973956f, -0.03247898316f), new Float3(-0.2687330705f, 0.322686276f, -0.1617284888f), new Float3(0.2105665099f, -0.1961317136f, -0.3459683451f), new Float3(0.4361845915f, -0.1105517485f, 0.004616608544f), new Float3(0.05333333359f, -0.313639498f, -0.3182543336f), new Float3(-0.05986216652f, 0.1361029153f, -0.4247264031f), new Float3(0.3664988455f, 0.2550543014f, -0.05590974511f), new Float3(-0.2341015558f, -0.182405731f, 0.3382670703f), new Float3(-0.04730947785f, -0.4222150243f, -0.1483114513f), new Float3(-0.2391566239f, -0.2577696514f, -0.2808182972f), new Float3(-0.1242081035f, 0.4256953395f, -0.07652336246f), new Float3(0.2614832715f, -0.3650179274f, 0.02980623099f), new Float3(-0.2728794681f, -0.3499628774f, 0.07458404908f), new Float3(0.007892900508f, -0.1672771315f, 0.4176793787f), new Float3(-0.01730330376f, 0.2978486637f, -0.3368779738f), new Float3(0.2054835762f, -0.3252600376f, -0.2334146693f), new Float3(-0.3231994983f, 0.1564282844f, -0.2712420987f), new Float3(-0.2669545963f, 0.2599343665f, -0.2523278991f), new Float3(-0.05554372779f, 0.3170813944f, -0.3144428146f), new Float3(-0.2083935713f, -0.310922837f, -0.2497981362f), new Float3(0.06989323478f, -0.3156141536f, 0.3130537363f), new Float3(0.3847566193f, -0.1605309138f, -0.1693876312f), new Float3(-0.3026215288f, -0.3001537679f, -0.1443188342f), new Float3(0.3450735512f, 0.08611519592f, 0.2756962409f), new Float3(0.1814473292f, -0.2788782453f, -0.3029914042f), new Float3(-0.03855010448f, 0.09795110726f, 0.4375151083f), new Float3(0.3533670318f, 0.2665752752f, 0.08105160988f), new Float3(-0.007945601311f, 0.140359426f, -0.4274764309f), new Float3(0.4063099273f, -0.1491768253f, -0.1231199324f), new Float3(-0.2016773589f, 0.008816271194f, -0.4021797064f), new Float3(-0.07527055435f, -0.425643481f, -0.1251477955f), }; - private static int FastFloor(float f) + private static int fastFloor(float f) { 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); } - 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); } - private static float InterpHermiteFunc(float t) + private static float interpHermiteFunc(float 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); } - 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); 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 ampFractal = 1; @@ -303,7 +303,7 @@ public class FastNoise private final static long Y_PRIME_L = 31337; 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; hash ^= X_PRIME * x; @@ -315,7 +315,7 @@ public class FastNoise 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; hash ^= X_PRIME * x; @@ -328,7 +328,7 @@ public class FastNoise 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; hash ^= X_PRIME * x; @@ -342,7 +342,7 @@ public class FastNoise 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; n ^= X_PRIME * x; @@ -351,7 +351,7 @@ public class FastNoise 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; n ^= X_PRIME_L * x; @@ -360,7 +360,7 @@ public class FastNoise 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; n ^= X_PRIME_L * x; @@ -370,7 +370,7 @@ public class FastNoise 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; n ^= X_PRIME * x; @@ -380,7 +380,7 @@ public class FastNoise 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; n ^= X_PRIME * x; @@ -638,7 +638,7 @@ public class FastNoise int zi = FloatCast2Int(z); 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) @@ -647,7 +647,7 @@ public class FastNoise int yi = FloatCast2Int(y); 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) @@ -655,7 +655,7 @@ public class FastNoise int xi = FloatCast2Int(x); 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) @@ -664,7 +664,7 @@ public class FastNoise long yi = DoubleCast2Long(y); 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) @@ -672,22 +672,22 @@ public class FastNoise long xi = DoubleCast2Long(x); 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) { - 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) { - return ValCoord3D(m_seed, x, y, z); + return valCoord3D(m_seed, x, y, z); } public float GetWhiteNoiseInt(int x, int y) { - return ValCoord2D(m_seed, x, y); + return valCoord2D(m_seed, x, y); } // Value Noise @@ -774,9 +774,9 @@ public class FastNoise private float SingleValue(int seed, float x, float y, float z) { - int x0 = FastFloor(x); - int y0 = FastFloor(y); - int z0 = FastFloor(z); + int x0 = fastFloor(x); + int y0 = fastFloor(y); + int z0 = fastFloor(z); int x1 = x0 + 1; int y1 = y0 + 1; int z1 = z0 + 1; @@ -791,26 +791,26 @@ public class FastNoise zs = z - z0; break; case Hermite: - xs = InterpHermiteFunc(x - x0); - ys = InterpHermiteFunc(y - y0); - zs = InterpHermiteFunc(z - z0); + xs = interpHermiteFunc(x - x0); + ys = interpHermiteFunc(y - y0); + zs = interpHermiteFunc(z - z0); break; case Quintic: - xs = InterpQuinticFunc(x - x0); - ys = InterpQuinticFunc(y - y0); - zs = InterpQuinticFunc(z - z0); + xs = interpQuinticFunc(x - x0); + ys = interpQuinticFunc(y - y0); + zs = interpQuinticFunc(z - z0); break; } - 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 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 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 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 yf0 = Lerp(xf00, xf10, ys); - float yf1 = Lerp(xf01, xf11, ys); + float yf0 = lerp(xf00, xf10, ys); + float yf1 = lerp(xf01, xf11, ys); - return Lerp(yf0, yf1, zs); + return lerp(yf0, yf1, zs); } public float GetValueFractal(float x, float y) @@ -891,8 +891,8 @@ public class FastNoise private float SingleValue(int seed, float x, float y) { - int x0 = FastFloor(x); - int y0 = FastFloor(y); + int x0 = fastFloor(x); + int y0 = fastFloor(y); int x1 = x0 + 1; int y1 = y0 + 1; @@ -905,19 +905,19 @@ public class FastNoise ys = y - y0; break; case Hermite: - xs = InterpHermiteFunc(x - x0); - ys = InterpHermiteFunc(y - y0); + xs = interpHermiteFunc(x - x0); + ys = interpHermiteFunc(y - y0); break; case Quintic: - xs = InterpQuinticFunc(x - x0); - ys = InterpQuinticFunc(y - y0); + xs = interpQuinticFunc(x - x0); + ys = interpQuinticFunc(y - y0); break; } - 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 xf0 = lerp(valCoord2D(seed, x0, y0), valCoord2D(seed, x1, y0), 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 @@ -1004,9 +1004,9 @@ public class FastNoise private float SinglePerlin(int seed, float x, float y, float z) { - int x0 = FastFloor(x); - int y0 = FastFloor(y); - int z0 = FastFloor(z); + int x0 = fastFloor(x); + int y0 = fastFloor(y); + int z0 = fastFloor(z); int x1 = x0 + 1; int y1 = y0 + 1; int z1 = z0 + 1; @@ -1021,14 +1021,14 @@ public class FastNoise zs = z - z0; break; case Hermite: - xs = InterpHermiteFunc(x - x0); - ys = InterpHermiteFunc(y - y0); - zs = InterpHermiteFunc(z - z0); + xs = interpHermiteFunc(x - x0); + ys = interpHermiteFunc(y - y0); + zs = interpHermiteFunc(z - z0); break; case Quintic: - xs = InterpQuinticFunc(x - x0); - ys = InterpQuinticFunc(y - y0); - zs = InterpQuinticFunc(z - z0); + xs = interpQuinticFunc(x - x0); + ys = interpQuinticFunc(y - y0); + zs = interpQuinticFunc(z - z0); break; } @@ -1039,15 +1039,15 @@ public class FastNoise float yd1 = yd0 - 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 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 xf11 = Lerp(GradCoord3D(seed, x0, y1, z1, xd0, yd1, zd1), GradCoord3D(seed, x1, y1, z1, xd1, yd1, zd1), 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 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 yf0 = Lerp(xf00, xf10, ys); - float yf1 = Lerp(xf01, xf11, ys); + float yf0 = lerp(xf00, xf10, ys); + float yf1 = lerp(xf01, xf11, ys); - return Lerp(yf0, yf1, zs); + return lerp(yf0, yf1, zs); } public float GetPerlinFractal(float x, float y) @@ -1129,8 +1129,8 @@ public class FastNoise private float SinglePerlin(int seed, float x, float y) { - int x0 = FastFloor(x); - int y0 = FastFloor(y); + int x0 = fastFloor(x); + int y0 = fastFloor(y); int x1 = x0 + 1; int y1 = y0 + 1; @@ -1143,12 +1143,12 @@ public class FastNoise ys = y - y0; break; case Hermite: - xs = InterpHermiteFunc(x - x0); - ys = InterpHermiteFunc(y - y0); + xs = interpHermiteFunc(x - x0); + ys = interpHermiteFunc(y - y0); break; case Quintic: - xs = InterpQuinticFunc(x - x0); - ys = InterpQuinticFunc(y - y0); + xs = interpQuinticFunc(x - x0); + ys = interpQuinticFunc(y - y0); break; } @@ -1157,10 +1157,10 @@ public class FastNoise float xd1 = xd0 - 1; float yd1 = yd0 - 1; - 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 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); - return Lerp(xf0, xf1, ys); + return lerp(xf0, xf1, ys); } // Simplex Noise @@ -1252,9 +1252,9 @@ public class FastNoise private float SingleSimplex(int seed, float x, float y, float z) { float t = (x + y + z) * F3; - int i = FastFloor(x + t); - int j = FastFloor(y + t); - int k = FastFloor(z + t); + int i = fastFloor(x + t); + int j = fastFloor(y + t); + int k = fastFloor(z + t); t = (i + j + k) * G3; float x0 = x - (i - t); @@ -1459,8 +1459,8 @@ public class FastNoise private float SingleSimplex(int seed, float x, float y) { float t = (x + y) * F2; - int i = FastFloor(x + t); - int j = FastFloor(y + t); + int i = fastFloor(x + t); + int j = fastFloor(y + t); t = (i + j) * G2; float X0 = i - t; @@ -1533,10 +1533,10 @@ public class FastNoise { float n0, n1, n2, n3, n4; float t = (x + y + z + w) * F4; - int i = FastFloor(x + t); - int j = FastFloor(y + t); - int k = FastFloor(z + t); - int l = FastFloor(w + t); + int i = fastFloor(x + t); + int j = fastFloor(y + t); + int k = fastFloor(z + t); + int l = fastFloor(w + t); t = (i + j + k + l) * G4; float X0 = i - t; float Y0 = j - t; @@ -1718,9 +1718,9 @@ public class FastNoise private float SingleCubic(int seed, float x, float y, float z) { - int x1 = FastFloor(x); - int y1 = FastFloor(y); - int z1 = FastFloor(z); + int x1 = fastFloor(x); + int y1 = fastFloor(y); + int z1 = fastFloor(z); int x0 = x1 - 1; int y0 = y1 - 1; @@ -1736,7 +1736,7 @@ public class FastNoise float ys = y - (float) y1; 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) @@ -1826,8 +1826,8 @@ public class FastNoise private float SingleCubic(int seed, float x, float y) { - int x1 = FastFloor(x); - int y1 = FastFloor(y); + int x1 = fastFloor(x); + int y1 = fastFloor(y); int x0 = x1 - 1; int y0 = y1 - 1; @@ -1839,7 +1839,7 @@ public class FastNoise float xs = x - (float) x1; 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 @@ -1862,9 +1862,9 @@ public class FastNoise private float SingleCellular(float x, float y, float z) { - int xr = FastRound(x); - int yr = FastRound(y); - int zr = FastRound(z); + int xr = fastRound(x); + int yr = fastRound(y); + int zr = fastRound(z); float distance = 999999; int xc = 0, yc = 0, zc = 0; @@ -1878,7 +1878,7 @@ public class FastNoise { 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 vecY = yi - y + vec.y; @@ -1904,7 +1904,7 @@ public class FastNoise { 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 vecY = yi - y + vec.y; @@ -1930,7 +1930,7 @@ public class FastNoise { 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 vecY = yi - y + vec.y; @@ -1954,10 +1954,10 @@ public class FastNoise switch(m_cellularReturnType) { case CellValue: - return ValCoord3D(0, xc, yc, zc); + return valCoord3D(0, xc, yc, zc); 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); case Distance: @@ -1969,9 +1969,9 @@ public class FastNoise private float SingleCellular2Edge(float x, float y, float z) { - int xr = FastRound(x); - int yr = FastRound(y); - int zr = FastRound(z); + int xr = fastRound(x); + int yr = fastRound(y); + int zr = fastRound(z); float distance = 999999; float distance2 = 999999; @@ -1985,7 +1985,7 @@ public class FastNoise { 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 vecY = yi - y + vec.y; @@ -2006,7 +2006,7 @@ public class FastNoise { 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 vecY = yi - y + vec.y; @@ -2027,7 +2027,7 @@ public class FastNoise { 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 vecY = yi - y + vec.y; @@ -2080,8 +2080,8 @@ public class FastNoise private float SingleCellular(float x, float y) { - int xr = FastRound(x); - int yr = FastRound(y); + int xr = fastRound(x); + int yr = fastRound(y); float distance = 999999; int xc = 0, yc = 0; @@ -2094,7 +2094,7 @@ public class FastNoise { 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 vecY = yi - y + vec.y; @@ -2115,7 +2115,7 @@ public class FastNoise { 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 vecY = yi - y + vec.y; @@ -2136,7 +2136,7 @@ public class FastNoise { 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 vecY = yi - y + vec.y; @@ -2157,10 +2157,10 @@ public class FastNoise switch(m_cellularReturnType) { case CellValue: - return ValCoord2D(0, xc, yc); + return valCoord2D(0, xc, yc); 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); case Distance: @@ -2172,8 +2172,8 @@ public class FastNoise private float SingleCellular2Edge(float x, float y) { - int xr = FastRound(x); - int yr = FastRound(y); + int xr = fastRound(x); + int yr = fastRound(y); float distance = 999999; float distance2 = 999999; @@ -2186,7 +2186,7 @@ public class FastNoise { 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 vecY = yi - y + vec.y; @@ -2203,7 +2203,7 @@ public class FastNoise { 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 vecY = yi - y + vec.y; @@ -2220,7 +2220,7 @@ public class FastNoise { 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 vecY = yi - y + vec.y; @@ -2278,9 +2278,9 @@ public class FastNoise float yf = v3.y * frequency; float zf = v3.z * frequency; - int x0 = FastFloor(xf); - int y0 = FastFloor(yf); - int z0 = FastFloor(zf); + int x0 = fastFloor(xf); + int y0 = fastFloor(yf); + int z0 = fastFloor(zf); int x1 = x0 + 1; int y1 = y0 + 1; int z1 = z0 + 1; @@ -2295,52 +2295,52 @@ public class FastNoise zs = zf - z0; break; case Hermite: - xs = InterpHermiteFunc(xf - x0); - ys = InterpHermiteFunc(yf - y0); - zs = InterpHermiteFunc(zf - z0); + xs = interpHermiteFunc(xf - x0); + ys = interpHermiteFunc(yf - y0); + zs = interpHermiteFunc(zf - z0); break; case Quintic: - xs = InterpQuinticFunc(xf - x0); - ys = InterpQuinticFunc(yf - y0); - zs = InterpQuinticFunc(zf - z0); + xs = interpQuinticFunc(xf - x0); + ys = interpQuinticFunc(yf - y0); + zs = interpQuinticFunc(zf - z0); break; } - Float3 vec0 = CELL_3D[Hash3D(seed, x0, y0, z0) & 255]; - Float3 vec1 = CELL_3D[Hash3D(seed, x1, y0, z0) & 255]; + Float3 vec0 = CELL_3D[hash3D(seed, x0, y0, z0) & 255]; + Float3 vec1 = CELL_3D[hash3D(seed, x1, y0, z0) & 255]; - float lx0x = Lerp(vec0.x, vec1.x, xs); - float ly0x = Lerp(vec0.y, vec1.y, xs); - float lz0x = Lerp(vec0.z, vec1.z, xs); + float lx0x = lerp(vec0.x, vec1.x, xs); + float ly0x = lerp(vec0.y, vec1.y, xs); + float lz0x = lerp(vec0.z, vec1.z, xs); - vec0 = CELL_3D[Hash3D(seed, x0, y1, z0) & 255]; - vec1 = CELL_3D[Hash3D(seed, x1, y1, z0) & 255]; + vec0 = CELL_3D[hash3D(seed, x0, y1, z0) & 255]; + vec1 = CELL_3D[hash3D(seed, x1, y1, z0) & 255]; - float lx1x = Lerp(vec0.x, vec1.x, xs); - float ly1x = Lerp(vec0.y, vec1.y, xs); - float lz1x = Lerp(vec0.z, vec1.z, xs); + float lx1x = lerp(vec0.x, vec1.x, xs); + float ly1x = lerp(vec0.y, vec1.y, xs); + float lz1x = lerp(vec0.z, vec1.z, xs); - float lx0y = Lerp(lx0x, lx1x, ys); - float ly0y = Lerp(ly0x, ly1x, ys); - float lz0y = Lerp(lz0x, lz1x, ys); + float lx0y = lerp(lx0x, lx1x, ys); + float ly0y = lerp(ly0x, ly1x, ys); + float lz0y = lerp(lz0x, lz1x, ys); - vec0 = CELL_3D[Hash3D(seed, x0, y0, z1) & 255]; - vec1 = CELL_3D[Hash3D(seed, x1, y0, z1) & 255]; + vec0 = CELL_3D[hash3D(seed, x0, y0, z1) & 255]; + vec1 = CELL_3D[hash3D(seed, x1, y0, z1) & 255]; - lx0x = Lerp(vec0.x, vec1.x, xs); - ly0x = Lerp(vec0.y, vec1.y, xs); - lz0x = Lerp(vec0.z, vec1.z, xs); + lx0x = lerp(vec0.x, vec1.x, xs); + ly0x = lerp(vec0.y, vec1.y, xs); + lz0x = lerp(vec0.z, vec1.z, xs); - vec0 = CELL_3D[Hash3D(seed, x0, y1, z1) & 255]; - vec1 = CELL_3D[Hash3D(seed, x1, y1, z1) & 255]; + vec0 = CELL_3D[hash3D(seed, x0, y1, z1) & 255]; + vec1 = CELL_3D[hash3D(seed, x1, y1, z1) & 255]; - lx1x = Lerp(vec0.x, vec1.x, xs); - ly1x = Lerp(vec0.y, vec1.y, xs); - lz1x = Lerp(vec0.z, vec1.z, xs); + lx1x = lerp(vec0.x, vec1.x, xs); + ly1x = lerp(vec0.y, vec1.y, xs); + lz1x = lerp(vec0.z, vec1.z, xs); - v3.x += Lerp(lx0y, Lerp(lx0x, lx1x, ys), zs) * perturbAmp; - v3.y += Lerp(ly0y, Lerp(ly0x, ly1x, ys), zs) * perturbAmp; - v3.z += Lerp(lz0y, Lerp(lz0x, lz1x, ys), zs) * perturbAmp; + v3.x += lerp(lx0y, lerp(lx0x, lx1x, ys), zs) * perturbAmp; + v3.y += lerp(ly0y, lerp(ly0x, ly1x, ys), zs) * perturbAmp; + v3.z += lerp(lz0y, lerp(lz0x, lz1x, ys), zs) * perturbAmp; } public void GradientPerturb(Vector2f v2) @@ -2369,8 +2369,8 @@ public class FastNoise float xf = v2.x * frequency; float yf = v2.y * frequency; - int x0 = FastFloor(xf); - int y0 = FastFloor(yf); + int x0 = fastFloor(xf); + int y0 = fastFloor(yf); int x1 = x0 + 1; int y1 = y0 + 1; @@ -2383,29 +2383,29 @@ public class FastNoise ys = yf - y0; break; case Hermite: - xs = InterpHermiteFunc(xf - x0); - ys = InterpHermiteFunc(yf - y0); + xs = interpHermiteFunc(xf - x0); + ys = interpHermiteFunc(yf - y0); break; case Quintic: - xs = InterpQuinticFunc(xf - x0); - ys = InterpQuinticFunc(yf - y0); + xs = interpQuinticFunc(xf - x0); + ys = interpQuinticFunc(yf - y0); break; } - Float2 vec0 = CELL_2D[Hash2D(seed, x0, y0) & 255]; - Float2 vec1 = CELL_2D[Hash2D(seed, x1, y0) & 255]; + Float2 vec0 = CELL_2D[hash2D(seed, x0, y0) & 255]; + Float2 vec1 = CELL_2D[hash2D(seed, x1, y0) & 255]; - float lx0x = Lerp(vec0.x, vec1.x, xs); - float ly0x = Lerp(vec0.y, vec1.y, xs); + float lx0x = lerp(vec0.x, vec1.x, xs); + float ly0x = lerp(vec0.y, vec1.y, xs); - vec0 = CELL_2D[Hash2D(seed, x0, y1) & 255]; - vec1 = CELL_2D[Hash2D(seed, x1, y1) & 255]; + vec0 = CELL_2D[hash2D(seed, x0, y1) & 255]; + vec1 = CELL_2D[hash2D(seed, x1, y1) & 255]; - float lx1x = Lerp(vec0.x, vec1.x, xs); - float ly1x = Lerp(vec0.y, vec1.y, xs); + float lx1x = lerp(vec0.x, vec1.x, xs); + float ly1x = lerp(vec0.y, vec1.y, xs); - v2.x += Lerp(lx0x, lx1x, ys) * perturbAmp; - v2.y += Lerp(ly0x, ly1x, ys) * perturbAmp; + v2.x += lerp(lx0x, lx1x, ys) * perturbAmp; + v2.y += lerp(ly0x, ly1x, ys) * perturbAmp; } } \ No newline at end of file diff --git a/src/main/java/com/volmit/iris/noise/FractalBillowPerlinNoise.java b/src/main/java/com/volmit/iris/noise/FractalBillowPerlinNoise.java index 3a8d836d3..11c4774ee 100644 --- a/src/main/java/com/volmit/iris/noise/FractalBillowPerlinNoise.java +++ b/src/main/java/com/volmit/iris/noise/FractalBillowPerlinNoise.java @@ -8,8 +8,8 @@ public class FractalBillowPerlinNoise implements NoiseGenerator, OctaveNoise { public FractalBillowPerlinNoise(long seed) { this.n = new FastNoise(new RNG(seed).imax()); - n.SetFractalOctaves(1); - n.SetFractalType(FractalType.Billow); + n.setFractalOctaves(1); + n.setFractalType(FractalType.Billow); } public double f(double v) { @@ -33,6 +33,6 @@ public class FractalBillowPerlinNoise implements NoiseGenerator, OctaveNoise { @Override public void setOctaves(int o) { - n.SetFractalOctaves(o); + n.setFractalOctaves(o); } } diff --git a/src/main/java/com/volmit/iris/noise/FractalBillowSimplexNoise.java b/src/main/java/com/volmit/iris/noise/FractalBillowSimplexNoise.java index 9d981f211..e5196f4e3 100644 --- a/src/main/java/com/volmit/iris/noise/FractalBillowSimplexNoise.java +++ b/src/main/java/com/volmit/iris/noise/FractalBillowSimplexNoise.java @@ -8,8 +8,8 @@ public class FractalBillowSimplexNoise implements NoiseGenerator, OctaveNoise { public FractalBillowSimplexNoise(long seed) { this.n = new FastNoise(new RNG(seed).imax()); - n.SetFractalOctaves(1); - n.SetFractalType(FractalType.Billow); + n.setFractalOctaves(1); + n.setFractalType(FractalType.Billow); } public double f(double v) { @@ -33,6 +33,6 @@ public class FractalBillowSimplexNoise implements NoiseGenerator, OctaveNoise { @Override public void setOctaves(int o) { - n.SetFractalOctaves(o); + n.setFractalOctaves(o); } } diff --git a/src/main/java/com/volmit/iris/noise/FractalCubicNoise.java b/src/main/java/com/volmit/iris/noise/FractalCubicNoise.java index 0e5e9fefb..15d4dca55 100644 --- a/src/main/java/com/volmit/iris/noise/FractalCubicNoise.java +++ b/src/main/java/com/volmit/iris/noise/FractalCubicNoise.java @@ -7,7 +7,7 @@ public class FractalCubicNoise implements NoiseGenerator { public FractalCubicNoise(long seed) { this.n = new FastNoise((int) seed); - n.SetFractalType(FractalType.Billow); + n.setFractalType(FractalType.Billow); } private double f(double n) { diff --git a/src/main/java/com/volmit/iris/noise/FractalFBMSimplexNoise.java b/src/main/java/com/volmit/iris/noise/FractalFBMSimplexNoise.java index 9723b60a1..e610d564d 100644 --- a/src/main/java/com/volmit/iris/noise/FractalFBMSimplexNoise.java +++ b/src/main/java/com/volmit/iris/noise/FractalFBMSimplexNoise.java @@ -8,8 +8,8 @@ public class FractalFBMSimplexNoise implements NoiseGenerator, OctaveNoise { public FractalFBMSimplexNoise(long seed) { this.n = new FastNoise(new RNG(seed).imax()); - n.SetFractalOctaves(1); - n.SetFractalType(FractalType.FBM); + n.setFractalOctaves(1); + n.setFractalType(FractalType.FBM); } public double f(double v) { @@ -33,6 +33,6 @@ public class FractalFBMSimplexNoise implements NoiseGenerator, OctaveNoise { @Override public void setOctaves(int o) { - n.SetFractalOctaves(o); + n.setFractalOctaves(o); } } diff --git a/src/main/java/com/volmit/iris/noise/FractalRigidMultiSimplexNoise.java b/src/main/java/com/volmit/iris/noise/FractalRigidMultiSimplexNoise.java index 911c61ec9..ed32edcd2 100644 --- a/src/main/java/com/volmit/iris/noise/FractalRigidMultiSimplexNoise.java +++ b/src/main/java/com/volmit/iris/noise/FractalRigidMultiSimplexNoise.java @@ -8,8 +8,8 @@ public class FractalRigidMultiSimplexNoise implements NoiseGenerator, OctaveNois public FractalRigidMultiSimplexNoise(long seed) { this.n = new FastNoise(new RNG(seed).imax()); - n.SetFractalOctaves(1); - n.SetFractalType(FractalType.RigidMulti); + n.setFractalOctaves(1); + n.setFractalType(FractalType.RigidMulti); } public double f(double v) { @@ -33,6 +33,6 @@ public class FractalRigidMultiSimplexNoise implements NoiseGenerator, OctaveNois @Override public void setOctaves(int o) { - n.SetFractalOctaves(o); + n.setFractalOctaves(o); } } diff --git a/src/main/java/com/volmit/iris/noise/GlobNoise.java b/src/main/java/com/volmit/iris/noise/GlobNoise.java index 00162c1ef..93152030d 100644 --- a/src/main/java/com/volmit/iris/noise/GlobNoise.java +++ b/src/main/java/com/volmit/iris/noise/GlobNoise.java @@ -5,9 +5,9 @@ public class GlobNoise implements NoiseGenerator { public GlobNoise(long seed) { this.n = new FastNoise((int) seed); - n.SetNoiseType(FastNoise.NoiseType.Cellular); - n.SetCellularReturnType(FastNoise.CellularReturnType.Distance2Div); - n.SetCellularDistanceFunction(FastNoise.CellularDistanceFunction.Natural); + n.setNoiseType(FastNoise.NoiseType.Cellular); + n.setCellularReturnType(FastNoise.CellularReturnType.Distance2Div); + n.setCellularDistanceFunction(FastNoise.CellularDistanceFunction.Natural); } private double f(double n) diff --git a/src/main/java/com/volmit/iris/noise/PerlinNoise.java b/src/main/java/com/volmit/iris/noise/PerlinNoise.java index 2c41ae05c..1cf158db2 100644 --- a/src/main/java/com/volmit/iris/noise/PerlinNoise.java +++ b/src/main/java/com/volmit/iris/noise/PerlinNoise.java @@ -8,7 +8,7 @@ public class PerlinNoise implements NoiseGenerator, OctaveNoise { public PerlinNoise(long seed) { this.n = new FastNoise(new RNG(seed).imax()); - n.SetNoiseType(FastNoise.NoiseType.Perlin); + n.setNoiseType(FastNoise.NoiseType.Perlin); octaves = 1; } diff --git a/src/main/java/com/volmit/iris/noise/SimplexNoise.java b/src/main/java/com/volmit/iris/noise/SimplexNoise.java index 4fb49ec75..ccb6bd1b3 100644 --- a/src/main/java/com/volmit/iris/noise/SimplexNoise.java +++ b/src/main/java/com/volmit/iris/noise/SimplexNoise.java @@ -8,7 +8,7 @@ public class SimplexNoise implements NoiseGenerator, OctaveNoise { public SimplexNoise(long seed) { this.n = new FastNoise(new RNG(seed).imax()); - n.SetNoiseType(FastNoise.NoiseType.Simplex); + n.setNoiseType(FastNoise.NoiseType.Simplex); octaves = 1; } diff --git a/src/main/java/com/volmit/iris/noise/VascularNoise.java b/src/main/java/com/volmit/iris/noise/VascularNoise.java index e64cd4085..192c3e8d4 100644 --- a/src/main/java/com/volmit/iris/noise/VascularNoise.java +++ b/src/main/java/com/volmit/iris/noise/VascularNoise.java @@ -7,9 +7,9 @@ public class VascularNoise implements NoiseGenerator { public VascularNoise(long seed) { this.n = new FastNoise((int) seed); - n.SetNoiseType(FastNoise.NoiseType.Cellular); - n.SetCellularReturnType(FastNoise.CellularReturnType.Distance2Sub); - n.SetCellularDistanceFunction(FastNoise.CellularDistanceFunction.Natural); + n.setNoiseType(FastNoise.NoiseType.Cellular); + n.setCellularReturnType(FastNoise.CellularReturnType.Distance2Sub); + n.setCellularDistanceFunction(FastNoise.CellularDistanceFunction.Natural); } private double filter(double noise) { diff --git a/src/main/java/com/volmit/iris/object/IrisObject.java b/src/main/java/com/volmit/iris/object/IrisObject.java index 3dc274bf3..44be8a5d9 100644 --- a/src/main/java/com/volmit/iris/object/IrisObject.java +++ b/src/main/java/com/volmit/iris/object/IrisObject.java @@ -31,7 +31,6 @@ import lombok.EqualsAndHashCode; @EqualsAndHashCode(callSuper = false) 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[] 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; @@ -469,12 +468,6 @@ public class IrisObject extends IrisRegistrant 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)); placer.set(vx, vy + 1, vz, SNOW_LAYERS[Math.max(Math.min(height, 7), 0)]); } diff --git a/src/main/java/com/volmit/iris/util/GroupedExecutor.java b/src/main/java/com/volmit/iris/util/GroupedExecutor.java index 459575254..b992acf81 100644 --- a/src/main/java/com/volmit/iris/util/GroupedExecutor.java +++ b/src/main/java/com/volmit/iris/util/GroupedExecutor.java @@ -6,8 +6,6 @@ import java.util.concurrent.ForkJoinPool; import java.util.concurrent.ForkJoinPool.ForkJoinWorkerThreadFactory; import java.util.concurrent.ForkJoinWorkerThread; -import com.volmit.iris.Iris; - public class GroupedExecutor { private int xc; @@ -73,21 +71,12 @@ public class GroupedExecutor return; } - PrecisionStopwatch s = PrecisionStopwatch.start(); - while(true) { if(mirror.get(g) == 0) { break; } - - if(s.getMilliseconds() > 30000) - { - Iris.warn("Couldn't unlock grouped task: " + g + "! Clearing Task Group Forcibly and timing out!"); - mirror.remove(g); - break; - } } }