diff --git a/core/src/main/java/com/seibel/lod/core/file/datafile/DataFileHandler.java b/core/src/main/java/com/seibel/lod/core/file/datafile/DataFileHandler.java index 7963ceae3..34ba47c4f 100644 --- a/core/src/main/java/com/seibel/lod/core/file/datafile/DataFileHandler.java +++ b/core/src/main/java/com/seibel/lod/core/file/datafile/DataFileHandler.java @@ -232,19 +232,25 @@ public class DataFileHandler implements IDataSourceProvider { /** This call is concurrent. I.e. it supports being called by multiple threads at the same time. */ @Override - public void write(DhSectionPos sectionPos, ChunkSizedData chunkData) { + public void write(DhSectionPos sectionPos, ChunkSizedData chunkData) + { DhLodPos chunkPos = new DhLodPos((byte) (chunkData.dataDetail+4), chunkData.x, chunkData.z); LodUtil.assertTrue(chunkPos.overlaps(sectionPos.getSectionBBoxPos()), "Chunk {} does not overlap section {}", chunkPos, sectionPos); - chunkPos = chunkPos.convertUpwardsTo((byte) minDetailLevel); // TODO: Handle if chunkData has higher detail than lowestDetail. - recursiveWrite(new DhSectionPos(chunkPos.detailLevel, chunkPos.x, chunkPos.z), chunkData); + chunkPos = chunkPos.convertUpwardsTo((byte) this.minDetailLevel); // TODO: Handle if chunkData has higher detail than lowestDetail. + this.recursiveWrite(new DhSectionPos(chunkPos.detailLevel, chunkPos.x, chunkPos.z), chunkData); } - private void recursiveWrite(DhSectionPos sectionPos, ChunkSizedData chunkData) { - DataMetaFile metaFile = files.get(sectionPos); - if (metaFile != null) { // Fast path: if there is a file for this section, just write to it. + private void recursiveWrite(DhSectionPos sectionPos, ChunkSizedData chunkData) + { + DataMetaFile metaFile = this.files.get(sectionPos); + if (metaFile != null) + { + // Fast path: if there is a file for this section, just write to it. metaFile.addToWriteQueue(chunkData); } - if (sectionPos.sectionDetail <= topDetailLevel.get()) { - recursiveWrite(sectionPos.getParentPos(), chunkData); + + if (sectionPos.sectionDetail <= this.topDetailLevel.get()) + { + this.recursiveWrite(sectionPos.getParentPos(), chunkData); } } diff --git a/core/src/main/java/com/seibel/lod/core/pos/DhLodPos.java b/core/src/main/java/com/seibel/lod/core/pos/DhLodPos.java index df523d064..4d47fb45a 100644 --- a/core/src/main/java/com/seibel/lod/core/pos/DhLodPos.java +++ b/core/src/main/java/com/seibel/lod/core/pos/DhLodPos.java @@ -52,6 +52,7 @@ public class DhLodPos implements Comparable } public DhBlockPos2D getCorner() { return new DhBlockPos2D(this.getX().toBlockWidth(), this.getZ().toBlockWidth()); } + /** converts this position to a lower detail level, angled towards the corner position. */ public DhLodPos getCorner(byte newDetail) { LodUtil.assertTrue(newDetail <= this.detailLevel);