From f1e3210c7ab3fc55b4f1a8cf7305b72510f2d4b0 Mon Sep 17 00:00:00 2001 From: Daniel Mills Date: Thu, 6 Aug 2020 02:58:40 -0400 Subject: [PATCH] Performance Improvements --- pom.xml | 2 ++ .../iris/gen/TerrainChunkGenerator.java | 34 ++++++++++++++----- .../volmit/iris/gen/layer/GenLayerBiome.java | 4 +-- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index 6053c0a17..8a92380a2 100644 --- a/pom.xml +++ b/pom.xml @@ -120,12 +120,14 @@ + org.spigotmc spigot-api 1.16.1-R0.1-SNAPSHOT provided + org.projectlombok lombok diff --git a/src/main/java/com/volmit/iris/gen/TerrainChunkGenerator.java b/src/main/java/com/volmit/iris/gen/TerrainChunkGenerator.java index be81cd41d..211d193f8 100644 --- a/src/main/java/com/volmit/iris/gen/TerrainChunkGenerator.java +++ b/src/main/java/com/volmit/iris/gen/TerrainChunkGenerator.java @@ -74,6 +74,7 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator try { + KList surfaces = new KList<>(); int highestPlaced = 0; BlockData block; int fluidHeight = getDimension().getFluidHeight(); @@ -82,11 +83,11 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator double wx = getZoomed(ox); double wz = getZoomed(oz); int depth = 0; - double noise = getNoiseHeight(rx, rz); - int height = (int) Math.round(noise) + fluidHeight; + double noise = getNoiseHeight(rx, rz) + fluidHeight; + int height = (int) Math.round(noise); boolean carvable = getDimension().isCarving() && height > getDimension().getCarvingMin(); IrisRegion region = sampleRegion(rx, rz); - BiomeResult biomeResult = sampleTrueBiome(rx, rz); + BiomeResult biomeResult = sampleTrueBiome(rx, rz, noise); IrisBiome biome = biomeResult.getBiome(); double airReversal = biomeResult.getHeightOffset(); @@ -206,13 +207,12 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator sliver.set(k, block); highestPlaced = Math.max(highestPlaced, k); - if(!cavernSurface && (k == height && block.getMaterial().isSolid() && k < fluidHeight)) { decorateUnderwater(biome, sliver, wx, k, wz, rx, rz, block); } - if((carvable && cavernSurface) || (k == Math.max(height, fluidHeight) && block.getMaterial().isSolid() && k < 255 && k >= fluidHeight)) + if((carvable && cavernSurface) && !(k == Math.max(height, fluidHeight) && block.getMaterial().isSolid() && k < 255 && k >= fluidHeight)) { decorateLand(biome, sliver, wx, k, wz, rx, rz, block); } @@ -256,10 +256,22 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator } } + block = sliver.get(Math.max(height, fluidHeight)); + + if(block.getMaterial().isSolid()) + { + decorateLand(biome, sliver, wx, Math.max(height, fluidHeight), wz, rx, rz, block); + } + if(!sampled && cachingAllowed && highestPlaced < height) { cacheHeightMap[(z << 4) | x] = highestPlaced; } + + for(Runnable i : surfaces) + { + i.run(); + } } catch(Throwable e) @@ -502,7 +514,7 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator return getBiomeHeight(wx, wz, rx, rz); } - public BiomeResult sampleTrueBiomeBase(int x, int z) + public BiomeResult sampleTrueBiomeBase(int x, int z, int height) { if(!getDimension().getFocus().equals("")) { @@ -512,7 +524,6 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator double wx = getModifiedX(x, z); double wz = getModifiedZ(x, z); IrisRegion region = sampleRegion(x, z); - int height = (int) Math.round(getTerrainHeight(x, z)); double sh = region.getShoreHeight(wx, wz); IrisBiome current = sampleBiome(x, z).getBiome(); @@ -569,6 +580,11 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator } public BiomeResult sampleTrueBiome(int x, int z) + { + return sampleTrueBiome(x, z, getTerrainHeight(x, z)); + } + + public BiomeResult sampleTrueBiome(int x, int z, double noise) { if(!getDimension().getFocus().equals("")) { @@ -583,9 +599,9 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator double wx = getModifiedX(x, z); double wz = getModifiedZ(x, z); IrisRegion region = sampleRegion(x, z); - int height = sampleHeight(x, z); + int height = (int) Math.round(noise); double sh = region.getShoreHeight(wx, wz); - BiomeResult res = sampleTrueBiomeBase(x, z); + BiomeResult res = sampleTrueBiomeBase(x, z, height); IrisBiome current = res.getBiome(); if(current.isSea() && height > getDimension().getFluidHeight() - sh) diff --git a/src/main/java/com/volmit/iris/gen/layer/GenLayerBiome.java b/src/main/java/com/volmit/iris/gen/layer/GenLayerBiome.java index af7882243..2a384ea9b 100644 --- a/src/main/java/com/volmit/iris/gen/layer/GenLayerBiome.java +++ b/src/main/java/com/volmit/iris/gen/layer/GenLayerBiome.java @@ -119,11 +119,11 @@ public class GenLayerBiome extends GenLayer public InferredType getType(double bx, double bz, IrisRegion regionData) { - bridgeGenerator.setShuffle(0); + bridgeGenerator.setShuffle(47); bridgeGenerator.setCellScale(0.33 / iris.getDimension().getContinentZoom()); double x = bx / iris.getDimension().getBiomeZoom(); double z = bz / iris.getDimension().getBiomeZoom(); - return bridgeGenerator.getIndex(x, z, 2) == 1 ? InferredType.SEA : InferredType.LAND; + return bridgeGenerator.getIndex(x, z, 2) == 1 ? InferredType.LAND : InferredType.SEA; } public BiomeResult generateBiomeData(double bx, double bz, IrisRegion regionData, RarityCellGenerator cell, KList biomes, InferredType inferredType)