forked from mirror/BlueMap
Do render-sorting based on the spawnpoint or radius-render center
This commit is contained in:
parent
b8cd92b507
commit
67f1e03f00
@ -59,13 +59,16 @@ public RenderTask(String name, MapType mapType) {
|
||||
this.renderedTiles = 0;
|
||||
}
|
||||
|
||||
public void optimizeQueue() {
|
||||
public void optimizeQueue(Vector2i center) {
|
||||
//Find a good grid size to match the MCAWorlds chunk-cache size of 500
|
||||
Vector2d sortGridSize = new Vector2d(20, 20).div(mapType.getTileRenderer().getHiresModelManager().getTileSize().toDouble().div(16)).ceil().max(1, 1);
|
||||
|
||||
synchronized (renderTiles) {
|
||||
ArrayList<Vector2i> tileList = new ArrayList<>(renderTiles);
|
||||
tileList.sort((v1, v2) -> {
|
||||
v1 = v1.sub(center);
|
||||
v2 = v2.sub(center);
|
||||
|
||||
Vector2i v1SortGridPos = v1.toDouble().div(sortGridSize).floor().toInt();
|
||||
Vector2i v2SortGridPos = v2.toDouble().div(sortGridSize).floor().toInt();
|
||||
|
||||
|
@ -123,6 +123,7 @@ public void createMapRenderTask(CommandSource source, MapType map, Vector2i cent
|
||||
source.sendMessage(Text.of(TextColor.GOLD, "Collecting chunks..."));
|
||||
|
||||
String taskName = "world-render";
|
||||
Vector2i renderCenter = map.getWorld().getSpawnPoint().toVector2(true);
|
||||
|
||||
Predicate<Vector2i> filter;
|
||||
if (center == null || blockRadius < 0) {
|
||||
@ -130,6 +131,7 @@ public void createMapRenderTask(CommandSource source, MapType map, Vector2i cent
|
||||
} else {
|
||||
filter = c -> c.mul(16).distanceSquared(center) <= blockRadius * blockRadius;
|
||||
taskName = "radius-render";
|
||||
renderCenter = center;
|
||||
}
|
||||
|
||||
Collection<Vector2i> chunks = map.getWorld().getChunkList(filter);
|
||||
@ -142,7 +144,7 @@ public void createMapRenderTask(CommandSource source, MapType map, Vector2i cent
|
||||
|
||||
RenderTask task = new RenderTask(taskName, map);
|
||||
task.addTiles(tiles);
|
||||
task.optimizeQueue();
|
||||
task.optimizeQueue(renderCenter);
|
||||
plugin.getRenderManager().addRenderTask(task);
|
||||
|
||||
source.sendMessage(Text.of(TextColor.GREEN, tiles.size() + " tiles found! Task created."));
|
||||
|
@ -112,10 +112,12 @@ public void renderMaps(BlueMapService blueMap, boolean forceRender, boolean forc
|
||||
if (tiles.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Vector2i renderCenter = map.getWorld().getSpawnPoint().toVector2(true);
|
||||
|
||||
RenderTask task = new RenderTask(map.getId(), map);
|
||||
task.addTiles(tiles);
|
||||
task.optimizeQueue();
|
||||
task.optimizeQueue(renderCenter);
|
||||
|
||||
renderManager.addRenderTask(task);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user