mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-03 08:25:31 +00:00
use column in ChunkInterpolator and NoiseChunkGenerator3D
This commit is contained in:
parent
c49202017f
commit
15fec550c7
@ -49,7 +49,7 @@ public class NoiseChunkGenerator3DAddon implements AddonInitializer {
|
||||
.getOrCreateRegistry(ChunkGeneratorProvider.class)
|
||||
.register(addon.key("NOISE_3D"),
|
||||
pack -> new NoiseChunkGenerator3D(platform, config.getElevationBlend(), config.getHorizontalRes(),
|
||||
config.getVerticalRes(), config.getPaletteRes(), config.getPaletteBlendSampler(), config.getPaletteBlendAmplitude(),
|
||||
config.getVerticalRes(),
|
||||
noisePropertiesPropertyKey, paletteInfoPropertyKey));
|
||||
event.getPack()
|
||||
.applyLoader(SlantLayer.class, SlantLayer::new);
|
||||
|
@ -5,7 +5,6 @@ import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
|
||||
|
||||
public class NoiseChunkGeneratorPackConfigTemplate implements ConfigTemplate {
|
||||
@ -13,18 +12,6 @@ public class NoiseChunkGeneratorPackConfigTemplate implements ConfigTemplate {
|
||||
@Default
|
||||
private @Meta int elevationBlend = 4;
|
||||
|
||||
@Value("blend.palette.resolution")
|
||||
@Default
|
||||
private @Meta int paletteRes = 1;
|
||||
|
||||
@Value("blend.palette.sampler")
|
||||
@Default
|
||||
private @Meta NoiseSampler paletteBlendSampler = NoiseSampler.zero();
|
||||
|
||||
@Value("blend.palette.amplitude")
|
||||
@Default
|
||||
private @Meta double paletteBlendAmplitude = 0;
|
||||
|
||||
@Value("carving.resolution.horizontal")
|
||||
@Default
|
||||
private @Meta int horizontalRes = 4;
|
||||
@ -44,16 +31,4 @@ public class NoiseChunkGeneratorPackConfigTemplate implements ConfigTemplate {
|
||||
public int getVerticalRes() {
|
||||
return verticalRes;
|
||||
}
|
||||
|
||||
public double getPaletteBlendAmplitude() {
|
||||
return paletteBlendAmplitude;
|
||||
}
|
||||
|
||||
public int getPaletteRes() {
|
||||
return paletteRes;
|
||||
}
|
||||
|
||||
public NoiseSampler getPaletteBlendSampler() {
|
||||
return paletteBlendSampler;
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.properties.PropertyKey;
|
||||
import com.dfsek.terra.api.util.Column;
|
||||
import com.dfsek.terra.api.util.MathUtil;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
@ -40,41 +41,22 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
|
||||
private final int carverHorizontalResolution;
|
||||
private final int carverVerticalResolution;
|
||||
|
||||
private final int paletteRes;
|
||||
|
||||
private final NoiseSampler paletteBlendSampler;
|
||||
|
||||
private final double paletteBlendAmplitude;
|
||||
private final PropertyKey<PaletteInfo> paletteInfoPropertyKey;
|
||||
private final PropertyKey<BiomeNoiseProperties> noisePropertiesKey;
|
||||
|
||||
public NoiseChunkGenerator3D(Platform platform, int elevationBlend, int carverHorizontalResolution,
|
||||
int carverVerticalResolution, int paletteRes, NoiseSampler paletteBlendSampler,
|
||||
double paletteBlendAmplitude, PropertyKey<BiomeNoiseProperties> noisePropertiesKey,
|
||||
int carverVerticalResolution,
|
||||
PropertyKey<BiomeNoiseProperties> noisePropertiesKey,
|
||||
PropertyKey<PaletteInfo> paletteInfoPropertyKey) {
|
||||
this.platform = platform;
|
||||
this.air = platform.getWorldHandle().air();
|
||||
this.carverHorizontalResolution = carverHorizontalResolution;
|
||||
this.carverVerticalResolution = carverVerticalResolution;
|
||||
this.paletteRes = paletteRes;
|
||||
this.paletteBlendSampler = paletteBlendSampler;
|
||||
this.paletteBlendAmplitude = paletteBlendAmplitude;
|
||||
this.paletteInfoPropertyKey = paletteInfoPropertyKey;
|
||||
this.noisePropertiesKey = noisePropertiesKey;
|
||||
this.samplerCache = new SamplerProvider(platform, elevationBlend, noisePropertiesKey);
|
||||
}
|
||||
|
||||
private Biome getBiome(int min, int max, double noiseX, double noiseZ, BiomeProvider biomeProvider, int x, int y, int z, long seed) {
|
||||
if(paletteBlendAmplitude == 1) {
|
||||
return biomeProvider.getBiome(x, y, z, seed);
|
||||
}
|
||||
int mx = ((x + (int) (paletteBlendAmplitude * noiseX)) / paletteRes) * paletteRes;
|
||||
int my = ((y + (int) (paletteBlendAmplitude * paletteBlendSampler.noise(seed + 2, x, y, z))) / paletteRes) * paletteRes;
|
||||
int mz = ((z + (int) (paletteBlendAmplitude * noiseZ)) / paletteRes) * paletteRes;
|
||||
|
||||
return biomeProvider.getBiome(mx, MathUtil.clamp(min, my, max), mz, seed);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("try")
|
||||
public void generateChunkData(@NotNull ProtoChunk chunk, @NotNull WorldProperties world,
|
||||
@ -83,8 +65,6 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
|
||||
platform.getProfiler().push("chunk_base_3d");
|
||||
int xOrig = (chunkX << 4);
|
||||
int zOrig = (chunkZ << 4);
|
||||
int min = world.getMinHeight();
|
||||
int max = world.getMaxHeight() - 1;
|
||||
|
||||
Sampler3D sampler = samplerCache.getChunk(chunkX, chunkZ, world, biomeProvider);
|
||||
|
||||
@ -100,16 +80,15 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
|
||||
seed);
|
||||
for(int x = 0; x < 16; x++) {
|
||||
for(int z = 0; z < 16; z++) {
|
||||
double paletteNoiseX = paletteBlendSampler.noise(seed, x, z);
|
||||
double paletteNoiseZ = paletteBlendSampler.noise(seed + 1, x, z);
|
||||
int paletteLevel = 0;
|
||||
|
||||
int cx = xOrig + x;
|
||||
int cz = zOrig + z;
|
||||
|
||||
BlockState data;
|
||||
Column<Biome> biomeColumn = biomeProvider.getColumn(cx, cz, world);
|
||||
for(int y = world.getMaxHeight() - 1; y >= world.getMinHeight(); y--) {
|
||||
Biome biome = getBiome(min, max, paletteNoiseX, paletteNoiseZ, biomeProvider, cx, y, cz, seed);
|
||||
Biome biome = biomeColumn.get(y);
|
||||
|
||||
PaletteInfo paletteInfo = biome.getContext().get(paletteInfoPropertyKey);
|
||||
|
||||
|
@ -9,6 +9,8 @@ package com.dfsek.terra.addons.chunkgenerator.generation.math.interpolation;
|
||||
|
||||
import com.dfsek.terra.addons.chunkgenerator.config.noise.BiomeNoiseProperties;
|
||||
import com.dfsek.terra.api.properties.PropertyKey;
|
||||
import com.dfsek.terra.api.util.Column;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
@ -54,9 +56,11 @@ public class ChunkInterpolator {
|
||||
for(int z = 0; z < 5; z++) {
|
||||
int scaledZ = z << 2;
|
||||
int absoluteZ = zOrigin + scaledZ;
|
||||
|
||||
Column<Biome> biomeColumn = provider.getColumn(absoluteX, absoluteZ, seed, min, max);
|
||||
for(int y = 0; y < size; y++) {
|
||||
int scaledY = (y << 2) + min;
|
||||
BiomeNoiseProperties generationSettings = provider.getBiome(absoluteX, scaledY, absoluteZ, seed)
|
||||
BiomeNoiseProperties generationSettings = biomeColumn.get(scaledY)
|
||||
.getContext()
|
||||
.get(noisePropertiesKey);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user