mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-02-16 10:30:42 +00:00
Handle resolution and biome blending
This commit is contained in:
@@ -54,6 +54,6 @@ public class BiomePipelineTemplate implements ObjectTemplate<BiomeProvider> {
|
||||
|
||||
@Override
|
||||
public BiomeProvider get() {
|
||||
return new PipelineBiomeProvider(new PipelineImpl(source, stages, 10), resolution, blendSampler, blendAmplitude);
|
||||
return new PipelineBiomeProvider(new PipelineImpl(source, stages, resolution, 500), resolution, blendSampler, blendAmplitude);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,11 +15,13 @@ public class BiomeChunkImpl implements BiomeChunk {
|
||||
private PipelineBiome[][] biomes;
|
||||
private final SeededVector worldOrigin;
|
||||
private final int chunkOriginArrayIndex;
|
||||
private final int worldCoordinateScale;
|
||||
|
||||
public BiomeChunkImpl(SeededVector worldOrigin, PipelineImpl pipeline) {
|
||||
|
||||
this.worldOrigin = worldOrigin;
|
||||
this.chunkOriginArrayIndex = pipeline.getChunkOriginArrayIndex();
|
||||
this.worldCoordinateScale = pipeline.getResolution();
|
||||
|
||||
int size = pipeline.getArraySize();
|
||||
|
||||
@@ -86,11 +88,11 @@ public class BiomeChunkImpl implements BiomeChunk {
|
||||
}
|
||||
|
||||
private int xIndexToWorldCoordinate(int xIndex) {
|
||||
return worldOrigin.x() + xIndex - chunkOriginArrayIndex;
|
||||
return (worldOrigin.x() + xIndex - chunkOriginArrayIndex) * worldCoordinateScale;
|
||||
}
|
||||
|
||||
private int zIndexToWorldCoordinate(int zIndex) {
|
||||
return worldOrigin.z() + zIndex - chunkOriginArrayIndex;
|
||||
return (worldOrigin.z() + zIndex - chunkOriginArrayIndex) * worldCoordinateScale;
|
||||
}
|
||||
|
||||
protected static int initialSizeToArraySize(int expanderCount, int initialSize) {
|
||||
|
||||
@@ -74,14 +74,11 @@ public class PipelineBiomeProvider implements BiomeProvider {
|
||||
|
||||
public Biome getBiome(int x, int z, long seed) {
|
||||
|
||||
// x += mutator.noise(seed + 1, x, z) * noiseAmp;
|
||||
// z += mutator.noise(seed + 2, x, z) * noiseAmp;
|
||||
|
||||
// x /= resolution;
|
||||
// z /= resolution;
|
||||
x += mutator.noise(seed + 1, x, z) * noiseAmp;
|
||||
z += mutator.noise(seed + 2, x, z) * noiseAmp;
|
||||
|
||||
// x *= resolution;
|
||||
// z *= resolution;
|
||||
x /= resolution;
|
||||
z /= resolution;
|
||||
|
||||
int chunkX = FastMath.floorDiv(x, chunkSize);
|
||||
int chunkZ = FastMath.floorDiv(z, chunkSize);
|
||||
|
||||
@@ -19,10 +19,12 @@ public class PipelineImpl implements Pipeline {
|
||||
private final int expanderCount;
|
||||
private final int arraySize;
|
||||
private final int chunkOriginArrayIndex;
|
||||
private final int resolution;
|
||||
|
||||
public PipelineImpl(Source source, List<Stage> stages, int idealChunkArraySize) {
|
||||
public PipelineImpl(Source source, List<Stage> stages, int resolution, int idealChunkArraySize) {
|
||||
this.source = source;
|
||||
this.stages = stages;
|
||||
this.resolution = resolution;
|
||||
this.expanderCount = (int) stages.stream().filter(s -> s instanceof Expander).count();
|
||||
|
||||
// Optimize for the ideal array size
|
||||
@@ -79,4 +81,8 @@ public class PipelineImpl implements Pipeline {
|
||||
public int getChunkOriginArrayIndex() {
|
||||
return chunkOriginArrayIndex;
|
||||
}
|
||||
|
||||
public int getResolution() {
|
||||
return resolution;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user