diff --git a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/HighDetailIncompleteFullDataSource.java b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/HighDetailIncompleteFullDataSource.java
index 6ac6de517..5ced11d40 100644
--- a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/HighDetailIncompleteFullDataSource.java
+++ b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/HighDetailIncompleteFullDataSource.java
@@ -523,7 +523,7 @@ public class HighDetailIncompleteFullDataSource implements IIncompleteFullDataSo
DhLodPos basePos = this.sectionPos.getCorner(SPARSE_UNIT_DETAIL);
DhLodPos dataPos = pos.getCorner(SPARSE_UNIT_DETAIL);
- int coveredChunks = pos.getWidth(SPARSE_UNIT_DETAIL).numberOfLodSectionsWide;
+ int coveredChunks = pos.getWidthCountForLowerDetailedSection(SPARSE_UNIT_DETAIL);
int sourceDataPerChunk = SPARSE_UNIT_SIZE >>> completeDataSource.getDataDetailLevel();
LodUtil.assertTrue((coveredChunks * sourceDataPerChunk) == CompleteFullDataSource.WIDTH);
diff --git a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/LowDetailIncompleteFullDataSource.java b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/LowDetailIncompleteFullDataSource.java
index b518316f8..8fa306dc2 100644
--- a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/LowDetailIncompleteFullDataSource.java
+++ b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/LowDetailIncompleteFullDataSource.java
@@ -398,7 +398,7 @@ public class LowDetailIncompleteFullDataSource extends FullDataArrayAccessor imp
LodUtil.assertTrue(offsetX >= 0 && offsetX < WIDTH && offsetZ >= 0 && offsetZ < WIDTH);
int chunksPerData = 1 << (this.getDataDetailLevel() - HighDetailIncompleteFullDataSource.SPARSE_UNIT_DETAIL);
- int dataSpan = this.sectionPos.getWidth(this.getDataDetailLevel()).numberOfLodSectionsWide;
+ int dataSpan = this.sectionPos.getWidthCountForLowerDetailedSection(this.getDataDetailLevel());
for (int xOffset = 0; xOffset < dataSpan; xOffset++)
{
@@ -419,7 +419,7 @@ public class LowDetailIncompleteFullDataSource extends FullDataArrayAccessor imp
else
{
DhLodPos dataLodPos = pos.getSectionBBoxPos();
- int lowerSectionsPerData = this.sectionPos.getWidth(dataLodPos.detailLevel).numberOfLodSectionsWide;
+ int lowerSectionsPerData = this.sectionPos.getWidthCountForLowerDetailedSection(dataLodPos.detailLevel);
if (dataLodPos.x % lowerSectionsPerData != 0 || dataLodPos.z % lowerSectionsPerData != 0)
{
return;
@@ -452,7 +452,7 @@ public class LowDetailIncompleteFullDataSource extends FullDataArrayAccessor imp
int offsetX = dataLodPos.x - thisLodPos.x;
int offsetZ = dataLodPos.z - thisLodPos.z;
- int dataWidth = this.sectionPos.getWidth(this.getDataDetailLevel()).numberOfLodSectionsWide;
+ int dataWidth = this.sectionPos.getWidthCountForLowerDetailedSection(this.getDataDetailLevel());
for (int xOffset = 0; xOffset < dataWidth; xOffset++)
{
@@ -465,7 +465,7 @@ public class LowDetailIncompleteFullDataSource extends FullDataArrayAccessor imp
else
{
DhLodPos dataPos = pos.getSectionBBoxPos();
- int lowerSectionsPerData = this.sectionPos.getWidth(dataPos.detailLevel).numberOfLodSectionsWide;
+ int lowerSectionsPerData = this.sectionPos.getWidthCountForLowerDetailedSection(dataPos.detailLevel);
if (dataPos.x % lowerSectionsPerData != 0 || dataPos.z % lowerSectionsPerData != 0)
{
return;
@@ -495,7 +495,7 @@ public class LowDetailIncompleteFullDataSource extends FullDataArrayAccessor imp
int offsetX = dataLodPos.x - thisLodPos.x;
int offsetZ = dataLodPos.z - thisLodPos.z;
- int dataWidth = this.sectionPos.getWidth(this.getDataDetailLevel()).numberOfLodSectionsWide;
+ int dataWidth = this.sectionPos.getWidthCountForLowerDetailedSection(this.getDataDetailLevel());
for (int xOffset = 0; xOffset < dataWidth; xOffset++)
{
@@ -508,7 +508,7 @@ public class LowDetailIncompleteFullDataSource extends FullDataArrayAccessor imp
else
{
DhLodPos dataPos = pos.getSectionBBoxPos();
- int lowerSectionsPerData = this.sectionPos.getWidth(dataPos.detailLevel).numberOfLodSectionsWide;
+ int lowerSectionsPerData = this.sectionPos.getWidthCountForLowerDetailedSection(dataPos.detailLevel);
if (dataPos.x % lowerSectionsPerData != 0 || dataPos.z % lowerSectionsPerData != 0)
{
return;
diff --git a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/render/ColumnRenderSource.java b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/render/ColumnRenderSource.java
index 0fc4ea570..fca21859b 100644
--- a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/render/ColumnRenderSource.java
+++ b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/render/ColumnRenderSource.java
@@ -526,7 +526,7 @@ public class ColumnRenderSource
stringBuilder.append(this.sectionPos);
stringBuilder.append(LINE_DELIMITER);
- int size = this.sectionPos.getWidth().numberOfLodSectionsWide;
+ int size = 1;
for (int z = 0; z < size; z++)
{
for (int x = 0; x < size; x++)
diff --git a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/transformers/FullDataToRenderDataTransformer.java b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/transformers/FullDataToRenderDataTransformer.java
index 40e707746..bacfea010 100644
--- a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/transformers/FullDataToRenderDataTransformer.java
+++ b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/transformers/FullDataToRenderDataTransformer.java
@@ -135,9 +135,9 @@ public class FullDataToRenderDataTransformer
int baseX = pos.getCorner().getCornerBlockPos().x;
int baseZ = pos.getCorner().getCornerBlockPos().z;
- for (int x = 0; x < pos.getWidth(dataDetail).numberOfLodSectionsWide; x++)
+ for (int x = 0; x < pos.getWidthCountForLowerDetailedSection(dataDetail); x++)
{
- for (int z = 0; z < pos.getWidth(dataDetail).numberOfLodSectionsWide; z++)
+ for (int z = 0; z < pos.getWidthCountForLowerDetailedSection(dataDetail); z++)
{
throwIfThreadInterrupted();
@@ -184,9 +184,9 @@ public class FullDataToRenderDataTransformer
{
int baseX = pos.getCorner().getCornerBlockPos().x;
int baseZ = pos.getCorner().getCornerBlockPos().z;
- for (int x = 0; x < pos.getWidth(dataDetail).numberOfLodSectionsWide; x++)
+ for (int x = 0; x < pos.getWidthCountForLowerDetailedSection(dataDetail); x++)
{
- for (int z = 0; z < pos.getWidth(dataDetail).numberOfLodSectionsWide; z++)
+ for (int z = 0; z < pos.getWidthCountForLowerDetailedSection(dataDetail); z++)
{
throwIfThreadInterrupted();
diff --git a/core/src/main/java/com/seibel/distanthorizons/core/pos/DhSectionPos.java b/core/src/main/java/com/seibel/distanthorizons/core/pos/DhSectionPos.java
index e7ecbb0a6..57fff321c 100644
--- a/core/src/main/java/com/seibel/distanthorizons/core/pos/DhSectionPos.java
+++ b/core/src/main/java/com/seibel/distanthorizons/core/pos/DhSectionPos.java
@@ -181,22 +181,25 @@ public class DhSectionPos
this.sectionZ * BitShiftUtil.powerOfTwo(offset));
}
- public DhLodUnit getWidth() { return this.getWidth(this.sectionDetailLevel); } // this always returns 1...
- public DhLodUnit getWidth(byte returnDetailLevel)
+ /**
+ * A detail level of X lower than this section's detail level will return:
+ * 0 -> 1
+ * 1 -> 2
+ * 2 -> 4
+ * 3 -> 8
+ * etc.
+ *
+ * @return how many {@link DhSectionPos}'s at the given detail level it would take to span the width of this section.
+ */
+ public int getWidthCountForLowerDetailedSection(byte returnDetailLevel)
{
LodUtil.assertTrue(returnDetailLevel <= this.sectionDetailLevel, "returnDetailLevel must be less than sectionDetail");
byte offset = (byte) (this.sectionDetailLevel - returnDetailLevel);
- return new DhLodUnit(this.sectionDetailLevel, BitShiftUtil.powerOfTwo(offset));
- }
-
- public int getNumberOfLodSectionsWide() { return this.getNumberOfLodSectionsWide(this.sectionDetailLevel); } // TODO this always returns 1...
- public int getNumberOfLodSectionsWide(byte returnDetailLevel)
- {
- LodUtil.assertTrue(returnDetailLevel <= this.sectionDetailLevel, "returnDetailLevel must be less than sectionDetail"); // TODO add something to the method name stating this
- byte offset = (byte) (this.sectionDetailLevel - returnDetailLevel);
return BitShiftUtil.powerOfTwo(offset);
}
+ /** @return how wide this section is in blocks */
+ public int getBlockWidth() { return BitShiftUtil.powerOfTwo(this.sectionDetailLevel); }
//==================//
@@ -261,7 +264,7 @@ public class DhSectionPos
DhBlockPos2D thisMinBlockPos = this.getCorner(LodUtil.BLOCK_DETAIL_LEVEL).getCornerBlockPos();
DhBlockPos2D otherCornerBlockPos = otherPos.getCorner(LodUtil.BLOCK_DETAIL_LEVEL).getCornerBlockPos();
- int thisBlockWidth = this.getWidth().toBlockWidth() - 1; // minus 1 to account for zero based positional indexing
+ int thisBlockWidth = this.getBlockWidth() - 1; // minus 1 to account for zero based positional indexing
DhBlockPos2D thisMaxBlockPos = new DhBlockPos2D(thisMinBlockPos.x + thisBlockWidth, thisMinBlockPos.z + thisBlockWidth);
return thisMinBlockPos.x <= otherCornerBlockPos.x && otherCornerBlockPos.x <= thisMaxBlockPos.x &&
diff --git a/core/src/main/java/com/seibel/distanthorizons/core/util/objects/quadTree/QuadNode.java b/core/src/main/java/com/seibel/distanthorizons/core/util/objects/quadTree/QuadNode.java
index 8f4d2ba45..d3666a9cc 100644
--- a/core/src/main/java/com/seibel/distanthorizons/core/util/objects/quadTree/QuadNode.java
+++ b/core/src/main/java/com/seibel/distanthorizons/core/util/objects/quadTree/QuadNode.java
@@ -180,7 +180,7 @@ public class QuadNode
if (!this.sectionPos.contains(inputSectionPos))
{
LOGGER.error((replaceValue ? "set " : "get ") + inputSectionPos + " center block: " + inputSectionPos.getCenter().getCornerBlockPos() + ", this pos: " + this.sectionPos + " this center block: " + this.sectionPos.getCenter().getCornerBlockPos());
- throw new IllegalArgumentException("Input section pos " + inputSectionPos + " outside of this quadNode's pos: " + this.sectionPos + ", this node's blockPos: " + this.sectionPos.convertNewToDetailLevel(LodUtil.BLOCK_DETAIL_LEVEL) + " block width: " + this.sectionPos.getWidth().toBlockWidth() + " input detail level: " + inputSectionPos.convertNewToDetailLevel(LodUtil.BLOCK_DETAIL_LEVEL) + " width: " + inputSectionPos.getWidth().toBlockWidth());
+ throw new IllegalArgumentException("Input section pos " + inputSectionPos + " outside of this quadNode's pos: " + this.sectionPos + ", this node's blockPos: " + this.sectionPos.convertNewToDetailLevel(LodUtil.BLOCK_DETAIL_LEVEL) + " block width: " + this.sectionPos.getBlockWidth() + " input detail level: " + inputSectionPos.convertNewToDetailLevel(LodUtil.BLOCK_DETAIL_LEVEL) + " width: " + inputSectionPos.getBlockWidth());
}
if (inputSectionPos.sectionDetailLevel > this.sectionPos.sectionDetailLevel)
diff --git a/core/src/test/java/tests/DhSectionPosTest.java b/core/src/test/java/tests/DhSectionPosTest.java
index 37b0c7109..2c305a3cf 100644
--- a/core/src/test/java/tests/DhSectionPosTest.java
+++ b/core/src/test/java/tests/DhSectionPosTest.java
@@ -256,40 +256,6 @@ public class DhSectionPosTest
}
- @Test
- public void GetDefaultWidth()
- {
- DhSectionPos originSectionPos = new DhSectionPos((byte) 0,0,0);
- DhSectionPos sectionPos = new DhSectionPos((byte) 0,-10000,5000);
-
- // widths should be the same regardless of position in the world
- originSectionPos = originSectionPos.convertNewToDetailLevel((byte) 1);
- Assert.assertEquals(1, originSectionPos.getNumberOfLodSectionsWide());
- Assert.assertEquals(originSectionPos.getWidth().numberOfLodSectionsWide, originSectionPos.getNumberOfLodSectionsWide());
-
- sectionPos = sectionPos.convertNewToDetailLevel((byte) 1);
- Assert.assertEquals(1, sectionPos.getNumberOfLodSectionsWide());
- Assert.assertEquals(sectionPos.getWidth().numberOfLodSectionsWide, sectionPos.getNumberOfLodSectionsWide());
-
-
- originSectionPos = originSectionPos.convertNewToDetailLevel(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL);
- Assert.assertEquals(1, originSectionPos.getNumberOfLodSectionsWide());
- Assert.assertEquals(originSectionPos.getWidth().numberOfLodSectionsWide, originSectionPos.getNumberOfLodSectionsWide());
-
- sectionPos = sectionPos.convertNewToDetailLevel(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL);
- Assert.assertEquals(1, sectionPos.getNumberOfLodSectionsWide());
- Assert.assertEquals(sectionPos.getWidth().numberOfLodSectionsWide, sectionPos.getNumberOfLodSectionsWide());
-
-
- originSectionPos = originSectionPos.convertNewToDetailLevel(DhSectionPos.SECTION_REGION_DETAIL_LEVEL);
- Assert.assertEquals(1, originSectionPos.getNumberOfLodSectionsWide());
- Assert.assertEquals(originSectionPos.getWidth().numberOfLodSectionsWide, originSectionPos.getNumberOfLodSectionsWide());
-
- sectionPos = sectionPos.convertNewToDetailLevel(DhSectionPos.SECTION_REGION_DETAIL_LEVEL);
- Assert.assertEquals(1, sectionPos.getNumberOfLodSectionsWide());
- Assert.assertEquals(sectionPos.getWidth().numberOfLodSectionsWide, sectionPos.getNumberOfLodSectionsWide());
-
- }
@Test
public void GetOffsetWidth()
{
@@ -297,32 +263,70 @@ public class DhSectionPosTest
DhSectionPos sectionPos = new DhSectionPos((byte) 0,-10000,5000);
+
+ // 1 -> 0
+ byte returnDetailLevel = 0;
originSectionPos = originSectionPos.convertNewToDetailLevel((byte) 1);
- Assert.assertEquals(2, originSectionPos.getNumberOfLodSectionsWide((byte) 0));
- Assert.assertEquals(originSectionPos.getWidth((byte) 0).numberOfLodSectionsWide, originSectionPos.getNumberOfLodSectionsWide((byte) 0));
+ Assert.assertEquals(2, originSectionPos.getWidthCountForLowerDetailedSection(returnDetailLevel));
sectionPos = sectionPos.convertNewToDetailLevel((byte) 1);
- Assert.assertEquals(2, sectionPos.getNumberOfLodSectionsWide((byte) 0));
- Assert.assertEquals(sectionPos.getWidth((byte) 0).numberOfLodSectionsWide, sectionPos.getNumberOfLodSectionsWide((byte) 0));
+ Assert.assertEquals(2, sectionPos.getWidthCountForLowerDetailedSection(returnDetailLevel));
+
+ // 2 -> 1
+ returnDetailLevel = 1;
+ originSectionPos = originSectionPos.convertNewToDetailLevel((byte) 2);
+ Assert.assertEquals(2, originSectionPos.getWidthCountForLowerDetailedSection(returnDetailLevel));
+
+ sectionPos = sectionPos.convertNewToDetailLevel((byte) 2);
+ Assert.assertEquals(2, sectionPos.getWidthCountForLowerDetailedSection(returnDetailLevel));
+
+
+
+ // Block -> 0
+ returnDetailLevel = 0;
originSectionPos = originSectionPos.convertNewToDetailLevel(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL);
- Assert.assertEquals(64, originSectionPos.getNumberOfLodSectionsWide((byte) 0));
- Assert.assertEquals(originSectionPos.getWidth((byte) 0).numberOfLodSectionsWide, originSectionPos.getNumberOfLodSectionsWide((byte) 0));
+ Assert.assertEquals(64, originSectionPos.getWidthCountForLowerDetailedSection(returnDetailLevel));
sectionPos = sectionPos.convertNewToDetailLevel(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL);
- Assert.assertEquals(64, sectionPos.getNumberOfLodSectionsWide((byte) 0));
- Assert.assertEquals(sectionPos.getWidth((byte) 0).numberOfLodSectionsWide, sectionPos.getNumberOfLodSectionsWide((byte) 0));
+ Assert.assertEquals(64, sectionPos.getWidthCountForLowerDetailedSection(returnDetailLevel));
+ // Region -> 3
+ returnDetailLevel = 3;
originSectionPos = originSectionPos.convertNewToDetailLevel(DhSectionPos.SECTION_REGION_DETAIL_LEVEL);
- Assert.assertEquals(4096, originSectionPos.getNumberOfLodSectionsWide((byte) 3));
- Assert.assertEquals(originSectionPos.getWidth((byte) 3).numberOfLodSectionsWide, originSectionPos.getNumberOfLodSectionsWide((byte) 3));
+ Assert.assertEquals(4096, originSectionPos.getWidthCountForLowerDetailedSection(returnDetailLevel));
sectionPos = sectionPos.convertNewToDetailLevel(DhSectionPos.SECTION_REGION_DETAIL_LEVEL);
- Assert.assertEquals(4096, sectionPos.getNumberOfLodSectionsWide((byte) 3));
- Assert.assertEquals(sectionPos.getWidth((byte) 3).numberOfLodSectionsWide, sectionPos.getNumberOfLodSectionsWide((byte) 3));
+ Assert.assertEquals(4096, sectionPos.getWidthCountForLowerDetailedSection(returnDetailLevel));
}
+ @Test
+ public void GetBlockWidth()
+ {
+ DhSectionPos originSectionPos = new DhSectionPos((byte) 0,0,0);
+ DhSectionPos sectionPos = new DhSectionPos((byte) 0,-10000,5000);
+
+
+ Assert.assertEquals(1, originSectionPos.getBlockWidth());
+ Assert.assertEquals(1, sectionPos.getBlockWidth());
+
+ originSectionPos = originSectionPos.convertNewToDetailLevel((byte) 1);
+ Assert.assertEquals(2, originSectionPos.getBlockWidth());
+ sectionPos = sectionPos.convertNewToDetailLevel((byte) 1);
+ Assert.assertEquals(2, sectionPos.getBlockWidth());
+
+ originSectionPos = originSectionPos.convertNewToDetailLevel(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL);
+ Assert.assertEquals(64, originSectionPos.getBlockWidth());
+ sectionPos = sectionPos.convertNewToDetailLevel(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL);
+ Assert.assertEquals(64, sectionPos.getBlockWidth());
+
+ originSectionPos = originSectionPos.convertNewToDetailLevel(DhSectionPos.SECTION_REGION_DETAIL_LEVEL);
+ Assert.assertEquals(32768, originSectionPos.getBlockWidth());
+ sectionPos = sectionPos.convertNewToDetailLevel(DhSectionPos.SECTION_REGION_DETAIL_LEVEL);
+ Assert.assertEquals(32768, sectionPos.getBlockWidth());
+
+ }
}