mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-17 22:31:52 +00:00
reformat
This commit is contained in:
@@ -14,10 +14,6 @@ group = "com.dfsek.terra.common"
|
||||
|
||||
dependencies {
|
||||
"shadedApi"(project(":common:api"))
|
||||
|
||||
|
||||
|
||||
|
||||
"compileOnly"("com.google.guava:guava:30.0-jre")
|
||||
|
||||
"testImplementation"("com.google.guava:guava:30.0-jre")
|
||||
|
||||
+2
-2
@@ -60,13 +60,13 @@ public class NoiseAddon extends TerraAddon implements EventListener {
|
||||
.applyLoader(CellularSampler.ReturnType.class, (t, object, cf) -> CellularSampler.ReturnType.valueOf((String) object))
|
||||
.applyLoader(CellularSampler.DistanceFunction.class, (t, object, cf) -> CellularSampler.DistanceFunction.valueOf((String) object));
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void packPreLoad(ConfigPackPreLoadEvent event) {
|
||||
CheckedRegistry<NoiseProvider> noiseRegistry = event.getPack().getOrCreateRegistry(NoiseProvider.class);
|
||||
event.getPack()
|
||||
.applyLoader(NoiseSeeded.class, new NoiseSamplerBuilderLoader(noiseRegistry));
|
||||
|
||||
|
||||
noiseRegistry.registerUnchecked("LINEAR", LinearNormalizerTemplate::new);
|
||||
noiseRegistry.registerUnchecked("NORMAL", NormalNormalizerTemplate::new);
|
||||
noiseRegistry.registerUnchecked("CLAMP", ClampNormalizerTemplate::new);
|
||||
|
||||
-1
@@ -2,7 +2,6 @@ package com.dfsek.terra.addons.noise;
|
||||
|
||||
import com.dfsek.tectonic.annotations.Value;
|
||||
import com.dfsek.tectonic.config.ConfigTemplate;
|
||||
import com.dfsek.terra.api.config.ConfigType;
|
||||
import com.dfsek.terra.api.util.seeded.NoiseSeeded;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
+1
-5
@@ -24,23 +24,19 @@ import java.util.Map;
|
||||
|
||||
@SuppressWarnings({"FieldMayBeFinal", "unused"})
|
||||
public class ExpressionFunctionTemplate extends SamplerTemplate<ExpressionFunction> implements ValidatedConfigTemplate {
|
||||
private final Map<String, NoiseSeeded> otherFunctions;
|
||||
@Value("variables")
|
||||
@Default
|
||||
private Map<String, Double> vars = new HashMap<>();
|
||||
|
||||
@Value("equation")
|
||||
private String equation;
|
||||
|
||||
@Value("functions")
|
||||
@Default
|
||||
private LinkedHashMap<String, NoiseSeeded> functions = new LinkedHashMap<>();
|
||||
|
||||
@Value("expressions")
|
||||
@Default
|
||||
private LinkedHashMap<String, FunctionTemplate> expressions = new LinkedHashMap<>();
|
||||
|
||||
private final Map<String, NoiseSeeded> otherFunctions;
|
||||
|
||||
public ExpressionFunctionTemplate(Map<String, NoiseSeeded> otherFunctions) {
|
||||
this.otherFunctions = otherFunctions;
|
||||
}
|
||||
|
||||
+8
-9
@@ -17,6 +17,14 @@ public class UserDefinedFunction implements DynamicFunction {
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
public static UserDefinedFunction newInstance(FunctionTemplate template, Parser parser, Scope parent) throws ParseException {
|
||||
|
||||
Scope functionScope = new Scope().withParent(parent);
|
||||
|
||||
template.getArgs().forEach(functionScope::addInvocationVariable);
|
||||
|
||||
return new UserDefinedFunction(parser.parse(template.getFunction(), functionScope), template.getArgs().size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public double eval(double... args) {
|
||||
@@ -32,13 +40,4 @@ public class UserDefinedFunction implements DynamicFunction {
|
||||
public int getArgNumber() {
|
||||
return args;
|
||||
}
|
||||
|
||||
public static UserDefinedFunction newInstance(FunctionTemplate template, Parser parser, Scope parent) throws ParseException {
|
||||
|
||||
Scope functionScope = new Scope().withParent(parent);
|
||||
|
||||
template.getArgs().forEach(functionScope::addInvocationVariable);
|
||||
|
||||
return new UserDefinedFunction(parser.parse(template.getFunction(), functionScope), template.getArgs().size());
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,9 +1,9 @@
|
||||
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.vector.Vector2;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.addons.noise.samplers.noise.simplex.OpenSimplex2Sampler;
|
||||
|
||||
/**
|
||||
* NoiseSampler implementation for Cellular (Voronoi/Worley) Noise.
|
||||
|
||||
+8
-12
@@ -9,7 +9,15 @@ public abstract class NoiseFunction implements NoiseSampler {
|
||||
protected static final int PRIME_X = 501125321;
|
||||
protected static final int PRIME_Y = 1136930381;
|
||||
protected static final int PRIME_Z = 1720413743;
|
||||
static final int precision = 100;
|
||||
static final int modulus = 360 * precision;
|
||||
static final double[] sin = new double[360 * 100]; // lookup table
|
||||
|
||||
static {
|
||||
for(int i = 0; i < sin.length; i++) {
|
||||
sin[i] = (float) Math.sin((double) (i) / (precision));
|
||||
}
|
||||
}
|
||||
|
||||
protected double frequency = 0.02d;
|
||||
protected int seed;
|
||||
@@ -22,8 +30,6 @@ public abstract class NoiseFunction implements NoiseSampler {
|
||||
return f >= 0 ? (int) f : (int) f - 1;
|
||||
}
|
||||
|
||||
static final int precision = 100;
|
||||
|
||||
protected static int hash(int seed, int xPrimed, int yPrimed, int zPrimed) {
|
||||
int hash = seed ^ xPrimed ^ yPrimed ^ zPrimed;
|
||||
|
||||
@@ -38,8 +44,6 @@ public abstract class NoiseFunction implements NoiseSampler {
|
||||
return hash;
|
||||
}
|
||||
|
||||
static final int modulus = 360 * precision;
|
||||
|
||||
protected static int fastRound(double f) {
|
||||
return f >= 0 ? (int) (f + 0.5f) : (int) (f - 0.5);
|
||||
}
|
||||
@@ -77,14 +81,6 @@ public abstract class NoiseFunction implements NoiseSampler {
|
||||
return FastMath.sqrt(f);
|
||||
}
|
||||
|
||||
static final double[] sin = new double[360 * 100]; // lookup table
|
||||
|
||||
static {
|
||||
for(int i = 0; i < sin.length; i++) {
|
||||
sin[i] = (float) Math.sin((double) (i) / (precision));
|
||||
}
|
||||
}
|
||||
|
||||
protected static int fastCeil(double f) {
|
||||
int i = (int) f;
|
||||
if(i < f) i++;
|
||||
|
||||
Reference in New Issue
Block a user