mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-02 16:05:29 +00:00
properly access 3d biomes in LazilyEvaluatedInterpolator
This commit is contained in:
parent
23a35f8097
commit
d73872a1c6
@ -3,16 +3,13 @@ package com.dfsek.terra.addons.chunkgenerator.generation.math.interpolation;
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import com.dfsek.terra.addons.chunkgenerator.config.noise.BiomeNoiseProperties;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
import static com.dfsek.terra.addons.chunkgenerator.generation.math.interpolation.Interpolator.lerp;
|
||||
|
||||
|
||||
public class LazilyEvaluatedInterpolator {
|
||||
private final Double[][][] samples;
|
||||
|
||||
private final NoiseSampler[][] samplers;
|
||||
private final Double[] samples; //
|
||||
|
||||
private final int chunkX;
|
||||
private final int chunkZ;
|
||||
@ -25,12 +22,14 @@ public class LazilyEvaluatedInterpolator {
|
||||
private final long seed;
|
||||
private final int min;
|
||||
|
||||
private final int zMul, yMul;
|
||||
public LazilyEvaluatedInterpolator(BiomeProvider biomeProvider, int cx, int cz, int max, int min, int horizontalRes, int verticalRes,
|
||||
long seed) {
|
||||
int hSamples = FastMath.ceilToInt(16.0 / horizontalRes);
|
||||
int vSamples = FastMath.ceilToInt((double) (max - min) / verticalRes);
|
||||
samples = new Double[hSamples + 1][vSamples + 1][hSamples + 1];
|
||||
samplers = new NoiseSampler[hSamples + 1][hSamples + 1];
|
||||
this.zMul = (hSamples + 1);
|
||||
this.yMul = zMul * zMul;
|
||||
samples = new Double[yMul * (vSamples + 1)];
|
||||
this.chunkX = cx << 4;
|
||||
this.chunkZ = cz << 4;
|
||||
this.horizontalRes = horizontalRes;
|
||||
@ -41,19 +40,19 @@ public class LazilyEvaluatedInterpolator {
|
||||
}
|
||||
|
||||
private double sample(int x, int y, int z, int ox, int oy, int oz) {
|
||||
Double sample = samples[x][y][z];
|
||||
int index = x + (z * zMul) + (y * yMul);
|
||||
Double sample = samples[index];
|
||||
if(sample == null) {
|
||||
int xi = ox + chunkX;
|
||||
int zi = oz + chunkZ;
|
||||
|
||||
NoiseSampler sampler = samplers[x][z];
|
||||
if(sampler == null) {
|
||||
sampler = biomeProvider.getBiome(xi, y, zi, seed).getContext().get(BiomeNoiseProperties.class).carving();
|
||||
samplers[x][z] = sampler;
|
||||
}
|
||||
|
||||
sample = sampler.noise(seed, xi, oy, zi);
|
||||
samples[x][y][z] = sample;
|
||||
sample = biomeProvider
|
||||
.getBiome(xi, y, zi, seed)
|
||||
.getContext()
|
||||
.get(BiomeNoiseProperties.class)
|
||||
.carving()
|
||||
.noise(seed, xi, oy, zi);
|
||||
samples[index] = sample;
|
||||
}
|
||||
return sample;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user