DFS's should now run locally on each thread.
This commit is contained in:
parent
faa2cfd79f
commit
e8340bfc91
@ -21,10 +21,6 @@ public class BiomePerIslandGenerator implements IslandBiomeGenerator {
|
|||||||
private volatile IslandWorldMapper worldIslandMap;
|
private volatile IslandWorldMapper worldIslandMap;
|
||||||
private volatile BiomeSelector biomeSelector;
|
private volatile BiomeSelector biomeSelector;
|
||||||
private volatile World world;
|
private volatile World world;
|
||||||
private final DepthFirstSearch freshCachePropagator;
|
|
||||||
private final DepthFirstSearch existenceChecker;
|
|
||||||
private final FreshCachePropagationInfo freshCachePropInfo;
|
|
||||||
private final PreviousGenerationInfo existenceInfo;
|
|
||||||
private volatile Point2 currChunkCoords;
|
private volatile Point2 currChunkCoords;
|
||||||
private volatile Biome[][] localChunkCache;
|
private volatile Biome[][] localChunkCache;
|
||||||
|
|
||||||
@ -32,12 +28,8 @@ public class BiomePerIslandGenerator implements IslandBiomeGenerator {
|
|||||||
|
|
||||||
public BiomePerIslandGenerator() {
|
public BiomePerIslandGenerator() {
|
||||||
this.temperatureMapGenerator = new TemperatureMapGenerator();
|
this.temperatureMapGenerator = new TemperatureMapGenerator();
|
||||||
chunkBiomesCache = new Cache<>(4096);
|
chunkBiomesCache = new Cache<>(8192);
|
||||||
chunkGenStatusCache = new Cache<>(4096);
|
chunkGenStatusCache = new Cache<>(4096);
|
||||||
freshCachePropInfo = new FreshCachePropagationInfo();
|
|
||||||
freshCachePropagator = new DepthFirstSearch(freshCachePropInfo);
|
|
||||||
existenceInfo = new PreviousGenerationInfo();
|
|
||||||
existenceChecker = new DepthFirstSearch(existenceInfo);
|
|
||||||
localChunkCache = new Biome[16][16];
|
localChunkCache = new Biome[16][16];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,16 +64,19 @@ public class BiomePerIslandGenerator implements IslandBiomeGenerator {
|
|||||||
if (!worldIslandMap.isIsland(worldX, worldZ)) {
|
if (!worldIslandMap.isIsland(worldX, worldZ)) {
|
||||||
return biomeSelector.getOceanBiome(temperature);
|
return biomeSelector.getOceanBiome(temperature);
|
||||||
}
|
}
|
||||||
|
|
||||||
freshCachePropInfo.clear();
|
IslandBiomeInfo biomeInfo = new IslandBiomeInfo();
|
||||||
existenceChecker.setStartPosition(worldX, worldZ);
|
DepthFirstSearch prevBiomeFinder = new DepthFirstSearch(biomeInfo);
|
||||||
if (!existenceChecker.findTarget(existenceInfo)) {
|
prevBiomeFinder.setStartPosition(worldX, worldZ);
|
||||||
if (freshCachePropInfo.main == null) freshCachePropInfo.main = biomeSelector.getLandBiome(temperature);
|
if (!prevBiomeFinder.findTarget(biomeInfo)) {
|
||||||
if (freshCachePropInfo.shore == null) freshCachePropInfo.shore = biomeSelector.getShoreBiome(freshCachePropInfo.main, temperature);
|
if (biomeInfo.main == null) biomeInfo.main = biomeSelector.getLandBiome(temperature);
|
||||||
if (freshCachePropInfo.shallow == null) freshCachePropInfo.shallow = biomeSelector.getOceanBiome(temperature);
|
if (biomeInfo.shore == null) biomeInfo.shore = biomeSelector.getShoreBiome(biomeInfo.main, temperature);
|
||||||
|
if (biomeInfo.shallow == null) biomeInfo.shallow = biomeSelector.getOceanBiome(temperature);
|
||||||
}
|
}
|
||||||
freshCachePropagator.setStartPosition(worldX, worldZ);
|
FreshCachePropagationInfo propInfo = new FreshCachePropagationInfo(biomeInfo.main, biomeInfo.shore, biomeInfo.shallow);
|
||||||
freshCachePropagator.findTarget(freshCachePropInfo);
|
DepthFirstSearch prop = new DepthFirstSearch(propInfo);
|
||||||
|
prop.setStartPosition(worldX, worldZ);
|
||||||
|
prop.findTarget(propInfo);
|
||||||
return getBiome(worldX, worldZ);
|
return getBiome(worldX, worldZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,9 +125,7 @@ public class BiomePerIslandGenerator implements IslandBiomeGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class FreshCachePropagationInfo implements CoordinateTargetValidatable, CoordinateValidatable {
|
private class FreshCachePropagationInfo implements CoordinateTargetValidatable, CoordinateValidatable {
|
||||||
public Biome shore;
|
public final Biome main, shore, shallow;
|
||||||
public Biome main;
|
|
||||||
public Biome shallow;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCoordinateTarget(int x, int y) {
|
public boolean isCoordinateTarget(int x, int y) {
|
||||||
@ -154,37 +147,47 @@ public class BiomePerIslandGenerator implements IslandBiomeGenerator {
|
|||||||
return chunkCoords.fastEquals(currChunkCoords) && worldIslandMap.isIsland(x, y);
|
return chunkCoords.fastEquals(currChunkCoords) && worldIslandMap.isIsland(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean allBiomesAcquired() {
|
public FreshCachePropagationInfo(Biome main, Biome shore, Biome shallow) {
|
||||||
return shore != null && main != null && shallow != null;
|
this.main = main;
|
||||||
}
|
this.shore = shore;
|
||||||
|
this.shallow = shallow;
|
||||||
public void clear() {
|
|
||||||
main = null;
|
|
||||||
shore = null;
|
|
||||||
shallow = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class PreviousGenerationInfo implements CoordinateTargetValidatable, CoordinateValidatable {
|
private class IslandBiomeInfo implements CoordinateTargetValidatable, CoordinateValidatable {
|
||||||
|
private boolean isLand, isShore, isShallow;
|
||||||
|
public Biome main, shore, shallow;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean validate(int x, int y) {
|
public boolean validate(int x, int y) {
|
||||||
|
isShore = false;
|
||||||
|
isShallow = false;
|
||||||
|
isLand = false;
|
||||||
return worldIslandMap.isIsland(x, y);
|
return worldIslandMap.isIsland(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCoordinateTarget(int x, int y) {
|
public boolean isCoordinateTarget(int x, int y) {
|
||||||
if (freshCachePropInfo.main == null && worldIslandMap.isLand(x, y) && !worldIslandMap.isShore(x, y)) {
|
if ((isLand = worldIslandMap.isLand(x, y))) {
|
||||||
freshCachePropInfo.main = getBiome(x, y);
|
isShore = worldIslandMap.isShore(x, y);
|
||||||
|
} else {
|
||||||
|
isShallow = worldIslandMap.isShallowPortion(x, y);
|
||||||
}
|
}
|
||||||
if (freshCachePropInfo.shore == null && worldIslandMap.isShore(x, y)) {
|
|
||||||
freshCachePropInfo.shore = getBiome(x, y);
|
if (main == null && isLand && !isShore) {
|
||||||
|
main = getBiome(x, y);
|
||||||
|
} else
|
||||||
|
if (shore == null && isShore) {
|
||||||
|
shore = getBiome(x, y);
|
||||||
|
} else
|
||||||
|
if (shallow == null && isShallow) {
|
||||||
|
shallow = getBiome(x, y);
|
||||||
}
|
}
|
||||||
if (freshCachePropInfo.shallow == null && worldIslandMap.isShallowPortion(x, y)) {
|
return allBiomesAcquired();
|
||||||
freshCachePropInfo.shallow = getBiome(x, y);
|
|
||||||
}
|
|
||||||
return freshCachePropInfo.allBiomesAcquired();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean allBiomesAcquired() {
|
||||||
|
return shore != null && main != null && shallow != null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user