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

@@ -170,8 +170,6 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
@Override
protected void onPostGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid, HeightMap height, BiomeMap biomeMap)
{
setCaching(false);
if(getSliverCache().size() > 20000)
{
getSliverCache().clear();
@@ -194,7 +192,6 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
p.end();
getMetrics().getParallax().put(p.getMilliseconds());
super.onPostParallaxPostGenerate(random, x, z, data, grid, height, biomeMap);
setCaching(true);
}
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 cacheZ;
private ReentrantLock genlock;
protected boolean cachingAllowed;
public ParallelChunkGenerator(String dimensionName, int threads)
{
@@ -77,7 +78,6 @@ public abstract class ParallelChunkGenerator extends BiomeChunkGenerator
String key = "c" + x + "," + z;
BiomeMap biomeMap = new BiomeMap();
int ii, jj;
unsafe = true;
for(ii = 0; ii < 16; ii++)
{
@@ -97,11 +97,14 @@ public abstract class ParallelChunkGenerator extends BiomeChunkGenerator
}
}
setCachingAllowed(true);
setUnsafe(true);
accelerant.waitFor(key);
setUnsafe(false);
setCachingAllowed(false);
map.write(data, grid, height);
getMetrics().getTerrain().put(p.getMilliseconds());
p = PrecisionStopwatch.start();
unsafe = false;
onPostGenerate(random, x, z, data, grid, height, biomeMap);
genlock.unlock();
}

View File

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