mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-14 04:41:13 +00:00
minor perf improvements
This commit is contained in:
@@ -41,7 +41,7 @@ public class StandardBiomeProvider implements BiomeProvider {
|
||||
}
|
||||
}
|
||||
);
|
||||
private int resolution = 4;
|
||||
private int resolution = 1;
|
||||
|
||||
protected StandardBiomeProvider(BiomePipeline pipeline) {
|
||||
this.pipeline = pipeline;
|
||||
|
||||
@@ -21,7 +21,7 @@ public class BiomePipeline {
|
||||
}
|
||||
|
||||
public BiomeHolder getBiomes(int x, int z) {
|
||||
BiomeHolder holder = new TerraBiomeHolder(25, new Vector2(x * (init - 1), z * (init - 1)));
|
||||
BiomeHolder holder = new TerraBiomeHolder(init, new Vector2(x * (init - 1), z * (init - 1)));
|
||||
holder.fill(source);
|
||||
for(Stage stage : stages) holder = stage.apply(holder);
|
||||
return holder;
|
||||
|
||||
@@ -12,6 +12,7 @@ public class TerraBiomeHolder implements BiomeHolder {
|
||||
private TerraBiome[][] biomes;
|
||||
|
||||
public TerraBiomeHolder(int width, Vector2 origin) {
|
||||
if(width % 2 == 0) throw new IllegalArgumentException();
|
||||
this.width = width;
|
||||
biomes = new TerraBiome[width][width];
|
||||
this.origin = origin;
|
||||
@@ -48,11 +49,7 @@ public class TerraBiomeHolder implements BiomeHolder {
|
||||
public void mutate(BiomeMutator mutator) {
|
||||
for(int x = 0; x < width; x++) {
|
||||
for(int z = 0; z < width; z++) {
|
||||
BiomeMutator.ViewPoint viewPoint = new BiomeMutator.ViewPoint(new TerraBiome[][] {
|
||||
{getBiomeRaw(x - 1, z + 1), getBiomeRaw(x, z + 1), getBiomeRaw(x + 1, z + 1)},
|
||||
{getBiomeRaw(x - 1, z), getBiomeRaw(x, z), getBiomeRaw(x + 1, z)},
|
||||
{getBiomeRaw(x - 1, z - 1), getBiomeRaw(x, z - 1), getBiomeRaw(x + 1, z - 1)}
|
||||
});
|
||||
BiomeMutator.ViewPoint viewPoint = new BiomeMutator.ViewPoint(this, x, z);
|
||||
biomes[x][z] = mutator.mutate(viewPoint, x + origin.getX(), z + origin.getZ());
|
||||
}
|
||||
}
|
||||
@@ -67,11 +64,6 @@ public class TerraBiomeHolder implements BiomeHolder {
|
||||
}
|
||||
}
|
||||
|
||||
private TerraBiome getBiomeRaw(int x, int z) {
|
||||
if(x >= width || z >= width || x < 0 || z < 0) return null;
|
||||
return biomes[x][z];
|
||||
}
|
||||
|
||||
@Override
|
||||
public TerraBiome getBiome(int x, int z) {
|
||||
if(x >= width || z >= width || x < 0 || z < 0) return null;
|
||||
|
||||
@@ -1,19 +1,25 @@
|
||||
package com.dfsek.terra.biome.pipeline.mutator;
|
||||
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
import com.dfsek.terra.biome.pipeline.BiomeHolder;
|
||||
|
||||
public interface BiomeMutator {
|
||||
TerraBiome mutate(ViewPoint viewPoint, double x, double z);
|
||||
|
||||
class ViewPoint {
|
||||
private final TerraBiome[][] biomes;
|
||||
private final BiomeHolder biomes;
|
||||
private final int offX;
|
||||
private final int offZ;
|
||||
|
||||
public ViewPoint(TerraBiome[][] biomes) {
|
||||
public ViewPoint(BiomeHolder biomes, int offX, int offZ) {
|
||||
this.biomes = biomes;
|
||||
this.offX = offX;
|
||||
this.offZ = offZ;
|
||||
}
|
||||
|
||||
|
||||
public TerraBiome getBiome(int x, int z) {
|
||||
return biomes[x + 1][z + 1];
|
||||
return biomes.getBiome(x + offX, z + offZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user