mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-18 10:32:30 +00:00
Various minor optimizations
This commit is contained in:
parent
177a18855c
commit
2b5fd16e4a
@ -21,8 +21,7 @@ public class TerraProfiler extends WorldProfiler {
|
||||
.addMeasurement(new Measurement(1500000, DataType.PERIOD_MILLISECONDS), "CaveTime")
|
||||
.addMeasurement(new Measurement(1500000, DataType.PERIOD_MILLISECONDS), "StructureTime")
|
||||
.addMeasurement(new Measurement(1500000, DataType.PERIOD_MILLISECONDS), "ElevationTime")
|
||||
.addMeasurement(new Measurement(1500000, DataType.PERIOD_MILLISECONDS), "SnowTime")
|
||||
.addMeasurement(new Measurement(1500000, DataType.PERIOD_MILLISECONDS), "CaveBlockUpdate");
|
||||
.addMeasurement(new Measurement(1500000, DataType.PERIOD_MILLISECONDS), "SnowTime");
|
||||
}
|
||||
|
||||
public static TerraProfiler fromWorld(World w) {
|
||||
|
@ -41,7 +41,7 @@ public final class ConfigUtil {
|
||||
dataSave = Duration.parse(Objects.requireNonNull(config.getString("data-save", "PT6M"))).toMillis() / 20L;
|
||||
masterDisableCaves = config.getBoolean("master-disable.caves", false);
|
||||
biomeSearchRes = config.getInt("biome-search-resolution", 4);
|
||||
cacheSize = config.getInt("cache-size", 512);
|
||||
cacheSize = config.getInt("cache-size", 256);
|
||||
|
||||
if(config.getBoolean("dump-default", true)) {
|
||||
try(JarFile jar = new JarFile(new File(Terra.class.getProtectionDomain().getCodeSource().getLocation().toURI()))) {
|
||||
|
@ -33,7 +33,7 @@ public class NoiseFunction2 implements NoiseFunction {
|
||||
* @return Result.
|
||||
*/
|
||||
public double evalNoCache(List<Expression> list) {
|
||||
return gen.getNoise((int) list.get(0).evaluate(), (int) list.get(1).evaluate());
|
||||
return gen.getNoise(list.get(0).evaluate(), list.get(1).evaluate());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -43,7 +43,7 @@ public class NoiseFunction2 implements NoiseFunction {
|
||||
|
||||
private static class Cache extends HashMapDoubleDouble {
|
||||
private static final long serialVersionUID = 8915092734723467010L;
|
||||
private final int cacheSize = ConfigUtil.cacheSize;
|
||||
private static final int cacheSize = ConfigUtil.cacheSize;
|
||||
|
||||
public double get(FastNoiseLite noise, double x, double z) {
|
||||
double xx = x >= 0 ? x * 2 : x * -2 - 1;
|
||||
|
@ -79,12 +79,10 @@ public class CavePopulator extends BlockPopulator {
|
||||
} catch(NullPointerException ignore) {
|
||||
}
|
||||
}
|
||||
try(ProfileFuture ignore = TerraProfiler.fromWorld(world).measure("CaveBlockUpdate")) {
|
||||
for(Block b : updateNeeded) {
|
||||
BlockData orig = b.getBlockData();
|
||||
b.setBlockData(AIR, false);
|
||||
b.setBlockData(orig, true);
|
||||
}
|
||||
for(Block b : updateNeeded) {
|
||||
BlockData orig = b.getBlockData();
|
||||
b.setBlockData(AIR, false);
|
||||
b.setBlockData(orig, true);
|
||||
}
|
||||
/*for(Map.Entry<Vector, CarvingData.CarvingType> e : new SimplexCarver(chunk.getX(), chunk.getZ()).carve(chunk.getX(), chunk.getZ(), world).getCarvedBlocks().entrySet()) {
|
||||
Vector v = e.getKey();
|
||||
|
@ -14,15 +14,18 @@ import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.polydev.gaea.generation.GenerationPhase;
|
||||
import org.polydev.gaea.math.MathUtil;
|
||||
import org.polydev.gaea.math.Range;
|
||||
import org.polydev.gaea.population.GaeaBlockPopulator;
|
||||
import org.polydev.gaea.profiler.ProfileFuture;
|
||||
import org.polydev.gaea.tree.Tree;
|
||||
import org.polydev.gaea.util.FastRandom;
|
||||
import org.polydev.gaea.util.GlueList;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
|
||||
public class TreePopulator extends GaeaBlockPopulator {
|
||||
private static void doTrees(@NotNull UserDefinedBiome biome, TerraWorld world, @NotNull Random random, @NotNull Chunk chunk, int x, int z) {
|
||||
for(Block block : getValidTreeSpawnsAt(chunk, x, z, new Range(0, 254))) {
|
||||
@ -55,11 +58,12 @@ public class TreePopulator extends GaeaBlockPopulator {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("try")
|
||||
public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk chunk) {
|
||||
public void populate(@NotNull World world, @NotNull Random r, @NotNull Chunk chunk) {
|
||||
try(ProfileFuture ignored = TerraProfiler.fromWorld(world).measure("TreeTime")) {
|
||||
TerraWorld tw = TerraWorld.getWorld(world);
|
||||
if(!tw.isSafe()) return;
|
||||
TerraBiomeGrid grid = tw.getGrid();
|
||||
FastRandom random = new FastRandom(MathUtil.getCarverChunkSeed(chunk.getX(), chunk.getZ(), world.getSeed()));
|
||||
for(int x = 0; x < 16; x += 2) {
|
||||
for(int z = 0; z < 16; z += 2) {
|
||||
UserDefinedBiome biome = (UserDefinedBiome) grid.getBiome((chunk.getX() << 4) + x, (chunk.getZ() << 4) + z, GenerationPhase.POPULATE);
|
||||
|
@ -4,6 +4,6 @@ language: "en_us"
|
||||
fail-type: SHUTDOWN
|
||||
dump-default: true
|
||||
biome-search-resolution: 4
|
||||
cache-size: 512
|
||||
cache-size: 256
|
||||
master-disable:
|
||||
caves: false
|
@ -13,7 +13,7 @@ public class NoiseTest {
|
||||
int a = 0;
|
||||
for(int i = 0; i < 200; i++) {
|
||||
long l = System.nanoTime();
|
||||
for(int j = 0; j < 5000; j++) {
|
||||
for(int j = 0; j < 1000; j++) {
|
||||
for(int x = 0; x < 4; x++) {
|
||||
for(int y = 0; y < 64; y++) {
|
||||
for(int z = 0; z < 4; z++) {
|
||||
@ -26,10 +26,12 @@ public class NoiseTest {
|
||||
System.out.print((long) n / 1000000 + "ms" + ((a % 10 == 0) ? "\n" : " "));
|
||||
a++;
|
||||
}
|
||||
System.out.println();
|
||||
System.out.println();
|
||||
System.out.println("No Cache:");
|
||||
for(int i = 0; i < 200; i++) {
|
||||
long l = System.nanoTime();
|
||||
for(int j = 0; j < 5000; j++) {
|
||||
for(int j = 0; j < 1000; j++) {
|
||||
for(int x = 0; x < 4; x++) {
|
||||
for(int y = 0; y < 64; y++) {
|
||||
for(int z = 0; z < 4; z++) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user