mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-16 13:51:41 +00:00
basic noise carver implementation
This commit is contained in:
@@ -20,6 +20,8 @@ public class GeneratorBuilder {
|
||||
|
||||
private String elevationEquation;
|
||||
|
||||
private String carvingEquation;
|
||||
|
||||
private Scope varScope;
|
||||
|
||||
private Map<String, NoiseBuilder> noiseBuilderMap;
|
||||
@@ -51,13 +53,15 @@ public class GeneratorBuilder {
|
||||
return gens.computeIfAbsent(seed, k -> {
|
||||
NoiseSampler noise;
|
||||
NoiseSampler elevation;
|
||||
NoiseSampler carving;
|
||||
try {
|
||||
noise = new ExpressionSampler(noiseEquation, varScope, seed, noiseBuilderMap);
|
||||
elevation = elevationEquation == null ? new ConstantSampler(0) : new ExpressionSampler(elevationEquation, varScope, seed, noiseBuilderMap);
|
||||
carving = new ExpressionSampler(carvingEquation, varScope, seed, noiseBuilderMap);
|
||||
} catch(ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return new WorldGenerator(palettes, slantPalettes, noise, elevation, noise2d, base, biomeNoise.build((int) seed), elevationWeight, blendDistance, blendStep, blendWeight);
|
||||
return new WorldGenerator(palettes, slantPalettes, noise, elevation, carving, noise2d, base, biomeNoise.build((int) seed), elevationWeight, blendDistance, blendStep, blendWeight);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -114,6 +118,10 @@ public class GeneratorBuilder {
|
||||
this.elevationEquation = elevationEquation;
|
||||
}
|
||||
|
||||
public void setCarvingEquation(String carvingEquation) {
|
||||
this.carvingEquation = carvingEquation;
|
||||
}
|
||||
|
||||
public Scope getVarScope() {
|
||||
return varScope;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ public class BiomeFactory implements TerraFactory<BiomeTemplate, TerraBiome> {
|
||||
GeneratorBuilder generatorBuilder = new GeneratorBuilder();
|
||||
generatorBuilder.setElevationEquation(template.getElevationEquation());
|
||||
generatorBuilder.setNoiseEquation(template.getNoiseEquation());
|
||||
generatorBuilder.setCarvingEquation(template.getCarvingEquation());
|
||||
generatorBuilder.setNoiseBuilderMap(template.getPack().getTemplate().getNoiseBuilderMap());
|
||||
generatorBuilder.setPalettes(template.getPalette());
|
||||
generatorBuilder.setSlantPalettes(template.getSlantPalette());
|
||||
|
||||
@@ -42,6 +42,11 @@ public class BiomeTemplate extends AbstractableTemplate implements ValidatedConf
|
||||
@Default
|
||||
private String extend = null;
|
||||
|
||||
@Value("carving.equation")
|
||||
@Abstractable
|
||||
@Default
|
||||
private String carvingEquation = "0";
|
||||
|
||||
@Value("noise-2d.enable")
|
||||
@Default
|
||||
@Abstractable
|
||||
@@ -235,6 +240,10 @@ public class BiomeTemplate extends AbstractableTemplate implements ValidatedConf
|
||||
return elevationEquation;
|
||||
}
|
||||
|
||||
public String getCarvingEquation() {
|
||||
return carvingEquation;
|
||||
}
|
||||
|
||||
public ConfigPack getPack() {
|
||||
return pack;
|
||||
}
|
||||
@@ -317,6 +326,12 @@ public class BiomeTemplate extends AbstractableTemplate implements ValidatedConf
|
||||
throw new ValidationException("Invalid noise equation: ", e);
|
||||
}
|
||||
|
||||
try {
|
||||
tester.parse(carvingEquation, testScope);
|
||||
} catch(ParseException e) {
|
||||
throw new ValidationException("Invalid carving equation: ", e);
|
||||
}
|
||||
|
||||
try {
|
||||
if(elevationEquation != null) tester.parse(elevationEquation, testScope);
|
||||
} catch(ParseException e) {
|
||||
|
||||
Reference in New Issue
Block a user