added the big update function

This commit is contained in:
Leonardo
2021-08-23 12:36:32 +02:00
parent 4c6185556f
commit 81cbc7a12b
4 changed files with 34 additions and 20 deletions
@@ -480,6 +480,29 @@ public class LodDimension
return region.getData(levelPos);
}
/**
* Get the data point at the given X and Z coordinates
* in this dimension.
* <br>
* Returns null if the LodChunk doesn't exist or
* is outside the loaded area.
*/
public void updateData(LevelPos levelPos)
{
if (levelPos.detailLevel > LodUtil.REGION_DETAIL_LEVEL)
throw new IllegalArgumentException("getLodFromCoordinates given a level of \"" + levelPos.detailLevel + "\" when \"" + LodUtil.REGION_DETAIL_LEVEL + "\" is the max.");
LodRegion region = getRegion(levelPos);
if (region == null)
{
return;
}
region.updateArea(levelPos);
}
/**
* return true if and only if the node at that position exist
*/
@@ -392,18 +392,17 @@ public class LodRegion implements Serializable
return levelPosList;
}
/**TODO a method to update a whole area, to be used as a single big update*/
/**
* @param levelPos
*/
private void updateArea(LevelPos levelPos)
public void updateArea(LevelPos levelPos)
{
/*
LevelPos tempLevelPos = levelPos;
LevelPos tempLevelPos;
int sizeDiff;
int startX;
int startZ;
for(int bottom = minLevelOfDetail + 1 ; bottom < levelPos.detailLevel ; bottom ++){
for(byte bottom = (byte) (minDetailLevel + 1); bottom < levelPos.detailLevel ; bottom++){
tempLevelPos = levelPos.convert(bottom);
startX = tempLevelPos.posX;
startZ = tempLevelPos.posZ;
@@ -415,19 +414,10 @@ public class LodRegion implements Serializable
}
}
int sizeDiff;
LevelPos levelPos;
for (byte tempLod = (byte) (minDetailLevel + 1); tempLod <= LodUtil.REGION_DETAIL_LEVEL; tempLod++) {
sizeDiff = (int) Math.pow(2,LodUtil.REGION_DETAIL_LEVEL - tempLod);
for (int x = 0; x < sizeDiff; x++) {
for (int z = 0; z < sizeDiff; z++) {
levelPos = new LevelPos(tempLod, x, z);
update(levelPos);
}
}
for (byte tempLod = levelPos.detailLevel; tempLod <= LodUtil.REGION_DETAIL_LEVEL; tempLod++) {
tempLevelPos = levelPos.convert(tempLod);
update(tempLevelPos);
}
*/
}
/**