mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-02-16 10:30:42 +00:00
getNoiseSeeded -> noise
This commit is contained in:
@@ -46,8 +46,8 @@ public class BiomePipelineProvider implements BiomeProvider {
|
||||
|
||||
@Override
|
||||
public TerraBiome getBiome(int x, int z, long seed) {
|
||||
x += mutator.getNoiseSeeded(seed + 1, x, z) * noiseAmp;
|
||||
z += mutator.getNoiseSeeded(seed + 2, x, z) * noiseAmp;
|
||||
x += mutator.noise(seed + 1, x, z) * noiseAmp;
|
||||
z += mutator.noise(seed + 2, x, z) * noiseAmp;
|
||||
|
||||
|
||||
x = FastMath.floorToInt(FastMath.floorDiv(x, resolution));
|
||||
@@ -82,9 +82,8 @@ public class BiomePipelineProvider implements BiomeProvider {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(!(obj instanceof SeededVector)) return false;
|
||||
SeededVector that = (SeededVector) obj;
|
||||
|
||||
if(!(obj instanceof SeededVector that)) return false;
|
||||
|
||||
return this.seed == that.seed && this.x == that.x && this.z == that.z;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,6 @@ public class FractalExpander implements BiomeExpander {
|
||||
|
||||
@Override
|
||||
public TerraBiome getBetween(double x, double z, long seed, TerraBiome... others) {
|
||||
return others[MathUtil.normalizeIndex(sampler.getNoiseSeeded(seed, x, z), others.length)];
|
||||
return others[MathUtil.normalizeIndex(sampler.noise(seed, x, z), others.length)];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class SmoothMutator implements BiomeMutator {
|
||||
boolean horiz = Objects.equals(left, right) && left != null;
|
||||
|
||||
if(vert && horiz) {
|
||||
return MathUtil.normalizeIndex(sampler.getNoiseSeeded(seed, x, z), 2) == 0 ? left : top;
|
||||
return MathUtil.normalizeIndex(sampler.noise(seed, x, z), 2) == 0 ? left : top;
|
||||
}
|
||||
|
||||
if(vert) return top;
|
||||
|
||||
@@ -37,7 +37,7 @@ public class ElevationInterpolator {
|
||||
for(int xi = -smooth; xi <= smooth; xi++) {
|
||||
for(int zi = -smooth; zi <= smooth; zi++) {
|
||||
GenerationSettings gen = gens[x + 1 + smooth + xi][z + 1 + smooth + zi];
|
||||
noise += gen.getElevationSampler().getNoiseSeeded(seed, xOrigin + x, zOrigin + z) * gen.getElevationWeight();
|
||||
noise += gen.getElevationSampler().noise(seed, xOrigin + x, zOrigin + z) * gen.getElevationWeight();
|
||||
div += gen.getElevationWeight();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public class Sampler3D implements Sampler {
|
||||
|
||||
public Sampler3D(int x, int z, BiomeProvider provider, World world, int elevationSmooth) {
|
||||
this.interpolator = new ChunkInterpolator3D(world, x, z, provider, (generator, coord) -> generator.getBaseSampler()
|
||||
.getNoiseSeeded(coord,
|
||||
.noise(coord,
|
||||
world.getSeed()));
|
||||
this.elevationInterpolator = new ElevationInterpolator(world, x, z, provider, elevationSmooth);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,6 @@ public class NoiseDistributor implements Distributor {
|
||||
|
||||
@Override
|
||||
public boolean matches(int x, int z, long seed) {
|
||||
return sampler.getNoiseSeeded(seed, x, z) > threshold;
|
||||
return sampler.noise(seed, x, z) > threshold;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public class Noise3DLocator implements Locator {
|
||||
int x = column.getX();
|
||||
int z = column.getZ();
|
||||
column.forEach(y -> {
|
||||
if(sampler.getNoiseSeeded(seed, x, y, z) > 0) results.set(y);
|
||||
if(sampler.noise(seed, x, y, z) > 0) results.set(y);
|
||||
});
|
||||
return results;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class NoiseLocator implements Locator {
|
||||
|
||||
long seed = column.getWorld().getSeed();
|
||||
samplers.forEach(sampler -> {
|
||||
int y = FastMath.floorToInt(sampler.getNoiseSeeded(seed, column.getX(), column.getX()));
|
||||
int y = FastMath.floorToInt(sampler.noise(seed, column.getX(), column.getX()));
|
||||
if(y >= column.getMaxY() || y < column.getMinY()) return;
|
||||
results.set(y);
|
||||
});
|
||||
|
||||
@@ -20,12 +20,12 @@ public abstract class Normalizer implements NoiseSampler {
|
||||
public abstract double normalize(double in);
|
||||
|
||||
@Override
|
||||
public double getNoiseSeeded(long seed, double x, double y) {
|
||||
return normalize(sampler.getNoiseSeeded(seed, x, y));
|
||||
public double noise(long seed, double x, double y) {
|
||||
return normalize(sampler.noise(seed, x, y));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getNoiseSeeded(long seed, double x, double y, double z) {
|
||||
return normalize(sampler.getNoiseSeeded(seed, x, y, z));
|
||||
public double noise(long seed, double x, double y, double z) {
|
||||
return normalize(sampler.noise(seed, x, y, z));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public class NoiseFunction2 implements DynamicFunction {
|
||||
|
||||
@Override
|
||||
public double eval(Context context, double... args) {
|
||||
return gen.getNoiseSeeded(((SeedContext) context).getSeed(), args[0], args[1]);
|
||||
return gen.noise(((SeedContext) context).getSeed(), args[0], args[1]);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -28,7 +28,7 @@ public class NoiseFunction3 implements DynamicFunction {
|
||||
|
||||
@Override
|
||||
public double eval(Context context, double... args) {
|
||||
return gen.getNoiseSeeded(((SeedContext) context).getSeed(), args[0], args[1], args[2]);
|
||||
return gen.noise(((SeedContext) context).getSeed(), args[0], args[1], args[2]);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,19 +22,19 @@ public class DomainWarpedSampler implements NoiseSampler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getNoiseSeeded(long seed, double x, double y) {
|
||||
return function.getNoiseSeeded(seed++,
|
||||
x + warp.getNoiseSeeded(seed++, x, y) * amplitude,
|
||||
y + warp.getNoiseSeeded(seed, x, y) * amplitude
|
||||
);
|
||||
public double noise(long seed, double x, double y) {
|
||||
return function.noise(seed++,
|
||||
x + warp.noise(seed++, x, y) * amplitude,
|
||||
y + warp.noise(seed, x, y) * amplitude
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getNoiseSeeded(long seed, double x, double y, double z) {
|
||||
return function.getNoiseSeeded(seed++,
|
||||
x + warp.getNoiseSeeded(seed++, x, y, z) * amplitude,
|
||||
y + warp.getNoiseSeeded(seed++, x, y, z) * amplitude,
|
||||
z + warp.getNoiseSeeded(seed, x, y, z) * amplitude
|
||||
);
|
||||
public double noise(long seed, double x, double y, double z) {
|
||||
return function.noise(seed++,
|
||||
x + warp.noise(seed++, x, y, z) * amplitude,
|
||||
y + warp.noise(seed++, x, y, z) * amplitude,
|
||||
z + warp.noise(seed, x, y, z) * amplitude
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,15 +27,15 @@ public class ImageSampler implements NoiseSampler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getNoiseSeeded(long seed, double x, double y) {
|
||||
public double noise(long seed, double x, double y) {
|
||||
return ((channel.getChannel(image.getRGB(FastMath.floorMod(FastMath.floorToInt(x * frequency), image.getWidth()),
|
||||
FastMath.floorMod(FastMath.floorToInt(y * frequency), image.getHeight()))) / 255D) - 0.5) *
|
||||
2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getNoiseSeeded(long seed, double x, double y, double z) {
|
||||
return getNoiseSeeded(seed, x, y);
|
||||
public double noise(long seed, double x, double y, double z) {
|
||||
return noise(seed, x, y);
|
||||
}
|
||||
|
||||
public enum Channel {
|
||||
|
||||
@@ -25,14 +25,14 @@ public class KernelSampler implements NoiseSampler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getNoiseSeeded(long seed, double x, double y) {
|
||||
public double noise(long seed, double x, double y) {
|
||||
x *= frequency;
|
||||
y *= frequency;
|
||||
double accumulator = 0;
|
||||
|
||||
for(int kx = 0; kx < kernel.length; kx++) {
|
||||
for(int ky = 0; ky < kernel[kx].length; ky++) {
|
||||
accumulator += in.getNoiseSeeded(seed, x + kx, y + ky) * kernel[kx][ky];
|
||||
accumulator += in.noise(seed, x + kx, y + ky) * kernel[kx][ky];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class KernelSampler implements NoiseSampler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getNoiseSeeded(long seed, double x, double y, double z) {
|
||||
public double noise(long seed, double x, double y, double z) {
|
||||
x *= frequency;
|
||||
y *= frequency;
|
||||
z *= frequency;
|
||||
@@ -48,7 +48,7 @@ public class KernelSampler implements NoiseSampler {
|
||||
|
||||
for(int kx = 0; kx < kernel.length; kx++) {
|
||||
for(int ky = 0; ky < kernel[kx].length; ky++) {
|
||||
accumulator += in.getNoiseSeeded(seed, x + kx, y, z + ky) * kernel[kx][ky];
|
||||
accumulator += in.noise(seed, x + kx, y, z + ky) * kernel[kx][ky];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ package com.dfsek.terra.addons.noise.samplers.noise;
|
||||
|
||||
import com.dfsek.terra.addons.noise.samplers.noise.simplex.OpenSimplex2Sampler;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.util.vector.Vector2;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
|
||||
|
||||
@@ -350,7 +349,7 @@ public class CellularSampler extends NoiseFunction {
|
||||
case Distance2Sub -> distance1 - distance0 - 1;
|
||||
case Distance2Mul -> distance1 * distance0 * 0.5 - 1;
|
||||
case Distance2Div -> distance0 / distance1 - 1;
|
||||
case NoiseLookup -> noiseLookup.getNoiseSeeded(sl, centerX, centerY);
|
||||
case NoiseLookup -> noiseLookup.noise(sl, centerX, centerY);
|
||||
case Distance3 -> distance2 - 1;
|
||||
case Distance3Add -> (distance2 + distance0) * 0.5 - 1;
|
||||
case Distance3Sub -> distance2 - distance0 - 1;
|
||||
@@ -510,7 +509,7 @@ public class CellularSampler extends NoiseFunction {
|
||||
case Distance2Sub -> distance1 - distance0 - 1;
|
||||
case Distance2Mul -> distance1 * distance0 * 0.5 - 1;
|
||||
case Distance2Div -> distance0 / distance1 - 1;
|
||||
case NoiseLookup -> noiseLookup.getNoiseSeeded(sl, center.getX(), center.getY(), center.getZ());
|
||||
case NoiseLookup -> noiseLookup.noise(sl, center.getX(), center.getY(), center.getZ());
|
||||
case Distance3 -> distance2 - 1;
|
||||
case Distance3Add -> (distance2 + distance0) * 0.5 - 1;
|
||||
case Distance3Sub -> distance2 - distance0 - 1;
|
||||
|
||||
@@ -135,12 +135,12 @@ public abstract class NoiseFunction implements NoiseSampler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getNoiseSeeded(long seed, double x, double y) {
|
||||
public double noise(long seed, double x, double y) {
|
||||
return getNoiseRaw(seed + salt, x * frequency, y * frequency);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getNoiseSeeded(long seed, double x, double y, double z) {
|
||||
public double noise(long seed, double x, double y, double z) {
|
||||
return getNoiseRaw(seed + salt, x * frequency, y * frequency, z * frequency);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ public class BrownianMotionSampler extends FractalNoiseFunction {
|
||||
double amp = fractalBounding;
|
||||
|
||||
for(int i = 0; i < octaves; i++) {
|
||||
double noise = input.getNoiseSeeded(seed++, x, y);
|
||||
double noise = input.noise(seed++, x, y);
|
||||
sum += noise * amp;
|
||||
amp *= lerp(1.0, fastMin(noise + 1, 2) * 0.5, weightedStrength);
|
||||
|
||||
@@ -39,7 +39,7 @@ public class BrownianMotionSampler extends FractalNoiseFunction {
|
||||
double amp = fractalBounding;
|
||||
|
||||
for(int i = 0; i < octaves; i++) {
|
||||
double noise = input.getNoiseSeeded(seed++, x, y, z);
|
||||
double noise = input.noise(seed++, x, y, z);
|
||||
sum += noise * amp;
|
||||
amp *= lerp(1.0, (noise + 1) * 0.5, weightedStrength);
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ public class PingPongSampler extends FractalNoiseFunction {
|
||||
double amp = fractalBounding;
|
||||
|
||||
for(int i = 0; i < octaves; i++) {
|
||||
double noise = pingPong((input.getNoiseSeeded(seed++, x, y) + 1) * pingPongStrength);
|
||||
double noise = pingPong((input.noise(seed++, x, y) + 1) * pingPongStrength);
|
||||
sum += (noise - 0.5) * 2 * amp;
|
||||
amp *= lerp(1.0, noise, weightedStrength);
|
||||
|
||||
@@ -51,7 +51,7 @@ public class PingPongSampler extends FractalNoiseFunction {
|
||||
double amp = fractalBounding;
|
||||
|
||||
for(int i = 0; i < octaves; i++) {
|
||||
double noise = pingPong((input.getNoiseSeeded(seed++, x, y, z) + 1) * pingPongStrength);
|
||||
double noise = pingPong((input.noise(seed++, x, y, z) + 1) * pingPongStrength);
|
||||
sum += (noise - 0.5) * 2 * amp;
|
||||
amp *= lerp(1.0, noise, weightedStrength);
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ public class RidgedFractalSampler extends FractalNoiseFunction {
|
||||
double amp = fractalBounding;
|
||||
|
||||
for(int i = 0; i < octaves; i++) {
|
||||
double noise = fastAbs(input.getNoiseSeeded(seed++, x, y));
|
||||
double noise = fastAbs(input.noise(seed++, x, y));
|
||||
sum += (noise * -2 + 1) * amp;
|
||||
amp *= lerp(1.0, 1 - noise, weightedStrength);
|
||||
|
||||
@@ -40,7 +40,7 @@ public class RidgedFractalSampler extends FractalNoiseFunction {
|
||||
double amp = fractalBounding;
|
||||
|
||||
for(int i = 0; i < octaves; i++) {
|
||||
double noise = fastAbs(input.getNoiseSeeded(seed++, x, y, z));
|
||||
double noise = fastAbs(input.noise(seed++, x, y, z));
|
||||
sum += (noise * -2 + 1) * amp;
|
||||
amp *= lerp(1.0, 1 - noise, weightedStrength);
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@ public class GaussianNoiseSampler extends NoiseFunction {
|
||||
public double getNoiseRaw(long seed, double x, double y) {
|
||||
double v1, v2, s;
|
||||
do {
|
||||
v1 = whiteNoiseSampler.getNoiseSeeded(seed++, x, y);
|
||||
v2 = whiteNoiseSampler.getNoiseSeeded(seed++, x, y);
|
||||
v1 = whiteNoiseSampler.noise(seed++, x, y);
|
||||
v2 = whiteNoiseSampler.noise(seed++, x, y);
|
||||
s = v1 * v1 + v2 * v2;
|
||||
} while(s >= 1 || s == 0);
|
||||
double multiplier = StrictMath.sqrt(-2 * StrictMath.log(s) / s);
|
||||
@@ -36,8 +36,8 @@ public class GaussianNoiseSampler extends NoiseFunction {
|
||||
public double getNoiseRaw(long seed, double x, double y, double z) {
|
||||
double v1, v2, s;
|
||||
do {
|
||||
v1 = whiteNoiseSampler.getNoiseSeeded(seed++, x, y, z);
|
||||
v2 = whiteNoiseSampler.getNoiseSeeded(seed++, x, y, z);
|
||||
v1 = whiteNoiseSampler.noise(seed++, x, y, z);
|
||||
v2 = whiteNoiseSampler.noise(seed++, x, y, z);
|
||||
s = v1 * v1 + v2 * v2;
|
||||
} while(s >= 1 || s == 0);
|
||||
double multiplier = StrictMath.sqrt(-2 * StrictMath.log(s) / s);
|
||||
|
||||
@@ -49,13 +49,13 @@ public class ProbabilityCollection<E> implements Collection<E> {
|
||||
@SuppressWarnings("unchecked")
|
||||
public E get(NoiseSampler n, double x, double y, double z, long seed) {
|
||||
if(array.length == 0) return null;
|
||||
return (E) array[MathUtil.normalizeIndex(n.getNoiseSeeded(seed, x, y, z), array.length)];
|
||||
return (E) array[MathUtil.normalizeIndex(n.noise(seed, x, y, z), array.length)];
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public E get(NoiseSampler n, double x, double z, long seed) {
|
||||
if(array.length == 0) return null;
|
||||
return (E) array[MathUtil.normalizeIndex(n.getNoiseSeeded(seed, x, z), array.length)];
|
||||
return (E) array[MathUtil.normalizeIndex(n.noise(seed, x, z), array.length)];
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@@ -18,35 +18,35 @@ public interface NoiseSampler {
|
||||
static NoiseSampler zero() {
|
||||
return new NoiseSampler() {
|
||||
@Override
|
||||
public double getNoiseSeeded(long seed, double x, double y) {
|
||||
public double noise(long seed, double x, double y) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getNoiseSeeded(long seed, double x, double y, double z) {
|
||||
public double noise(long seed, double x, double y, double z) {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
default double getNoiseSeeded(Vector3 vector3, long seed) {
|
||||
return getNoiseSeeded(seed, vector3.getX(), vector3.getY(), vector3.getZ());
|
||||
default double noise(Vector3 vector3, long seed) {
|
||||
return noise(seed, vector3.getX(), vector3.getY(), vector3.getZ());
|
||||
}
|
||||
|
||||
default double getNoiseSeeded(Vector3Int vector3, long seed) {
|
||||
return getNoiseSeeded(seed, vector3.getX(), vector3.getY(), vector3.getZ());
|
||||
default double noise(Vector3Int vector3, long seed) {
|
||||
return noise(seed, vector3.getX(), vector3.getY(), vector3.getZ());
|
||||
}
|
||||
|
||||
|
||||
default double getNoiseSeeded(Vector2 vector2, long seed) {
|
||||
return getNoiseSeeded(seed, vector2.getX(), vector2.getZ());
|
||||
default double noise(Vector2 vector2, long seed) {
|
||||
return noise(seed, vector2.getX(), vector2.getZ());
|
||||
}
|
||||
|
||||
default double getNoiseSeeded(Vector2Int vector2, long seed) {
|
||||
return getNoiseSeeded(seed, vector2.getX(), vector2.getZ());
|
||||
default double noise(Vector2Int vector2, long seed) {
|
||||
return noise(seed, vector2.getX(), vector2.getZ());
|
||||
}
|
||||
|
||||
double getNoiseSeeded(long seed, double x, double y);
|
||||
double noise(long seed, double x, double y);
|
||||
|
||||
double getNoiseSeeded(long seed, double x, double y, double z);
|
||||
double noise(long seed, double x, double y, double z);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user