Fixed PosToGenerate issue

This commit is contained in:
tom lee
2022-01-18 22:33:44 +08:00
parent 546d60f1fc
commit 6c77164a65
2 changed files with 17 additions and 10 deletions
@@ -65,10 +65,14 @@ public class PosToGenerateContainer
{
// We are introducing a position in the far array
if (farSize < farPosToGenerate.length)
farSize++;
index = farSize - 1;
index = farSize;
if (index == farPosToGenerate.length) {
if (LevelPosUtil.compareDistance(distance, farPosToGenerate[index - 1][3]) > 0) {
return;
}
index--;
} else farSize++;
if (sort) {
while (index > 0 && LevelPosUtil.compareDistance(distance, farPosToGenerate[index - 1][3]) <= 0)
{
@@ -87,11 +91,15 @@ public class PosToGenerateContainer
else
{
//We are introducing a position in the near array
index = nearSize;
if (index == nearPosToGenerate.length) {
if (LevelPosUtil.compareDistance(distance, nearPosToGenerate[index - 1][3]) > 0) {
return;
}
index--;
} else nearSize++;
if (nearSize < nearPosToGenerate.length)
nearSize++;
index = nearSize - 1;
if (sort) {
while (index > 0 && LevelPosUtil.compareDistance(distance, nearPosToGenerate[index - 1][3]) <= 0)
{
@@ -523,8 +523,7 @@ public class LodDimension
PosToGenerateContainer posToGenerate;
posToGenerate = new PosToGenerateContainer((byte) 8, maxDataToGenerate, playerBlockPosX, playerBlockPosZ);
iterateByDistance((int x, int z) -> {
boolean isCloseRange = (Math.abs(x-halfWidth)+Math.abs(z-halfWidth)<2);
if (!isCloseRange && posToGenerate.isFull()) return;
boolean isCloseRange = (Math.abs(x-halfWidth)+Math.abs(z-halfWidth)<=2);
//All of this is handled directly by the region, which scan every pos from top to bottom of the quad tree
LodRegion lodRegion = regions[x][z];
if (lodRegion != null)