From 81cbc7a12b63c7f21395982a47c41bb996fbdc41 Mon Sep 17 00:00:00 2001 From: Leonardo Date: Mon, 23 Aug 2021 12:36:32 +0200 Subject: [PATCH] added the big update function --- .../com/seibel/lod/builders/LodBuilder.java | 3 ++- .../com/seibel/lod/objects/LodDimension.java | 23 ++++++++++++++++++ .../com/seibel/lod/objects/LodRegion.java | 24 ++++++------------- .../com/seibel/lod/proxy/ClientProxy.java | 4 ++-- 4 files changed, 34 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/seibel/lod/builders/LodBuilder.java b/src/main/java/com/seibel/lod/builders/LodBuilder.java index ce472a984..41c30afaa 100644 --- a/src/main/java/com/seibel/lod/builders/LodBuilder.java +++ b/src/main/java/com/seibel/lod/builders/LodBuilder.java @@ -181,9 +181,10 @@ public class LodBuilder lodDim.addData(levelPos.convert(detail.detailLevel), data, config.distanceGenerationMode, - true, + false, false); } + lodDim.updateData(new LevelPos(LodUtil.CHUNK_DETAIL_LEVEL, chunk.getPos().x, chunk.getPos().z)); } diff --git a/src/main/java/com/seibel/lod/objects/LodDimension.java b/src/main/java/com/seibel/lod/objects/LodDimension.java index 60a41cea6..c9e6d0d24 100644 --- a/src/main/java/com/seibel/lod/objects/LodDimension.java +++ b/src/main/java/com/seibel/lod/objects/LodDimension.java @@ -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. + *
+ * 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 */ diff --git a/src/main/java/com/seibel/lod/objects/LodRegion.java b/src/main/java/com/seibel/lod/objects/LodRegion.java index d9386d4b1..1c3c66a93 100644 --- a/src/main/java/com/seibel/lod/objects/LodRegion.java +++ b/src/main/java/com/seibel/lod/objects/LodRegion.java @@ -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); } - */ } /** diff --git a/src/main/java/com/seibel/lod/proxy/ClientProxy.java b/src/main/java/com/seibel/lod/proxy/ClientProxy.java index b9470a704..af4772495 100644 --- a/src/main/java/com/seibel/lod/proxy/ClientProxy.java +++ b/src/main/java/com/seibel/lod/proxy/ClientProxy.java @@ -139,8 +139,8 @@ public class ClientProxy // LodConfig.CLIENT.drawLODs.set(true); LodConfig.CLIENT.debugMode.set(false); - LodConfig.CLIENT.maxDrawDetail.set(LodDetail.FULL); - LodConfig.CLIENT.maxGenerationDetail.set(LodDetail.FULL); + LodConfig.CLIENT.maxDrawDetail.set(LodDetail.QUAD); + LodConfig.CLIENT.maxGenerationDetail.set(LodDetail.QUAD); LodConfig.CLIENT.fogDistance.set(FogDistance.FAR); LodConfig.CLIENT.fogDrawOverride.set(FogDrawOverride.ALWAYS_DRAW_FOG_FANCY);