mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-14 19:56:19 +00:00
Merge remote-tracking branch 'origin/ver/7.0.0' into dev/pure
This commit is contained in:
@@ -33,6 +33,7 @@ import com.dfsek.terra.addons.noise.config.templates.noise.fractal.BrownianMotio
|
||||
import com.dfsek.terra.addons.noise.config.templates.noise.fractal.PingPongTemplate;
|
||||
import com.dfsek.terra.addons.noise.config.templates.noise.fractal.RidgedFractalTemplate;
|
||||
import com.dfsek.terra.addons.noise.config.templates.normalizer.ClampNormalizerTemplate;
|
||||
import com.dfsek.terra.addons.noise.config.templates.normalizer.LinearMapNormalizerTemplate;
|
||||
import com.dfsek.terra.addons.noise.config.templates.normalizer.LinearNormalizerTemplate;
|
||||
import com.dfsek.terra.addons.noise.config.templates.normalizer.NormalNormalizerTemplate;
|
||||
import com.dfsek.terra.addons.noise.config.templates.normalizer.PosterizationNormalizerTemplate;
|
||||
@@ -88,6 +89,7 @@ public class NoiseAddon implements MonadAddonInitializer {
|
||||
.applyLoader(FunctionTemplate.class, FunctionTemplate::new);
|
||||
|
||||
noiseRegistry.register(base.key("LINEAR"), LinearNormalizerTemplate::new);
|
||||
noiseRegistry.register(base.key("LINEAR_MAP"), LinearMapNormalizerTemplate::new);
|
||||
noiseRegistry.register(base.key("NORMAL"), NormalNormalizerTemplate::new);
|
||||
noiseRegistry.register(base.key("CLAMP"), ClampNormalizerTemplate::new);
|
||||
noiseRegistry.register(base.key("PROBABILITY"), ProbabilityNormalizerTemplate::new);
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.dfsek.terra.addons.noise.config.templates.normalizer;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
|
||||
import com.dfsek.terra.addons.noise.normalizer.LinearMapNormalizer;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
|
||||
|
||||
public class LinearMapNormalizerTemplate extends NormalizerTemplate<LinearMapNormalizer> {
|
||||
|
||||
@Value("from.a")
|
||||
@Default
|
||||
private @Meta double aFrom = -1;
|
||||
|
||||
@Value("from.b")
|
||||
@Default
|
||||
private @Meta double bFrom = 1;
|
||||
|
||||
@Value("to.a")
|
||||
private @Meta double aTo;
|
||||
|
||||
@Value("to.b")
|
||||
private @Meta double bTo;
|
||||
|
||||
@Override
|
||||
public NoiseSampler get() {
|
||||
return new LinearMapNormalizer(function, aFrom, aTo, bFrom, bTo);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.dfsek.terra.addons.noise.normalizer;
|
||||
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
|
||||
|
||||
public class LinearMapNormalizer extends Normalizer {
|
||||
|
||||
private final double aFrom;
|
||||
|
||||
private final double aTo;
|
||||
|
||||
private final double bFrom;
|
||||
|
||||
private final double bTo;
|
||||
|
||||
public LinearMapNormalizer(NoiseSampler sampler, double aFrom, double aTo, double bFrom, double bTo) {
|
||||
super(sampler);
|
||||
this.aFrom = aFrom;
|
||||
this.aTo = aTo;
|
||||
this.bFrom = bFrom;
|
||||
this.bTo = bTo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double normalize(double in) {
|
||||
return (in - aFrom) * (aTo - bTo) / (aFrom - bFrom) + aTo;
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
package com.dfsek.terra.addons.terrascript.script.functions;
|
||||
|
||||
import com.dfsek.terra.api.util.vector.Vector3Int;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -66,20 +68,24 @@ public class StructureFunction implements Function<Boolean> {
|
||||
|
||||
|
||||
String app = id.apply(implementationArguments, scope);
|
||||
int xValue = FastMath.roundToInt(xz.getX());
|
||||
int yValue = y.apply(implementationArguments, scope).intValue();
|
||||
int zValue = FastMath.roundToInt(xz.getZ());
|
||||
Vector3Int origin = Vector3Int.of(xValue, yValue, zValue);
|
||||
return registry.getByID(app).map(script -> {
|
||||
if(script instanceof StructureScript structureScript) {
|
||||
return structureScript.generate(arguments.getOrigin(),
|
||||
return structureScript.generate(origin,
|
||||
arguments.getWorld()
|
||||
.buffer(FastMath.roundToInt(xz.getX()),
|
||||
y.apply(implementationArguments, scope).intValue(),
|
||||
FastMath.roundToInt(xz.getZ())),
|
||||
.buffer(xValue,
|
||||
yValue,
|
||||
zValue),
|
||||
arguments.getRotation(), arguments.getRecursions() + 1);
|
||||
}
|
||||
return script.generate(arguments.getOrigin(),
|
||||
arguments.getWorld()
|
||||
.buffer(FastMath.roundToInt(xz.getX()),
|
||||
y.apply(implementationArguments, scope).intValue(),
|
||||
FastMath.roundToInt(xz.getZ())),
|
||||
.buffer(xValue,
|
||||
yValue,
|
||||
zValue),
|
||||
arguments.getRotation());
|
||||
}).orElseGet(() -> {
|
||||
LOGGER.error("No such structure {}", app);
|
||||
|
||||
Reference in New Issue
Block a user