From 378c064629dd9765529de7231e66c9fd6aba5b50 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Thu, 10 Nov 2022 07:47:59 -0600 Subject: [PATCH] Add DhBlockPos and DhChunkPos constructors to DhSectionPos --- .../com/seibel/lod/core/pos/DhSectionPos.java | 40 ++++++++++++++++++- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/seibel/lod/core/pos/DhSectionPos.java b/core/src/main/java/com/seibel/lod/core/pos/DhSectionPos.java index 5e283adc9..e5f3b1f4a 100644 --- a/core/src/main/java/com/seibel/lod/core/pos/DhSectionPos.java +++ b/core/src/main/java/com/seibel/lod/core/pos/DhSectionPos.java @@ -8,13 +8,29 @@ import com.seibel.lod.core.util.MathUtil; import java.util.function.Consumer; /** - * The position object used to define LOD objects in the quad trees. - * + * The position object used to define LOD objects in the quad trees.
+ * + * A section contains 64 x 64 LOD columns at a given quality. + * The Section detail level is different from the LOD detail level. + * For the specifics of how they compare can be viewed in the constants {@link #SECTION_BLOCK_DETAIL_LEVEL}, + * {@link #SECTION_CHUNK_DETAIL_LEVEL}, and {@link #SECTION_REGION_DETAIL_LEVEL}). + * * @author Leetom * @version 2022-11-6 */ public class DhSectionPos { + /** + * The lowest detail level a Section position can hold. + * This section DetailLevel holds 64 x 64 Block level (detail level 0) LODs. + */ + public final static byte SECTION_MINIMUM_DETAIL_LEVEL = 6; + + public final static byte SECTION_BLOCK_DETAIL_LEVEL = SECTION_MINIMUM_DETAIL_LEVEL + LodUtil.BLOCK_DETAIL_LEVEL; + public final static byte SECTION_CHUNK_DETAIL_LEVEL = SECTION_MINIMUM_DETAIL_LEVEL + LodUtil.CHUNK_DETAIL_LEVEL; + public final static byte SECTION_REGION_DETAIL_LEVEL = SECTION_MINIMUM_DETAIL_LEVEL + LodUtil.REGION_DETAIL_LEVEL; + + public final byte sectionDetail; /** in sectionDetail level grid */ @@ -31,6 +47,26 @@ public class DhSectionPos this.sectionZ = sectionZ; } + public DhSectionPos(DhBlockPos blockPos) + { + DhLodPos lodPos = new DhLodPos(LodUtil.BLOCK_DETAIL_LEVEL, blockPos.x, blockPos.z); + lodPos = lodPos.convertUpwardsTo(SECTION_BLOCK_DETAIL_LEVEL); + + this.sectionDetail = SECTION_BLOCK_DETAIL_LEVEL; + this.sectionX = lodPos.x; + this.sectionZ = lodPos.z; + } + + public DhSectionPos(DhChunkPos chunkPos) + { + DhLodPos lodPos = new DhLodPos(LodUtil.CHUNK_DETAIL_LEVEL, chunkPos.x, chunkPos.z); + lodPos = lodPos.convertUpwardsTo(SECTION_CHUNK_DETAIL_LEVEL); + + this.sectionDetail = SECTION_CHUNK_DETAIL_LEVEL; + this.sectionX = lodPos.x; + this.sectionZ = lodPos.z; + } + /** Returns the center for the highest detail level (0) */