Actually subtract a tile-position not a block-position to get the correct center

This commit is contained in:
Blue (Lukas Rieger) 2020-09-30 15:46:42 +02:00
parent 1312f4bf96
commit 00b9b05431
No known key found for this signature in database
GPG Key ID: 904C4995F9E1F800
1 changed files with 6 additions and 3 deletions

View File

@ -36,6 +36,7 @@ import java.util.UUID;
import com.flowpowered.math.vector.Vector2d;
import com.flowpowered.math.vector.Vector2i;
import com.flowpowered.math.vector.Vector3i;
public class RenderTask {
@ -59,15 +60,17 @@ public class RenderTask {
this.renderedTiles = 0;
}
public void optimizeQueue(Vector2i center) {
public void optimizeQueue(Vector2i centerBlockPos) {
//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);
Vector2i centerTile = mapType.getTileRenderer().getHiresModelManager().posToTile(new Vector3i(centerBlockPos.getX(), 0, centerBlockPos.getY()));
synchronized (renderTiles) {
ArrayList<Vector2i> tileList = new ArrayList<>(renderTiles);
tileList.sort((v1, v2) -> {
v1 = v1.sub(center);
v2 = v2.sub(center);
v1 = v1.sub(centerTile);
v2 = v2.sub(centerTile);
Vector2i v1SortGridPos = v1.toDouble().div(sortGridSize).floor().toInt();
Vector2i v2SortGridPos = v2.toDouble().div(sortGridSize).floor().toInt();