Skip to content

Commit 42e53f0

Browse files
committed
Fixes for lowres lighting and map-purging/saving, tweak default settings
1 parent 4be78ff commit 42e53f0

File tree

10 files changed

+102
-25
lines changed

10 files changed

+102
-25
lines changed

BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/WebappConfig.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ public class WebappConfig {
2828
private int maxZoomDistance = 100000;
2929

3030
private int hiresSliderMax = 500;
31-
private int hiresSliderDefault = 200;
32-
private int hiresSliderMin = 50;
31+
private int hiresSliderDefault = 100;
32+
private int hiresSliderMin = 0;
3333

34-
private int lowresSliderMax = 10000;
34+
private int lowresSliderMax = 7000;
3535
private int lowresSliderDefault = 2000;
3636
private int lowresSliderMin = 500;
3737

BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/plugin/commands/CommandHelper.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import de.bluecolored.bluemap.common.plugin.text.TextFormat;
3131
import de.bluecolored.bluemap.common.rendermanager.RenderManager;
3232
import de.bluecolored.bluemap.common.rendermanager.RenderTask;
33-
import de.bluecolored.bluemap.core.map.BmMap;
3433
import de.bluecolored.bluemap.core.world.World;
3534
import org.apache.commons.lang3.time.DurationFormatUtils;
3635

@@ -80,6 +79,11 @@ public List<Text> createStatusMessage(){
8079
lines.add(Text.of(TextColor.GRAY, " [" + getRefForTask(task) + "] ", TextColor.GOLD, task.getDescription()));
8180

8281
if (i == 0) {
82+
String detail = task.getDetail().orElse(null);
83+
if (detail != null) {
84+
lines.add(Text.of(TextColor.GRAY, " Detail: ", TextColor.WHITE, detail));
85+
}
86+
8387
lines.add(Text.of(TextColor.GRAY, " Progress: ", TextColor.WHITE,
8488
(Math.round(task.estimateProgress() * 10000) / 100.0) + "%"));
8589

BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/rendermanager/CombinedRenderTask.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@
2626

2727
import de.bluecolored.bluemap.api.debug.DebugDump;
2828

29-
import java.util.ArrayList;
30-
import java.util.Collection;
31-
import java.util.Collections;
32-
import java.util.List;
29+
import java.util.*;
3330

3431
@DebugDump
3532
public class CombinedRenderTask<T extends RenderTask> implements RenderTask {
@@ -105,8 +102,11 @@ public boolean contains(RenderTask task) {
105102

106103
@Override
107104
public String getDescription() {
108-
//return description + " (" + (this.currentTaskIndex + 1) + "/" + tasks.size() + ")";
109105
return description;
110106
}
111107

108+
@Override
109+
public Optional<String> getDetail() {
110+
return Optional.ofNullable(this.tasks.get(this.currentTaskIndex).getDescription());
111+
}
112112
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package de.bluecolored.bluemap.common.rendermanager;
2+
3+
import de.bluecolored.bluemap.core.map.BmMap;
4+
5+
import java.util.concurrent.atomic.AtomicBoolean;
6+
7+
public class MapSaveTask implements RenderTask {
8+
9+
private final BmMap map;
10+
private final AtomicBoolean saved;
11+
12+
public MapSaveTask(BmMap map) {
13+
this.map = map;
14+
this.saved = new AtomicBoolean(false);
15+
}
16+
17+
@Override
18+
public void doWork() {
19+
if (this.saved.compareAndSet(false, true)) {
20+
map.save();
21+
}
22+
}
23+
24+
@Override
25+
public boolean hasMoreWork() {
26+
return !this.saved.get();
27+
}
28+
29+
@Override
30+
public void cancel() {
31+
this.saved.set(true);
32+
}
33+
34+
@Override
35+
public String getDescription() {
36+
return "Save map '" + map.getId() + "'";
37+
}
38+
39+
@Override
40+
public boolean contains(RenderTask task) {
41+
if (this == task) return true;
42+
if (task == null) return false;
43+
if (getClass() != task.getClass()) return false;
44+
MapSaveTask other = (MapSaveTask) task;
45+
return map.getId().equals(other.map.getId());
46+
}
47+
48+
}

BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/rendermanager/MapUpdateTask.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
import java.util.stream.Collectors;
3939

4040
@DebugDump
41-
public class MapUpdateTask extends CombinedRenderTask<WorldRegionRenderTask> {
41+
public class MapUpdateTask extends CombinedRenderTask<RenderTask> {
4242

4343
private final BmMap map;
4444
private final Collection<Vector2i> regions;
@@ -77,17 +77,25 @@ public Collection<Vector2i> getRegions() {
7777
return regions;
7878
}
7979

80-
private static Collection<WorldRegionRenderTask> createTasks(BmMap map, Collection<Vector2i> regions, boolean force) {
81-
List<WorldRegionRenderTask> tasks = new ArrayList<>(regions.size());
82-
regions.forEach(region -> tasks.add(new WorldRegionRenderTask(map, region, force)));
80+
private static Collection<RenderTask> createTasks(BmMap map, Collection<Vector2i> regions, boolean force) {
81+
ArrayList<WorldRegionRenderTask> regionTasks = new ArrayList<>(regions.size());
82+
regions.forEach(region -> regionTasks.add(new WorldRegionRenderTask(map, region, force)));
8383

8484
// get spawn region
8585
World world = map.getWorld();
8686
Vector2i spawnPoint = world.getSpawnPoint().toVector2(true);
8787
Grid regionGrid = world.getRegionGrid();
8888
Vector2i spawnRegion = regionGrid.getCell(spawnPoint);
8989

90-
tasks.sort(WorldRegionRenderTask.defaultComparator(spawnRegion));
90+
// sort tasks by distance to the spawn region
91+
regionTasks.sort(WorldRegionRenderTask.defaultComparator(spawnRegion));
92+
93+
// save map before and after the whole update
94+
ArrayList<RenderTask> tasks = new ArrayList<>(regionTasks.size() + 2);
95+
tasks.add(new MapSaveTask(map));
96+
tasks.addAll(regionTasks);
97+
tasks.add(new MapSaveTask(map));
98+
9199
return tasks;
92100
}
93101

BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/rendermanager/RenderTask.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
*/
2525
package de.bluecolored.bluemap.common.rendermanager;
2626

27+
import java.util.Optional;
28+
2729
public interface RenderTask {
2830

2931
void doWork() throws Exception;
@@ -55,4 +57,8 @@ default boolean contains(RenderTask task) {
5557

5658
String getDescription();
5759

60+
default Optional<String> getDetail() {
61+
return Optional.empty();
62+
}
63+
5864
}

BlueMapCommon/src/main/resources/de/bluecolored/bluemap/config/webapp.conf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ enable-free-flight: true
2929
# The default map and camera-location where a user will start after opening the webapp.
3030
# This is in form of the url-anchor: Open your map in a browser and look at the url, everything after the '#' is the value for this setting.
3131
# Default is "no anchor" -> The camera will start with the topmost map and at that map's starting point.
32-
#start-location: "overworld:0:16:-32:390:0.1:0.19:0:0:perspective"
32+
#start-location: "world:0:16:-32:390:0.1:0.19:0:0:perspective"
3333

3434
# The minimum (closest) and maximum (furthest) distance (in blocks) that the camera can be from the ground
3535
min-zoom-distance: 5
@@ -42,14 +42,14 @@ resolution-default: 1
4242

4343
# The min, max and default values of the hires render-distance slider (settings-menu)
4444
# The values are in blocks.
45-
# Default is max:500 default:200 and min:50
45+
# Default is max:500 default:100 and min:0
4646
hires-slider-max: 500
47-
hires-slider-default: 200
48-
hires-slider-min: 50
47+
hires-slider-default: 100
48+
hires-slider-min: 0
4949

5050
# The min, max and default values of the lowres render-distance slider (settings-menu)
5151
# The values are in blocks.
52-
# Default is max:10000 default:2000 and min:500
53-
lowres-slider-max: 10000
52+
# Default is max:7000 default:2000 and min:500
53+
lowres-slider-max: 7000
5454
lowres-slider-default: 2000
5555
lowres-slider-min: 500

BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/BmMap.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ public synchronized void save() {
130130
lowresTileManager.save();
131131
saveRenderState();
132132
saveMarkerState();
133+
saveMapSettings();
133134

135+
// only save texture gallery if not present in storage
134136
try {
135137
if (storage.readMeta(id, MetaType.TEXTURES).isEmpty())
136138
saveTextureGallery();

BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/hires/HiresModelRenderer.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,19 @@ public void render(World world, Vector3i modelMin, Vector3i modelMax, HiresTileM
8585

8686
modelFactory.render(block, blockModel, blockColor);
8787

88+
//update topBlockLight
89+
if (
90+
y >= renderSettings.getRemoveCavesBelowY() ||
91+
(renderSettings.isCaveDetectionUsesBlockLight() ? block.getBlockLightLevel() : block.getSunLightLevel()) > 0
92+
) {
93+
if (blockColor.a > 0) {
94+
topBlockLight = Math.floor(topBlockLight * (1 - blockColor.a));
95+
}
96+
topBlockLight = Math.max(topBlockLight, block.getBlockLightLevel());
97+
} else {
98+
topBlockLight = 0;
99+
}
100+
88101
// skip empty blocks
89102
if (blockModel.getSize() <= 0) continue;
90103

@@ -95,11 +108,7 @@ public void render(World world, Vector3i modelMin, Vector3i modelMax, HiresTileM
95108
if (blockColor.a > 0) {
96109
maxHeight = y;
97110
columnColor.overlay(blockColor.premultiplied());
98-
topBlockLight = Math.floor(topBlockLight * (1 - blockColor.a));
99111
}
100-
101-
//update topBlockLight
102-
topBlockLight = Math.max(topBlockLight, block.getBlockLightLevel());
103112
}
104113
}
105114

0 commit comments

Comments
 (0)