mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-10 09:46:24 +00:00
Per-world noise gen is no longer dumb
This commit is contained in:
29
src/main/java/com/dfsek/terra/math/BlankFunction.java
Normal file
29
src/main/java/com/dfsek/terra/math/BlankFunction.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package com.dfsek.terra.math;
|
||||
|
||||
import parsii.eval.Expression;
|
||||
import parsii.eval.Function;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BlankFunction implements Function {
|
||||
private final int args;
|
||||
|
||||
public BlankFunction(int args) {
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumberOfArguments() {
|
||||
return args;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double eval(List<Expression> list) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNaturalFunction() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -3,5 +3,4 @@ package com.dfsek.terra.math;
|
||||
import parsii.eval.Function;
|
||||
|
||||
public interface NoiseFunction extends Function {
|
||||
void setNoise(long seed);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.dfsek.terra.math;
|
||||
|
||||
import com.dfsek.terra.config.base.ConfigUtil;
|
||||
import com.dfsek.terra.generation.config.NoiseBuilder;
|
||||
import org.bukkit.World;
|
||||
import org.polydev.gaea.math.FastNoiseLite;
|
||||
import parsii.eval.Expression;
|
||||
|
||||
@@ -9,11 +10,10 @@ import java.util.List;
|
||||
|
||||
public class NoiseFunction2 implements NoiseFunction {
|
||||
private final Cache cache = new Cache();
|
||||
private FastNoiseLite gen;
|
||||
private final NoiseBuilder builder;
|
||||
private final FastNoiseLite gen;
|
||||
|
||||
public NoiseFunction2(NoiseBuilder builder) {
|
||||
this.builder = builder;
|
||||
public NoiseFunction2(World world, NoiseBuilder builder) {
|
||||
this.gen = builder.build((int) world.getSeed());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -31,11 +31,6 @@ public class NoiseFunction2 implements NoiseFunction {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNoise(long seed) {
|
||||
this.gen = builder.build((int) seed);
|
||||
}
|
||||
|
||||
private final class Cache {
|
||||
private final double[] cacheX = new double[ConfigUtil.cacheSize];
|
||||
private final double[] cacheZ = new double[ConfigUtil.cacheSize];
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
package com.dfsek.terra.math;
|
||||
|
||||
import com.dfsek.terra.generation.config.NoiseBuilder;
|
||||
import org.bukkit.World;
|
||||
import org.polydev.gaea.math.FastNoiseLite;
|
||||
import parsii.eval.Expression;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class NoiseFunction3 implements NoiseFunction {
|
||||
private FastNoiseLite gen;
|
||||
private final NoiseBuilder builder;
|
||||
private final FastNoiseLite gen;
|
||||
|
||||
public NoiseFunction3(NoiseBuilder builder) {
|
||||
this.builder = builder;
|
||||
public NoiseFunction3(World world, NoiseBuilder builder) {
|
||||
this.gen = builder.build((int) world.getSeed());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -28,9 +28,4 @@ public class NoiseFunction3 implements NoiseFunction {
|
||||
public boolean isNaturalFunction() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNoise(long seed) {
|
||||
this.gen = builder.build((int) seed);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user