This commit is contained in:
Daniel Mills 2020-07-30 03:52:23 -04:00
parent aec5486144
commit d92c96ecc2
6 changed files with 16 additions and 21 deletions

View File

@ -831,7 +831,7 @@ public class Iris extends JavaPlugin implements BoardProvider
imsg(i, "Creating Iris " + dimm + "..."); imsg(i, "Creating Iris " + dimm + "...");
} }
int tc = Math.max(Runtime.getRuntime().availableProcessors(), 4); int tc = Math.max(Runtime.getRuntime().availableProcessors() * 4, 4);
IrisChunkGenerator gx = new IrisChunkGenerator(dimm, tc); IrisChunkGenerator gx = new IrisChunkGenerator(dimm, tc);
info("Generating with " + tc + " threads per chunk"); info("Generating with " + tc + " threads per chunk");
O<Boolean> done = new O<Boolean>(); O<Boolean> done = new O<Boolean>();

View File

@ -1,9 +0,0 @@
package com.volmit.iris;
import lombok.Data;
@Data
public class IrisSettings
{
private int threads = 8;
}

View File

@ -170,8 +170,6 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
@Override @Override
protected void onPostGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid, HeightMap height, BiomeMap biomeMap) protected void onPostGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid, HeightMap height, BiomeMap biomeMap)
{ {
setCaching(false);
if(getSliverCache().size() > 20000) if(getSliverCache().size() > 20000)
{ {
getSliverCache().clear(); getSliverCache().clear();
@ -194,7 +192,6 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
p.end(); p.end();
getMetrics().getParallax().put(p.getMilliseconds()); getMetrics().getParallax().put(p.getMilliseconds());
super.onPostParallaxPostGenerate(random, x, z, data, grid, height, biomeMap); super.onPostParallaxPostGenerate(random, x, z, data, grid, height, biomeMap);
setCaching(true);
} }
protected void injectBiomeSky(int x, int z, BiomeGrid grid) protected void injectBiomeSky(int x, int z, BiomeGrid grid)

View File

@ -26,6 +26,7 @@ public abstract class ParallelChunkGenerator extends BiomeChunkGenerator
protected int cacheX; protected int cacheX;
protected int cacheZ; protected int cacheZ;
private ReentrantLock genlock; private ReentrantLock genlock;
protected boolean cachingAllowed;
public ParallelChunkGenerator(String dimensionName, int threads) public ParallelChunkGenerator(String dimensionName, int threads)
{ {
@ -77,7 +78,6 @@ public abstract class ParallelChunkGenerator extends BiomeChunkGenerator
String key = "c" + x + "," + z; String key = "c" + x + "," + z;
BiomeMap biomeMap = new BiomeMap(); BiomeMap biomeMap = new BiomeMap();
int ii, jj; int ii, jj;
unsafe = true;
for(ii = 0; ii < 16; ii++) for(ii = 0; ii < 16; ii++)
{ {
@ -97,11 +97,14 @@ public abstract class ParallelChunkGenerator extends BiomeChunkGenerator
} }
} }
setCachingAllowed(true);
setUnsafe(true);
accelerant.waitFor(key); accelerant.waitFor(key);
setUnsafe(false);
setCachingAllowed(false);
map.write(data, grid, height); map.write(data, grid, height);
getMetrics().getTerrain().put(p.getMilliseconds()); getMetrics().getTerrain().put(p.getMilliseconds());
p = PrecisionStopwatch.start(); p = PrecisionStopwatch.start();
unsafe = false;
onPostGenerate(random, x, z, data, grid, height, biomeMap); onPostGenerate(random, x, z, data, grid, height, biomeMap);
genlock.unlock(); genlock.unlock();
} }

View File

@ -41,14 +41,13 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
private int[] cacheHeightMap; private int[] cacheHeightMap;
private IrisBiome[] cacheTrueBiome; private IrisBiome[] cacheTrueBiome;
private ReentrantLock cacheLock; private ReentrantLock cacheLock;
private boolean caching;
public TerrainChunkGenerator(String dimensionName, int threads) public TerrainChunkGenerator(String dimensionName, int threads)
{ {
super(dimensionName, threads); super(dimensionName, threads);
cacheHeightMap = new int[256]; cacheHeightMap = new int[256];
cacheTrueBiome = new IrisBiome[256]; cacheTrueBiome = new IrisBiome[256];
caching = true; cachingAllowed = true;
cacheLock = new ReentrantLock(); cacheLock = new ReentrantLock();
} }
@ -100,7 +99,7 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
throw new RuntimeException("Null Biome!"); throw new RuntimeException("Null Biome!");
} }
if(caching) if(cachingAllowed)
{ {
try try
{ {
@ -245,7 +244,7 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
} }
} }
if(caching && highestPlaced < height) if(cachingAllowed && highestPlaced < height)
{ {
cacheHeightMap[(z << 4) | x] = highestPlaced; cacheHeightMap[(z << 4) | x] = highestPlaced;
} }

View File

@ -49,7 +49,7 @@ public class GenLayerCave extends GenLayer
gg.SetCellularReturnType(CellularReturnType.Distance2Sub); gg.SetCellularReturnType(CellularReturnType.Distance2Sub);
gg.SetCellularDistanceFunction(CellularDistanceFunction.Natural); gg.SetCellularDistanceFunction(CellularDistanceFunction.Natural);
for(int i = 0; i < 2; i++) for(int i = 0; i < 3; i++)
{ {
double wx = wxx + (shuffle.noise(wxx, wzz) * shuffleDistance); double wx = wxx + (shuffle.noise(wxx, wzz) * shuffleDistance);
double wz = wzz + (shuffle.noise(wzz, wxx) * shuffleDistance); double wz = wzz + (shuffle.noise(wzz, wxx) * shuffleDistance);
@ -57,7 +57,7 @@ public class GenLayerCave extends GenLayer
double baseWidth = (14 * iris.getDimension().getCaveScale()); double baseWidth = (14 * iris.getDimension().getCaveScale());
double distanceCheck = 0.0132 * baseWidth; double distanceCheck = 0.0132 * baseWidth;
double distanceTake = 0.0022 * baseWidth; double distanceTake = 0.0022 * baseWidth;
double drop = (-i * 7) + 44 + iris.getDimension().getCaveShift(); double drop = (-i * 17) + 44 + iris.getDimension().getCaveShift();
double caveHeightNoise = incline * gincline.noise((wx + (10000 * i)), (wz - (10000 * i))); double caveHeightNoise = incline * gincline.noise((wx + (10000 * i)), (wz - (10000 * i)));
caveHeightNoise += shuffle.fitDoubleD(-1, 1, wxx - caveHeightNoise, wzz + caveHeightNoise) * 3; caveHeightNoise += shuffle.fitDoubleD(-1, 1, wxx - caveHeightNoise, wzz + caveHeightNoise) * 3;
@ -73,6 +73,11 @@ public class GenLayerCave extends GenLayer
int pu = (int) (caveHeight + tunnelHeight); int pu = (int) (caveHeight + tunnelHeight);
int pd = (int) (caveHeight - tunnelHeight); int pd = (int) (caveHeight - tunnelHeight);
if((pu > 255 && pd > 255) || (pu < 0 && pd < 0))
{
continue;
}
if(data == null) if(data == null)
{ {
ceiling = pu > ceiling ? pu : ceiling; ceiling = pu > ceiling ? pu : ceiling;