Improve min-inhabited-time calculations and add hidden radius setting

This commit is contained in:
Lukas Rieger (Blue) 2022-12-17 15:06:18 +01:00
parent 2a94b0faab
commit cf93cb56c4
No known key found for this signature in database
GPG Key ID: 2D09EC5ED2687FF2
3 changed files with 41 additions and 4 deletions

View File

@ -69,6 +69,7 @@ public class MapConfig implements MapSettings {
private transient Vector3i max = null;
private long minInhabitedTime = 0;
private int minInhabitedTimeRadius = 0;
private boolean renderEdges = true;
@ -96,34 +97,42 @@ public Path getWorld() {
return world;
}
@Override
public int getSorting() {
return sorting;
}
@Override
public Optional<Vector2i> getStartPos() {
return Optional.ofNullable(startPos);
}
@Override
public String getSkyColor() {
return skyColor;
}
@Override
public float getAmbientLight() {
return ambientLight;
}
@Override
public int getWorldSkyLight() {
return worldSkyLight;
}
@Override
public int getRemoveCavesBelowY() {
return removeCavesBelowY;
}
@Override
public boolean isCaveDetectionUsesBlockLight() {
return caveDetectionUsesBlockLight;
}
@Override
public int getCaveDetectionOceanFloor() {
return caveDetectionOceanFloor;
}
@ -138,10 +147,17 @@ public Vector3i getMaxPos() {
return max;
}
@Override
public long getMinInhabitedTime() {
return minInhabitedTime;
}
@Override
public int getMinInhabitedTimeRadius() {
return minInhabitedTimeRadius;
}
@Override
public boolean isRenderEdges() {
return renderEdges;
}
@ -164,18 +180,22 @@ public ConfigurationNode getMarkerSets() {
return markerSets;
}
@Override
public int getHiresTileSize() {
return hiresTileSize;
}
@Override
public int getLowresTileSize() {
return lowresTileSize;
}
@Override
public int getLodCount() {
return lodCount;
}
@Override
public int getLodFactor() {
return lodFactor;
}

View File

@ -130,7 +130,7 @@ public void doWork() {
}
//Logger.global.logInfo("Working on " + worldRegion + " - Tile " + tile);
if (isAllChunksInTileGenerated(tile)) {
if (tileRenderPreconditions(tile)) {
map.renderTile(tile); // <- actual work
}
@ -143,22 +143,37 @@ public void doWork() {
}
}
private boolean isAllChunksInTileGenerated(Vector2i tile) {
private boolean tileRenderPreconditions(Vector2i tile) {
Grid tileGrid = map.getHiresModelManager().getTileGrid();
Grid chunkGrid = map.getWorld().getChunkGrid();
Vector2i minChunk = tileGrid.getCellMin(tile, chunkGrid);
Vector2i maxChunk = tileGrid.getCellMax(tile, chunkGrid);
long minInhab = map.getMapSettings().getMinInhabitedTime();
int minInhabRadius = map.getMapSettings().getMinInhabitedTimeRadius();
if (minInhabRadius < 0) minInhabRadius = 0;
if (minInhabRadius > 16) minInhabRadius = 16; // sanity check
boolean isInhabited = false;
for (int x = minChunk.getX(); x <= maxChunk.getX(); x++) {
for (int z = minChunk.getY(); z <= maxChunk.getY(); z++) {
Chunk chunk = map.getWorld().getChunk(x, z);
if (!chunk.isGenerated()) return false;
if (chunk.getInhabitedTime() < map.getMapSettings().getMinInhabitedTime()) return false;
if (chunk.getInhabitedTime() < minInhab) isInhabited = true;
}
}
return true;
if (minInhabRadius > 0) {
for (int x = minChunk.getX() - minInhabRadius; x <= maxChunk.getX() + minInhabRadius; x++) {
for (int z = minChunk.getY() - minInhabRadius; z <= maxChunk.getY() + minInhabRadius; z++) {
Chunk chunk = map.getWorld().getChunk(x, z);
if (chunk.getInhabitedTime() < minInhab) isInhabited = true;
}
}
}
return isInhabited;
}
private void complete() {

View File

@ -39,6 +39,8 @@ public interface MapSettings extends RenderSettings {
long getMinInhabitedTime();
int getMinInhabitedTimeRadius();
int getHiresTileSize();
int getLowresTileSize();