mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-08-30 13:50:46 +00:00
Carving is now very much optimized
This commit is contained in:
@@ -25,7 +25,7 @@ public class CarverCache {
|
|||||||
if(carvers.size() > PluginConfig.getCacheSize() * 2) carvers.clear();
|
if(carvers.size() > PluginConfig.getCacheSize() * 2) carvers.clear();
|
||||||
return carvers.computeIfAbsent((((long) chunkX) << 32) | (chunkZ & 0xffffffffL) ^ w.getSeed(), key -> {
|
return carvers.computeIfAbsent((((long) chunkX) << 32) | (chunkZ & 0xffffffffL) ^ w.getSeed(), key -> {
|
||||||
TerraBiomeGrid grid = TerraWorld.getWorld(w).getGrid();
|
TerraBiomeGrid grid = TerraWorld.getWorld(w).getGrid();
|
||||||
if(carver.isChunkCarved(w, chunkX, chunkZ, new FastRandom(MathUtil.hashToLong(this.getClass().getName() + "_" + chunkX + "&" + chunkZ)))) {
|
if(carver.isChunkCarved(w, chunkX, chunkZ, new FastRandom(MathUtil.hashToLong(carver.getClass().getName() + "_" + chunkX + "&" + chunkZ)))) {
|
||||||
long seed = MathUtil.getCarverChunkSeed(chunkX, chunkZ, w.getSeed());
|
long seed = MathUtil.getCarverChunkSeed(chunkX, chunkZ, w.getSeed());
|
||||||
carver.getSeedVar().setValue(seed);
|
carver.getSeedVar().setValue(seed);
|
||||||
Random r = new FastRandom(seed);
|
Random r = new FastRandom(seed);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import net.jafama.FastMath;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
import org.polydev.gaea.generation.GenerationPhase;
|
import org.polydev.gaea.generation.GenerationPhase;
|
||||||
|
import org.polydev.gaea.math.MathUtil;
|
||||||
import org.polydev.gaea.math.Range;
|
import org.polydev.gaea.math.Range;
|
||||||
import org.polydev.gaea.util.FastRandom;
|
import org.polydev.gaea.util.FastRandom;
|
||||||
import org.polydev.gaea.world.carving.Carver;
|
import org.polydev.gaea.world.carving.Carver;
|
||||||
@@ -30,6 +31,9 @@ public class UserDefinedCarver extends Carver {
|
|||||||
private final int hash;
|
private final int hash;
|
||||||
private final int topCut;
|
private final int topCut;
|
||||||
private final int bottomCut;
|
private final int bottomCut;
|
||||||
|
private double step = 2;
|
||||||
|
private Range recalc = new Range(8, 10);
|
||||||
|
private double recalcMagnitude = 3;
|
||||||
private final CarverTemplate config;
|
private final CarverTemplate config;
|
||||||
private final Expression xRad;
|
private final Expression xRad;
|
||||||
private final Expression yRad;
|
private final Expression yRad;
|
||||||
@@ -40,9 +44,6 @@ public class UserDefinedCarver extends Carver {
|
|||||||
private final Range height;
|
private final Range height;
|
||||||
private final double sixtyFourSq = FastMath.pow(64, 2);
|
private final double sixtyFourSq = FastMath.pow(64, 2);
|
||||||
private final CarverCache cache = new CarverCache();
|
private final CarverCache cache = new CarverCache();
|
||||||
private double step = 2;
|
|
||||||
private Range recalc = new Range(8, 10);
|
|
||||||
private double recalcMagnitude = 3;
|
|
||||||
|
|
||||||
public UserDefinedCarver(Range height, Range length, double[] start, double[] mutate, List<String> radii, Scope parent, int hash, int topCut, int bottomCut, CarverTemplate config) throws ParseException {
|
public UserDefinedCarver(Range height, Range length, double[] start, double[] mutate, List<String> radii, Scope parent, int hash, int topCut, int bottomCut, CarverTemplate config) throws ParseException {
|
||||||
super(height.getMin(), height.getMax());
|
super(height.getMin(), height.getMax());
|
||||||
@@ -104,12 +105,14 @@ public class UserDefinedCarver extends Carver {
|
|||||||
int carvingRadius = getCarvingRadius();
|
int carvingRadius = getCarvingRadius();
|
||||||
for(int x = chunkX - carvingRadius; x <= chunkX + carvingRadius; x++) {
|
for(int x = chunkX - carvingRadius; x <= chunkX + carvingRadius; x++) {
|
||||||
for(int z = chunkZ - carvingRadius; z <= chunkZ + carvingRadius; z++) {
|
for(int z = chunkZ - carvingRadius; z <= chunkZ + carvingRadius; z++) {
|
||||||
cache.getPoints(x, z, w, this).forEach(point -> {
|
if(isChunkCarved(w, x, z, new FastRandom(MathUtil.hashToLong(this.getClass().getName() + "_" + x + "&" + z)))) {
|
||||||
Vector origin = point.getOrigin();
|
cache.getPoints(x, z, w, this).forEach(point -> {
|
||||||
if(FastMath.floorDiv(origin.getBlockX(), 16) != chunkX && FastMath.floorDiv(origin.getBlockZ(), 16) != chunkZ)
|
Vector origin = point.getOrigin();
|
||||||
return;
|
if(FastMath.floorDiv(origin.getBlockX(), 16) != chunkX && FastMath.floorDiv(origin.getBlockZ(), 16) != chunkZ)
|
||||||
point.carve(chunkX, chunkZ, consumer);
|
return;
|
||||||
});
|
point.carve(chunkX, chunkZ, consumer);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user