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