This commit is contained in:
@@ -99,6 +99,7 @@ public class DirtyUpdateService {
|
|||||||
int standardViewDist = server.getPlayerList().getViewDistance() * 16;
|
int standardViewDist = server.getPlayerList().getViewDistance() * 16;
|
||||||
int m = (1 << (lvl + 1)) - 1;
|
int m = (1 << (lvl + 1)) - 1;
|
||||||
int perPlayerBudget = 25;
|
int perPlayerBudget = 25;
|
||||||
|
java.util.ArrayList<long[]> cols = new java.util.ArrayList<>();
|
||||||
for (int dx = 0; dx <= m; dx++) {
|
for (int dx = 0; dx <= m; dx++) {
|
||||||
for (int dz = 0; dz <= m; dz++) {
|
for (int dz = 0; dz <= m; dz++) {
|
||||||
double centerX = (((sx << (lvl + 1)) | dx) * sectionSize) + (sectionSize / 2.0);
|
double centerX = (((sx << (lvl + 1)) | dx) * sectionSize) + (sectionSize / 2.0);
|
||||||
@@ -109,19 +110,26 @@ public class DirtyUpdateService {
|
|||||||
if (distSq > standardViewDist * standardViewDist && distSq < voxyDistance * voxyDistance) {
|
if (distSq > standardViewDist * standardViewDist && distSq < voxyDistance * voxyDistance) {
|
||||||
int absX = (sx << (lvl + 1)) | dx;
|
int absX = (sx << (lvl + 1)) | dx;
|
||||||
int absZ = (sz << (lvl + 1)) | dz;
|
int absZ = (sz << (lvl + 1)) | dz;
|
||||||
int minAbsY = (sy << (lvl + 1));
|
cols.add(new long[]{absX, absZ, Double.doubleToRawLongBits(distSq)});
|
||||||
int maxAbsY = minAbsY + m;
|
}
|
||||||
int[] yList = VisibleBandUtil.computeVisibleBands(matchLevel, dirty.world, absX, absZ);
|
}
|
||||||
for (int i = 0; i < yList.length && perPlayerBudget > 0; i++) {
|
}
|
||||||
int absY = yList[i];
|
cols.sort((a,b)->Long.compare(a[2], b[2]));
|
||||||
if (absY < minAbsY || absY > maxAbsY) continue;
|
for (var it : cols) {
|
||||||
var voxelized = WorldSectionToVoxelizedConverter.convert(dirty.section, lvl, absX, absY, absZ);
|
if (perPlayerBudget <= 0) break;
|
||||||
if (voxelized.lvl0NonAirCount > 0) {
|
int absX = (int) it[0];
|
||||||
var payload = VoxyNetwork.LodUpdatePayload.create(voxelized, dirty.world.getMapper());
|
int absZ = (int) it[1];
|
||||||
ServerPlayNetworking.send(player, payload);
|
int minAbsY = (sy << (lvl + 1));
|
||||||
perPlayerBudget--;
|
int maxAbsY = minAbsY + m;
|
||||||
}
|
int[] yList = VisibleBandUtil.computeVisibleBands(matchLevel, dirty.world, absX, absZ);
|
||||||
}
|
for (int i = 0; i < yList.length && perPlayerBudget > 0; i++) {
|
||||||
|
int absY = yList[i];
|
||||||
|
if (absY < minAbsY || absY > maxAbsY) continue;
|
||||||
|
var voxelized = WorldSectionToVoxelizedConverter.convert(dirty.section, lvl, absX, absY, absZ);
|
||||||
|
if (voxelized.lvl0NonAirCount > 0) {
|
||||||
|
var payload = VoxyNetwork.LodUpdatePayload.create(voxelized, dirty.world.getMapper());
|
||||||
|
ServerPlayNetworking.send(player, payload);
|
||||||
|
perPlayerBudget--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ public class PlayerLodTracker {
|
|||||||
prog.yList = VisibleBandUtil.computeVisibleBands(level, engine, x, z);
|
prog.yList = VisibleBandUtil.computeVisibleBands(level, engine, x, z);
|
||||||
prog.nextIdx = 0;
|
prog.nextIdx = 0;
|
||||||
}
|
}
|
||||||
budget.addAndGet(-processVerticalList(player, engine, x, z, prog, budget.get()));
|
// defer processing to global prioritized loop
|
||||||
}
|
}
|
||||||
}, (x, z) -> {
|
}, (x, z) -> {
|
||||||
// On Remove (Unload)
|
// On Remove (Unload)
|
||||||
@@ -120,17 +120,29 @@ public class PlayerLodTracker {
|
|||||||
state.sentColumns.remove(key);
|
state.sentColumns.remove(key);
|
||||||
});
|
});
|
||||||
if (budget.get() > 0) {
|
if (budget.get() > 0) {
|
||||||
|
java.util.ArrayList<long[]> cols = new java.util.ArrayList<>(state.sentColumns.size());
|
||||||
for (var entry : state.sentColumns.entrySet()) {
|
for (var entry : state.sentColumns.entrySet()) {
|
||||||
if (budget.get() <= 0) break;
|
|
||||||
long key = entry.getKey();
|
long key = entry.getKey();
|
||||||
int x = (int)(key >> 32);
|
int cx = (int)(key >> 32);
|
||||||
int z = (int)key;
|
int cz = (int)key;
|
||||||
var prog = entry.getValue();
|
double dx = cx - state.lastX;
|
||||||
|
double dz = cz - state.lastZ;
|
||||||
|
double d2 = dx*dx + dz*dz;
|
||||||
|
cols.add(new long[]{key, Double.doubleToRawLongBits(d2)});
|
||||||
|
}
|
||||||
|
cols.sort((a,b)->Long.compare(a[1], b[1]));
|
||||||
|
for (var it : cols) {
|
||||||
|
if (budget.get() <= 0) break;
|
||||||
|
long key = it[0];
|
||||||
|
int cx = (int)(key >> 32);
|
||||||
|
int cz = (int)key;
|
||||||
|
var prog = state.sentColumns.get(key);
|
||||||
|
if (prog == null) continue;
|
||||||
if (prog.yList == null) {
|
if (prog.yList == null) {
|
||||||
prog.yList = VisibleBandUtil.computeVisibleBands(level, engine, x, z);
|
prog.yList = VisibleBandUtil.computeVisibleBands(level, engine, cx, cz);
|
||||||
prog.nextIdx = 0;
|
prog.nextIdx = 0;
|
||||||
}
|
}
|
||||||
budget.addAndGet(-processVerticalList(player, engine, x, z, prog, budget.get()));
|
budget.addAndGet(-processVerticalList(player, engine, cx, cz, prog, budget.get()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user