mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-18 10:32:30 +00:00
Minor performance improvements to generation
This commit is contained in:
parent
291d0aaf1c
commit
2100718b2a
@ -1,5 +1,6 @@
|
|||||||
package com.dfsek.terra.biome;
|
package com.dfsek.terra.biome;
|
||||||
|
|
||||||
|
import com.dfsek.terra.config.genconfig.biome.BiomeConfig;
|
||||||
import com.dfsek.terra.config.genconfig.biome.GeneratorOptions;
|
import com.dfsek.terra.config.genconfig.biome.GeneratorOptions;
|
||||||
import com.dfsek.terra.generation.UserDefinedDecorator;
|
import com.dfsek.terra.generation.UserDefinedDecorator;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -18,15 +19,17 @@ public class UserDefinedBiome implements Biome {
|
|||||||
private final UserDefinedDecorator decorator;
|
private final UserDefinedDecorator decorator;
|
||||||
private final org.bukkit.block.Biome vanilla;
|
private final org.bukkit.block.Biome vanilla;
|
||||||
private final String id;
|
private final String id;
|
||||||
|
private final BiomeConfig config;
|
||||||
private final boolean erode;
|
private final boolean erode;
|
||||||
|
|
||||||
|
|
||||||
public UserDefinedBiome(org.bukkit.block.Biome vanilla, UserDefinedDecorator dec, GeneratorOptions gen, boolean erode, String id) {
|
public UserDefinedBiome(org.bukkit.block.Biome vanilla, UserDefinedDecorator dec, GeneratorOptions gen, boolean erode, BiomeConfig config) {
|
||||||
this.vanilla = vanilla;
|
this.vanilla = vanilla;
|
||||||
this.decorator = dec;
|
this.decorator = dec;
|
||||||
this.gen = gen;
|
this.gen = gen;
|
||||||
this.id = id;
|
this.id = config.getID();
|
||||||
this.erode = erode;
|
this.erode = erode;
|
||||||
|
this.config = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -77,6 +80,10 @@ public class UserDefinedBiome implements Biome {
|
|||||||
return erode;
|
return erode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BiomeConfig getConfig() {
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Generator getGenerator(World w) {
|
public Generator getGenerator(World w) {
|
||||||
return gen.getGenerator(w.getSeed());
|
return gen.getGenerator(w.getSeed());
|
||||||
|
@ -171,7 +171,7 @@ public class BiomeConfig extends TerraConfig {
|
|||||||
try {
|
try {
|
||||||
// Get UserDefinedBiome instance representing this config.
|
// Get UserDefinedBiome instance representing this config.
|
||||||
GeneratorOptions gen = new GeneratorOptions(eq, elevation, config.getVariableScope(), palette.getPaletteMap(), slant, config.getNoiseBuilders(), getBoolean("prevent-smooth", false), doElevationInterpolation);
|
GeneratorOptions gen = new GeneratorOptions(eq, elevation, config.getVariableScope(), palette.getPaletteMap(), slant, config.getNoiseBuilders(), getBoolean("prevent-smooth", false), doElevationInterpolation);
|
||||||
this.biome = new UserDefinedBiome(vanillaBiome, dec, gen, getBoolean("erodible", false), biomeID);
|
this.biome = new UserDefinedBiome(vanillaBiome, dec, gen, getBoolean("erodible", false), this);
|
||||||
} catch(ParseException e) {
|
} catch(ParseException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw new ConfigException("Unable to parse noise equation!", getID());
|
throw new ConfigException("Unable to parse noise equation!", getID());
|
||||||
|
@ -80,17 +80,19 @@ public class TerraChunkGenerator extends GaeaChunkGenerator {
|
|||||||
private static Palette<BlockData> getPalette(int x, int y, int z, BiomeConfig c, ChunkInterpolator interpolator, ElevationInterpolator elevationInterpolator) {
|
private static Palette<BlockData> getPalette(int x, int y, int z, BiomeConfig c, ChunkInterpolator interpolator, ElevationInterpolator elevationInterpolator) {
|
||||||
Palette<BlockData> slant = ((WorldGenerator) c.getBiome().getGenerator()).getSlantPalette(y);
|
Palette<BlockData> slant = ((WorldGenerator) c.getBiome().getGenerator()).getSlantPalette(y);
|
||||||
if(slant != null) {
|
if(slant != null) {
|
||||||
boolean north = interpolator.getNoise(x, y - elevationInterpolator.getElevation(x, z + 1), z + 1) > 0;
|
|
||||||
boolean south = interpolator.getNoise(x, y - elevationInterpolator.getElevation(x, z - 1), z - 1) > 0;
|
|
||||||
boolean east = interpolator.getNoise(x + 1, y - elevationInterpolator.getElevation(x + 1, z), z) > 0;
|
|
||||||
boolean west = interpolator.getNoise(x - 1, y - elevationInterpolator.getElevation(x - 1, z), z) > 0;
|
|
||||||
|
|
||||||
double ySlantOffsetTop = c.getYSlantOffsetTop();
|
double ySlantOffsetTop = c.getYSlantOffsetTop();
|
||||||
double ySlantOffsetBottom = c.getYSlantOffsetBottom();
|
double ySlantOffsetBottom = c.getYSlantOffsetBottom();
|
||||||
boolean top = interpolator.getNoise(x, y + ySlantOffsetTop - elevationInterpolator.getElevation(x, z), z) > 0;
|
boolean top = interpolator.getNoise(x, y + ySlantOffsetTop - elevationInterpolator.getElevation(x, z), z) > 0;
|
||||||
boolean bottom = interpolator.getNoise(x, y - ySlantOffsetBottom - elevationInterpolator.getElevation(x, z), z) > 0;
|
boolean bottom = interpolator.getNoise(x, y - ySlantOffsetBottom - elevationInterpolator.getElevation(x, z), z) > 0;
|
||||||
|
|
||||||
if((top && bottom) && (north || south || east || west) && (!(north && south && east && west))) return slant;
|
if(top && bottom) {
|
||||||
|
boolean north = interpolator.getNoise(x, y - elevationInterpolator.getElevation(x, z + 1), z + 1) > 0;
|
||||||
|
boolean south = interpolator.getNoise(x, y - elevationInterpolator.getElevation(x, z - 1), z - 1) > 0;
|
||||||
|
boolean east = interpolator.getNoise(x + 1, y - elevationInterpolator.getElevation(x + 1, z), z) > 0;
|
||||||
|
boolean west = interpolator.getNoise(x - 1, y - elevationInterpolator.getElevation(x - 1, z), z) > 0;
|
||||||
|
|
||||||
|
if((north || south || east || west) && (!(north && south && east && west))) return slant;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return c.getBiome().getGenerator().getPalette(y);
|
return c.getBiome().getGenerator().getPalette(y);
|
||||||
}
|
}
|
||||||
@ -104,10 +106,10 @@ public class TerraChunkGenerator extends GaeaChunkGenerator {
|
|||||||
if(stairPalette != null) {
|
if(stairPalette != null) {
|
||||||
BlockData stair = stairPalette.get(0, block.getBlockX(), block.getBlockZ());
|
BlockData stair = stairPalette.get(0, block.getBlockX(), block.getBlockZ());
|
||||||
Stairs stairNew = (Stairs) stair.clone();
|
Stairs stairNew = (Stairs) stair.clone();
|
||||||
double elevationN = elevationInterpolator.getElevation(block.getBlockX(), block.getBlockZ() - 1); // Northern elevation
|
int elevationN = (int) elevationInterpolator.getElevation(block.getBlockX(), block.getBlockZ() - 1); // Northern elevation
|
||||||
double elevationS = elevationInterpolator.getElevation(block.getBlockX(), block.getBlockZ() + 1); // Southern elevation
|
int elevationS = (int) elevationInterpolator.getElevation(block.getBlockX(), block.getBlockZ() + 1); // Southern elevation
|
||||||
double elevationE = elevationInterpolator.getElevation(block.getBlockX() + 1, block.getBlockZ()); // Eastern elevation
|
int elevationE = (int) elevationInterpolator.getElevation(block.getBlockX() + 1, block.getBlockZ()); // Eastern elevation
|
||||||
double elevationW = elevationInterpolator.getElevation(block.getBlockX() - 1, block.getBlockZ()); // Western elevation
|
int elevationW = (int) elevationInterpolator.getElevation(block.getBlockX() - 1, block.getBlockZ()); // Western elevation
|
||||||
if(interpolator.getNoise(block.getBlockX() - 0.5, block.getBlockY() - elevationW, block.getBlockZ()) > thresh) {
|
if(interpolator.getNoise(block.getBlockX() - 0.5, block.getBlockY() - elevationW, block.getBlockZ()) > thresh) {
|
||||||
stairNew.setFacing(BlockFace.WEST);
|
stairNew.setFacing(BlockFace.WEST);
|
||||||
} else if(interpolator.getNoise(block.getBlockX(), block.getBlockY() - elevationN, block.getBlockZ() - 0.5) > thresh) {
|
} else if(interpolator.getNoise(block.getBlockX(), block.getBlockY() - elevationN, block.getBlockZ() - 0.5) > thresh) {
|
||||||
@ -163,7 +165,7 @@ public class TerraChunkGenerator extends GaeaChunkGenerator {
|
|||||||
int cz = zOrig + z;
|
int cz = zOrig + z;
|
||||||
|
|
||||||
Biome b = grid.getBiome(xOrig + x, zOrig + z, GenerationPhase.PALETTE_APPLY);
|
Biome b = grid.getBiome(xOrig + x, zOrig + z, GenerationPhase.PALETTE_APPLY);
|
||||||
BiomeConfig c = config.getBiome((UserDefinedBiome) b);
|
BiomeConfig c = ((UserDefinedBiome) b).getConfig();
|
||||||
|
|
||||||
double elevate = elevationInterpolator.getElevation(x, z);
|
double elevate = elevationInterpolator.getElevation(x, z);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user