mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-04 00:45:57 +00:00
remove unused class ExpressionSampler
This commit is contained in:
parent
f0441cbefc
commit
96b52f9a3e
@ -1,58 +0,0 @@
|
|||||||
package com.dfsek.terra.addons.noise.samplers;
|
|
||||||
|
|
||||||
import com.dfsek.paralithic.Expression;
|
|
||||||
import com.dfsek.paralithic.eval.parser.Parser;
|
|
||||||
import com.dfsek.paralithic.eval.parser.Scope;
|
|
||||||
import com.dfsek.paralithic.eval.tokenizer.ParseException;
|
|
||||||
import com.dfsek.terra.addons.noise.config.templates.FunctionTemplate;
|
|
||||||
import com.dfsek.terra.addons.noise.paralithic.defined.UserDefinedFunction;
|
|
||||||
import com.dfsek.terra.addons.noise.paralithic.noise.NoiseFunction2;
|
|
||||||
import com.dfsek.terra.addons.noise.paralithic.noise.NoiseFunction3;
|
|
||||||
import com.dfsek.terra.addons.noise.paralithic.noise.SeedContext;
|
|
||||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
|
||||||
import com.dfsek.terra.api.util.seeded.SeededNoiseSampler;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sampler3D implementation using Paralithic expression
|
|
||||||
*/
|
|
||||||
public class ExpressionSampler implements NoiseSampler {
|
|
||||||
private final Expression expression;
|
|
||||||
|
|
||||||
public ExpressionSampler(String equation, Scope parent, long seed, Map<String, SeededNoiseSampler> functions, Map<String, FunctionTemplate> definedFunctions) throws ParseException {
|
|
||||||
Parser parser = new Parser();
|
|
||||||
Scope scope = new Scope().withParent(parent);
|
|
||||||
|
|
||||||
scope.addInvocationVariable("x");
|
|
||||||
scope.addInvocationVariable("y");
|
|
||||||
scope.addInvocationVariable("z");
|
|
||||||
|
|
||||||
functions.forEach((id, noise) -> {
|
|
||||||
switch(noise.getDimensions()) {
|
|
||||||
case 2:
|
|
||||||
parser.registerFunction(id, new NoiseFunction2(noise.build(seed)));
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
parser.registerFunction(id, new NoiseFunction3(noise.build(seed)));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
for(Map.Entry<String, FunctionTemplate> entry : definedFunctions.entrySet()) {
|
|
||||||
parser.registerFunction(entry.getKey(), UserDefinedFunction.newInstance(entry.getValue(), parser, parent));
|
|
||||||
}
|
|
||||||
|
|
||||||
this.expression = parser.parse(equation, scope);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double getNoiseSeeded(long seed, double x, double y) {
|
|
||||||
return getNoiseSeeded(seed, x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double getNoiseSeeded(long seed, double x, double y, double z) {
|
|
||||||
return expression.evaluate(new SeedContext(seed), x, y, z);
|
|
||||||
}
|
|
||||||
}
|
|
@ -3,19 +3,6 @@ package com.dfsek.terra.api.util.seeded;
|
|||||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||||
|
|
||||||
public interface SeededNoiseSampler extends SeededBuilder<NoiseSampler> {
|
public interface SeededNoiseSampler extends SeededBuilder<NoiseSampler> {
|
||||||
static SeededNoiseSampler zero(int dimensions) {
|
|
||||||
return new SeededNoiseSampler() {
|
|
||||||
@Override
|
|
||||||
public NoiseSampler build(long seed) {
|
|
||||||
return NoiseSampler.zero();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getDimensions() {
|
|
||||||
return dimensions;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
int getDimensions();
|
int getDimensions();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user