Remove unnecessary suffix from SectionPos encode method
This commit is contained in:
@@ -24,7 +24,6 @@ import com.seibel.distanthorizons.core.pos.DhSectionPos;
|
||||
import com.seibel.distanthorizons.core.pos.DhChunkPos;
|
||||
import com.seibel.distanthorizons.core.pos.DhBlockPos;
|
||||
import com.seibel.distanthorizons.core.pos.DhBlockPos2D;
|
||||
import com.seibel.distanthorizons.core.util.LodUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -40,19 +39,19 @@ public class DhSectionPosTest
|
||||
long pos;
|
||||
|
||||
// zero pos
|
||||
pos = DhSectionPos.encodePos((byte) 0, 0, 0);
|
||||
pos = DhSectionPos.encode((byte) 0, 0, 0);
|
||||
assertSectionPosEqual(0, DhSectionPos.getDetailLevel(pos));
|
||||
assertSectionPosEqual(0, DhSectionPos.getX(pos));
|
||||
assertSectionPosEqual(0, DhSectionPos.getZ(pos));
|
||||
|
||||
// positive values
|
||||
pos = DhSectionPos.encodePos((byte) 10, 4, 1);
|
||||
pos = DhSectionPos.encode((byte) 10, 4, 1);
|
||||
assertSectionPosEqual(10, DhSectionPos.getDetailLevel(pos));
|
||||
assertSectionPosEqual(4, DhSectionPos.getX(pos));
|
||||
assertSectionPosEqual(1, DhSectionPos.getZ(pos));
|
||||
|
||||
// negative position, positive detail level
|
||||
pos = DhSectionPos.encodePos((byte) 2, -1, -4);
|
||||
pos = DhSectionPos.encode((byte) 2, -1, -4);
|
||||
assertSectionPosEqual(2, DhSectionPos.getDetailLevel(pos));
|
||||
assertSectionPosEqual(-1, DhSectionPos.getX(pos));
|
||||
assertSectionPosEqual(-4, DhSectionPos.getZ(pos));
|
||||
@@ -64,61 +63,61 @@ public class DhSectionPosTest
|
||||
@Test
|
||||
public void containsPosTest()
|
||||
{
|
||||
long root = DhSectionPos.encodePos((byte) 10, 0, 0);
|
||||
long child = DhSectionPos.encodePos((byte) 9, 1, 1);
|
||||
long root = DhSectionPos.encode((byte) 10, 0, 0);
|
||||
long child = DhSectionPos.encode((byte) 9, 1, 1);
|
||||
|
||||
Assert.assertTrue("section pos contains fail", DhSectionPos.contains(root, child));
|
||||
Assert.assertFalse("section pos contains fail", DhSectionPos.contains(child, root));
|
||||
|
||||
|
||||
root = DhSectionPos.encodePos((byte) 10, 1, 0);
|
||||
root = DhSectionPos.encode((byte) 10, 1, 0);
|
||||
|
||||
// out of bounds
|
||||
child = DhSectionPos.encodePos((byte) 9, 0, 0);
|
||||
child = DhSectionPos.encode((byte) 9, 0, 0);
|
||||
Assert.assertFalse("position should be out of bounds", DhSectionPos.contains(root, child));
|
||||
child = DhSectionPos.encodePos((byte) 9, 1, 1);
|
||||
child = DhSectionPos.encode((byte) 9, 1, 1);
|
||||
Assert.assertFalse("position should be out of bounds", DhSectionPos.contains(root, child));
|
||||
|
||||
// in bounds
|
||||
child = DhSectionPos.encodePos((byte) 9, 2, 0);
|
||||
child = DhSectionPos.encode((byte) 9, 2, 0);
|
||||
Assert.assertTrue("position should be in bounds", DhSectionPos.contains(root, child));
|
||||
child = DhSectionPos.encodePos((byte) 9, 3, 1);
|
||||
child = DhSectionPos.encode((byte) 9, 3, 1);
|
||||
Assert.assertTrue("position should be in bounds", DhSectionPos.contains(root, child));
|
||||
|
||||
// out of bounds
|
||||
child = DhSectionPos.encodePos((byte) 9, 2, 2);
|
||||
child = DhSectionPos.encode((byte) 9, 2, 2);
|
||||
Assert.assertFalse("position should be out of bounds", DhSectionPos.contains(root, child));
|
||||
child = DhSectionPos.encodePos((byte) 9, 3, 3);
|
||||
child = DhSectionPos.encode((byte) 9, 3, 3);
|
||||
Assert.assertFalse("position should be out of bounds", DhSectionPos.contains(root, child));
|
||||
|
||||
child = DhSectionPos.encodePos((byte) 9, 4, 4);
|
||||
child = DhSectionPos.encode((byte) 9, 4, 4);
|
||||
Assert.assertFalse("position should be out of bounds", DhSectionPos.contains(root, child));
|
||||
child = DhSectionPos.encodePos((byte) 9, 5, 5);
|
||||
child = DhSectionPos.encode((byte) 9, 5, 5);
|
||||
Assert.assertFalse("position should be out of bounds", DhSectionPos.contains(root, child));
|
||||
|
||||
|
||||
Assert.assertTrue(DhSectionPos.contains(DhSectionPos.encodePos((byte) 6, 0, 0), DhSectionPos.encodePos((byte) 0, 0, 0)));
|
||||
Assert.assertTrue(DhSectionPos.contains(DhSectionPos.encodePos((byte) 6, 0, 0), DhSectionPos.encodePos((byte) 1, 0, 0)));
|
||||
Assert.assertTrue(DhSectionPos.contains(DhSectionPos.encodePos((byte) 6, 0, 0), DhSectionPos.encodePos((byte) 2, 0, 0)));
|
||||
Assert.assertTrue(DhSectionPos.contains(DhSectionPos.encodePos((byte) 6, 0, 0), DhSectionPos.encodePos((byte) 3, 0, 0)));
|
||||
Assert.assertTrue(DhSectionPos.contains(DhSectionPos.encodePos((byte) 6, 0, 0), DhSectionPos.encodePos((byte) 4, 0, 0)));
|
||||
Assert.assertTrue(DhSectionPos.contains(DhSectionPos.encodePos((byte) 6, 0, 0), DhSectionPos.encodePos((byte) 5, 0, 0)));
|
||||
Assert.assertTrue(DhSectionPos.contains(DhSectionPos.encodePos((byte) 6, 0, 0), DhSectionPos.encodePos((byte) 6, 0, 0)));
|
||||
Assert.assertTrue(DhSectionPos.contains(DhSectionPos.encode((byte) 6, 0, 0), DhSectionPos.encode((byte) 0, 0, 0)));
|
||||
Assert.assertTrue(DhSectionPos.contains(DhSectionPos.encode((byte) 6, 0, 0), DhSectionPos.encode((byte) 1, 0, 0)));
|
||||
Assert.assertTrue(DhSectionPos.contains(DhSectionPos.encode((byte) 6, 0, 0), DhSectionPos.encode((byte) 2, 0, 0)));
|
||||
Assert.assertTrue(DhSectionPos.contains(DhSectionPos.encode((byte) 6, 0, 0), DhSectionPos.encode((byte) 3, 0, 0)));
|
||||
Assert.assertTrue(DhSectionPos.contains(DhSectionPos.encode((byte) 6, 0, 0), DhSectionPos.encode((byte) 4, 0, 0)));
|
||||
Assert.assertTrue(DhSectionPos.contains(DhSectionPos.encode((byte) 6, 0, 0), DhSectionPos.encode((byte) 5, 0, 0)));
|
||||
Assert.assertTrue(DhSectionPos.contains(DhSectionPos.encode((byte) 6, 0, 0), DhSectionPos.encode((byte) 6, 0, 0)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void containsAdjacentPosTest()
|
||||
{
|
||||
// neither should contain the other, they are single blocks that are next to each other
|
||||
long left = DhSectionPos.encodePos((byte) 0, 4606, 0);
|
||||
long right = DhSectionPos.encodePos((byte) 0, 4607, 0);
|
||||
long left = DhSectionPos.encode((byte) 0, 4606, 0);
|
||||
long right = DhSectionPos.encode((byte) 0, 4607, 0);
|
||||
Assert.assertFalse(DhSectionPos.contains(left, right));
|
||||
Assert.assertFalse(DhSectionPos.contains(right, left));
|
||||
|
||||
|
||||
// 512 block wide sections that are adjacent, but not overlapping
|
||||
left = DhSectionPos.encodePos((byte) 9, 0, 0);
|
||||
right = DhSectionPos.encodePos((byte) 9, 1, 0);
|
||||
left = DhSectionPos.encode((byte) 9, 0, 0);
|
||||
right = DhSectionPos.encode((byte) 9, 1, 0);
|
||||
Assert.assertFalse(DhSectionPos.contains(left, right));
|
||||
Assert.assertFalse(DhSectionPos.contains(right, left));
|
||||
|
||||
@@ -127,19 +126,19 @@ public class DhSectionPosTest
|
||||
@Test
|
||||
public void parentPosTest()
|
||||
{
|
||||
long leaf = DhSectionPos.encodePos((byte) 0, 0, 0);
|
||||
long leaf = DhSectionPos.encode((byte) 0, 0, 0);
|
||||
long convert = DhSectionPos.convertToDetailLevel(leaf, (byte) 1);
|
||||
long parent = DhSectionPos.getParentPos(leaf);
|
||||
assertSectionPosEqual("get parent at 0,0 fail", convert, parent);
|
||||
|
||||
|
||||
leaf = DhSectionPos.encodePos((byte) 0, 1, 1);
|
||||
leaf = DhSectionPos.encode((byte) 0, 1, 1);
|
||||
convert = DhSectionPos.convertToDetailLevel(leaf, (byte) 1);
|
||||
parent = DhSectionPos.getParentPos(leaf);
|
||||
assertSectionPosEqual("get parent at 1,1 fail", convert, parent);
|
||||
|
||||
|
||||
leaf = DhSectionPos.encodePos((byte) 1, 2, 2);
|
||||
leaf = DhSectionPos.encode((byte) 1, 2, 2);
|
||||
convert = DhSectionPos.convertToDetailLevel(leaf, (byte) 2);
|
||||
parent = DhSectionPos.getParentPos(leaf);
|
||||
assertSectionPosEqual("parent upscale fail", convert, parent);
|
||||
@@ -152,7 +151,7 @@ public class DhSectionPosTest
|
||||
@Test
|
||||
public void childPosTest()
|
||||
{
|
||||
long node = DhSectionPos.encodePos((byte) 1, 2302, 0);
|
||||
long node = DhSectionPos.encode((byte) 1, 2302, 0);
|
||||
long nw = DhSectionPos.getChildByIndex(node, 0);
|
||||
long sw = DhSectionPos.getChildByIndex(node, 1);
|
||||
long ne = DhSectionPos.getChildByIndex(node, 2);
|
||||
@@ -164,18 +163,18 @@ public class DhSectionPosTest
|
||||
Assert.assertNotEquals(ne, se);
|
||||
|
||||
// confirm each child has the correct value
|
||||
assertSectionPosEqual(nw, DhSectionPos.encodePos((byte) 0, 4604, 0));
|
||||
assertSectionPosEqual(sw, DhSectionPos.encodePos((byte) 0, 4605, 0));
|
||||
assertSectionPosEqual(ne, DhSectionPos.encodePos((byte) 0, 4604, 1));
|
||||
assertSectionPosEqual(se, DhSectionPos.encodePos((byte) 0, 4605, 1));
|
||||
assertSectionPosEqual(nw, DhSectionPos.encode((byte) 0, 4604, 0));
|
||||
assertSectionPosEqual(sw, DhSectionPos.encode((byte) 0, 4605, 0));
|
||||
assertSectionPosEqual(ne, DhSectionPos.encode((byte) 0, 4604, 1));
|
||||
assertSectionPosEqual(se, DhSectionPos.encode((byte) 0, 4605, 1));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCenterBlock2DTest()
|
||||
{
|
||||
long parentNode = DhSectionPos.encodePos((byte) 2, 1151, 0); // width 4 blocks
|
||||
long inputPos = DhSectionPos.encodePos((byte) 0, 4606, 0); // width 1 block
|
||||
long parentNode = DhSectionPos.encode((byte) 2, 1151, 0); // width 4 blocks
|
||||
long inputPos = DhSectionPos.encode((byte) 0, 4606, 0); // width 1 block
|
||||
Assert.assertTrue(DhSectionPos.contains(parentNode, inputPos));
|
||||
|
||||
DhBlockPos2D parentCenter = DhSectionPos.getCenterBlockPos(parentNode);
|
||||
@@ -192,20 +191,20 @@ public class DhSectionPosTest
|
||||
// origin pos //
|
||||
|
||||
DhBlockPos originBlockPos = new DhBlockPos(0, 0, 0);
|
||||
long originSectionPos = DhSectionPos.encodeContainingPos(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, originBlockPos);
|
||||
assertSectionPosEqual(DhSectionPos.encodePos(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, 0, 0), originSectionPos);
|
||||
long originSectionPos = DhSectionPos.encodeContaining(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, originBlockPos);
|
||||
assertSectionPosEqual(DhSectionPos.encode(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, 0, 0), originSectionPos);
|
||||
|
||||
|
||||
// offset pos //
|
||||
long offsetSectionPos;
|
||||
|
||||
DhBlockPos offsetBlockPos = new DhBlockPos(1000, 0, 42000);
|
||||
offsetSectionPos = DhSectionPos.encodeContainingPos(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, offsetBlockPos);
|
||||
assertSectionPosEqual(DhSectionPos.encodePos(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, 15, 656), offsetSectionPos);
|
||||
offsetSectionPos = DhSectionPos.encodeContaining(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, offsetBlockPos);
|
||||
assertSectionPosEqual(DhSectionPos.encode(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, 15, 656), offsetSectionPos);
|
||||
|
||||
offsetBlockPos = new DhBlockPos(-987654, 0, 46);
|
||||
offsetSectionPos = DhSectionPos.encodeContainingPos(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, offsetBlockPos);
|
||||
assertSectionPosEqual(DhSectionPos.encodePos(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, -15433, 0), offsetSectionPos);
|
||||
offsetSectionPos = DhSectionPos.encodeContaining(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, offsetBlockPos);
|
||||
assertSectionPosEqual(DhSectionPos.encode(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, -15433, 0), offsetSectionPos);
|
||||
|
||||
}
|
||||
|
||||
@@ -215,19 +214,19 @@ public class DhSectionPosTest
|
||||
// origin pos //
|
||||
|
||||
DhChunkPos originChunkPos = new DhChunkPos(0,0);
|
||||
long originSectionPos = DhSectionPos.encodeContainingPos(DhSectionPos.SECTION_CHUNK_DETAIL_LEVEL, originChunkPos);
|
||||
assertSectionPosEqual(DhSectionPos.encodePos(DhSectionPos.SECTION_CHUNK_DETAIL_LEVEL, 0, 0), originSectionPos);
|
||||
long originSectionPos = DhSectionPos.encodeContaining(DhSectionPos.SECTION_CHUNK_DETAIL_LEVEL, originChunkPos);
|
||||
assertSectionPosEqual(DhSectionPos.encode(DhSectionPos.SECTION_CHUNK_DETAIL_LEVEL, 0, 0), originSectionPos);
|
||||
|
||||
|
||||
// offset pos //
|
||||
|
||||
DhChunkPos offsetChunkPos = new DhChunkPos(1000, 42000);
|
||||
long offsetSectionPos = DhSectionPos.encodeContainingPos(DhSectionPos.SECTION_CHUNK_DETAIL_LEVEL, offsetChunkPos);
|
||||
assertSectionPosEqual(DhSectionPos.encodePos(DhSectionPos.SECTION_CHUNK_DETAIL_LEVEL, 15, 656), offsetSectionPos);
|
||||
long offsetSectionPos = DhSectionPos.encodeContaining(DhSectionPos.SECTION_CHUNK_DETAIL_LEVEL, offsetChunkPos);
|
||||
assertSectionPosEqual(DhSectionPos.encode(DhSectionPos.SECTION_CHUNK_DETAIL_LEVEL, 15, 656), offsetSectionPos);
|
||||
|
||||
offsetChunkPos = new DhChunkPos(-987654, 46);
|
||||
offsetSectionPos = DhSectionPos.encodeContainingPos(DhSectionPos.SECTION_CHUNK_DETAIL_LEVEL, offsetChunkPos);
|
||||
assertSectionPosEqual(DhSectionPos.encodePos(DhSectionPos.SECTION_CHUNK_DETAIL_LEVEL, -15433, 0), offsetSectionPos);
|
||||
offsetSectionPos = DhSectionPos.encodeContaining(DhSectionPos.SECTION_CHUNK_DETAIL_LEVEL, offsetChunkPos);
|
||||
assertSectionPosEqual(DhSectionPos.encode(DhSectionPos.SECTION_CHUNK_DETAIL_LEVEL, -15433, 0), offsetSectionPos);
|
||||
|
||||
}
|
||||
|
||||
@@ -236,38 +235,38 @@ public class DhSectionPosTest
|
||||
{
|
||||
// origin pos //
|
||||
|
||||
long originSectionPos = DhSectionPos.encodePos((byte) 0,0,0);
|
||||
long originSectionPos = DhSectionPos.encode((byte) 0,0,0);
|
||||
|
||||
originSectionPos = DhSectionPos.convertToDetailLevel(originSectionPos, (byte) 1);
|
||||
assertSectionPosEqual(DhSectionPos.encodePos((byte) 1, 0, 0), originSectionPos);
|
||||
assertSectionPosEqual(DhSectionPos.encode((byte) 1, 0, 0), originSectionPos);
|
||||
|
||||
originSectionPos = DhSectionPos.convertToDetailLevel(originSectionPos, DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL);
|
||||
assertSectionPosEqual(DhSectionPos.encodePos(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, 0, 0), originSectionPos);
|
||||
assertSectionPosEqual(DhSectionPos.encode(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, 0, 0), originSectionPos);
|
||||
|
||||
originSectionPos = DhSectionPos.convertToDetailLevel(originSectionPos, DhSectionPos.SECTION_REGION_DETAIL_LEVEL);
|
||||
assertSectionPosEqual(DhSectionPos.encodePos(DhSectionPos.SECTION_REGION_DETAIL_LEVEL, 0, 0), originSectionPos);
|
||||
assertSectionPosEqual(DhSectionPos.encode(DhSectionPos.SECTION_REGION_DETAIL_LEVEL, 0, 0), originSectionPos);
|
||||
|
||||
|
||||
// offset pos //
|
||||
|
||||
long offsetSectionPos = DhSectionPos.encodePos((byte) 0,-10000,5000);
|
||||
long offsetSectionPos = DhSectionPos.encode((byte) 0,-10000,5000);
|
||||
|
||||
offsetSectionPos = DhSectionPos.convertToDetailLevel(offsetSectionPos, (byte) 1);
|
||||
assertSectionPosEqual(DhSectionPos.encodePos((byte) 1, -5000, 2500), offsetSectionPos);
|
||||
assertSectionPosEqual(DhSectionPos.encode((byte) 1, -5000, 2500), offsetSectionPos);
|
||||
|
||||
offsetSectionPos = DhSectionPos.convertToDetailLevel(offsetSectionPos, DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL);
|
||||
assertSectionPosEqual(DhSectionPos.encodePos(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, -157, 78), offsetSectionPos);
|
||||
assertSectionPosEqual(DhSectionPos.encode(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, -157, 78), offsetSectionPos);
|
||||
|
||||
offsetSectionPos = DhSectionPos.convertToDetailLevel(offsetSectionPos, DhSectionPos.SECTION_REGION_DETAIL_LEVEL);
|
||||
assertSectionPosEqual(DhSectionPos.encodePos(DhSectionPos.SECTION_REGION_DETAIL_LEVEL, -1, 0), offsetSectionPos);
|
||||
assertSectionPosEqual(DhSectionPos.encode(DhSectionPos.SECTION_REGION_DETAIL_LEVEL, -1, 0), offsetSectionPos);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getOffsetWidth()
|
||||
{
|
||||
long originSectionPos = DhSectionPos.encodePos((byte) 0,0,0);
|
||||
long sectionPos = DhSectionPos.encodePos((byte) 0,-10000,5000);
|
||||
long originSectionPos = DhSectionPos.encode((byte) 0,0,0);
|
||||
long sectionPos = DhSectionPos.encode((byte) 0,-10000,5000);
|
||||
|
||||
|
||||
|
||||
@@ -311,8 +310,8 @@ public class DhSectionPosTest
|
||||
@Test
|
||||
public void getBlockWidth()
|
||||
{
|
||||
long originSectionPos = DhSectionPos.encodePos((byte) 0,0,0);
|
||||
long sectionPos = DhSectionPos.encodePos((byte) 0,-10000,5000);
|
||||
long originSectionPos = DhSectionPos.encode((byte) 0,0,0);
|
||||
long sectionPos = DhSectionPos.encode((byte) 0,-10000,5000);
|
||||
|
||||
|
||||
assertSectionPosEqual(1, DhSectionPos.getBlockWidth(originSectionPos));
|
||||
@@ -338,8 +337,8 @@ public class DhSectionPosTest
|
||||
@Test
|
||||
public void getCenterBlockPosOrigin()
|
||||
{
|
||||
long originSectionPos = DhSectionPos.encodePos((byte) 0,0,0);
|
||||
long sectionPos = DhSectionPos.encodePos((byte) 0,-10000,5000);
|
||||
long originSectionPos = DhSectionPos.encode((byte) 0,0,0);
|
||||
long sectionPos = DhSectionPos.encode((byte) 0,-10000,5000);
|
||||
|
||||
|
||||
|
||||
@@ -385,28 +384,28 @@ public class DhSectionPosTest
|
||||
long pos;
|
||||
|
||||
// origin block detail
|
||||
pos = DhSectionPos.encodePos((byte) 0,0,0);
|
||||
pos = DhSectionPos.encode((byte) 0,0,0);
|
||||
Assert.assertEquals(0, DhSectionPos.getMinCornerBlockX(pos));
|
||||
Assert.assertEquals(0, DhSectionPos.getMinCornerBlockZ(pos));
|
||||
|
||||
// offset block detail
|
||||
pos = DhSectionPos.encodePos((byte) 0,2,3);
|
||||
pos = DhSectionPos.encode((byte) 0,2,3);
|
||||
Assert.assertEquals(2 * DhSectionPos.getBlockWidth(pos), DhSectionPos.getMinCornerBlockX(pos));
|
||||
Assert.assertEquals(3 * DhSectionPos.getBlockWidth(pos), DhSectionPos.getMinCornerBlockZ(pos));
|
||||
|
||||
// negative offset block detail
|
||||
pos = DhSectionPos.encodePos((byte) 0,-1,-2);
|
||||
pos = DhSectionPos.encode((byte) 0,-1,-2);
|
||||
Assert.assertEquals(-1 * DhSectionPos.getBlockWidth(pos), DhSectionPos.getMinCornerBlockX(pos));
|
||||
Assert.assertEquals(-2 * DhSectionPos.getBlockWidth(pos), DhSectionPos.getMinCornerBlockZ(pos));
|
||||
|
||||
|
||||
// origin chunk detail
|
||||
pos = DhSectionPos.encodePos(DhSectionPos.SECTION_CHUNK_DETAIL_LEVEL,0,0);
|
||||
pos = DhSectionPos.encode(DhSectionPos.SECTION_CHUNK_DETAIL_LEVEL,0,0);
|
||||
Assert.assertEquals(0, DhSectionPos.getMinCornerBlockX(pos));
|
||||
Assert.assertEquals(0, DhSectionPos.getMinCornerBlockZ(pos));
|
||||
|
||||
// offset chunk detail
|
||||
pos = DhSectionPos.encodePos(DhSectionPos.SECTION_CHUNK_DETAIL_LEVEL,2,3);
|
||||
pos = DhSectionPos.encode(DhSectionPos.SECTION_CHUNK_DETAIL_LEVEL,2,3);
|
||||
Assert.assertEquals(2 * DhSectionPos.getBlockWidth(pos), DhSectionPos.getMinCornerBlockX(pos));
|
||||
Assert.assertEquals(3 * DhSectionPos.getBlockWidth(pos), DhSectionPos.getMinCornerBlockZ(pos));
|
||||
|
||||
@@ -416,13 +415,13 @@ public class DhSectionPosTest
|
||||
@Test
|
||||
public void getAdjacentPos()
|
||||
{
|
||||
long pos = DhSectionPos.encodePos((byte) 0, 0, 0);
|
||||
long pos = DhSectionPos.encode((byte) 0, 0, 0);
|
||||
|
||||
assertSectionPosEqual(DhSectionPos.encodePos((byte) 0, 0, -1), DhSectionPos.getAdjacentPos(pos, EDhDirection.NORTH));
|
||||
assertSectionPosEqual(DhSectionPos.encodePos((byte) 0, 0, 1), DhSectionPos.getAdjacentPos(pos, EDhDirection.SOUTH));
|
||||
assertSectionPosEqual(DhSectionPos.encode((byte) 0, 0, -1), DhSectionPos.getAdjacentPos(pos, EDhDirection.NORTH));
|
||||
assertSectionPosEqual(DhSectionPos.encode((byte) 0, 0, 1), DhSectionPos.getAdjacentPos(pos, EDhDirection.SOUTH));
|
||||
|
||||
assertSectionPosEqual(DhSectionPos.encodePos((byte) 0, 1, 0), DhSectionPos.getAdjacentPos(pos, EDhDirection.EAST));
|
||||
assertSectionPosEqual(DhSectionPos.encodePos((byte) 0, -1, 0), DhSectionPos.getAdjacentPos(pos, EDhDirection.WEST));
|
||||
assertSectionPosEqual(DhSectionPos.encode((byte) 0, 1, 0), DhSectionPos.getAdjacentPos(pos, EDhDirection.EAST));
|
||||
assertSectionPosEqual(DhSectionPos.encode((byte) 0, -1, 0), DhSectionPos.getAdjacentPos(pos, EDhDirection.WEST));
|
||||
|
||||
// getting the adjacent position in the up and down position don't make sense
|
||||
Assert.assertThrows(IllegalArgumentException.class, () -> { DhSectionPos.getAdjacentPos(pos, EDhDirection.UP); });
|
||||
@@ -432,7 +431,7 @@ public class DhSectionPosTest
|
||||
@Test
|
||||
public void forEachChildIterator()
|
||||
{
|
||||
long pos = DhSectionPos.encodePos((byte) 1, 0, 0);
|
||||
long pos = DhSectionPos.encode((byte) 1, 0, 0);
|
||||
|
||||
ArrayList<Long> childPosList = new ArrayList<>();
|
||||
AtomicInteger childCount = new AtomicInteger(0);
|
||||
@@ -442,10 +441,10 @@ public class DhSectionPosTest
|
||||
childPosList.add(childPos);
|
||||
});
|
||||
|
||||
Assert.assertTrue(childPosList.contains(DhSectionPos.encodePos((byte) 0, 0, 0)));
|
||||
Assert.assertTrue(childPosList.contains(DhSectionPos.encodePos((byte) 0, 1, 0)));
|
||||
Assert.assertTrue(childPosList.contains(DhSectionPos.encodePos((byte) 0, 0, 1)));
|
||||
Assert.assertTrue(childPosList.contains(DhSectionPos.encodePos((byte) 0, 1, 1)));
|
||||
Assert.assertTrue(childPosList.contains(DhSectionPos.encode((byte) 0, 0, 0)));
|
||||
Assert.assertTrue(childPosList.contains(DhSectionPos.encode((byte) 0, 1, 0)));
|
||||
Assert.assertTrue(childPosList.contains(DhSectionPos.encode((byte) 0, 0, 1)));
|
||||
Assert.assertTrue(childPosList.contains(DhSectionPos.encode((byte) 0, 1, 1)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -60,30 +60,30 @@ public class QuadTreeTest
|
||||
|
||||
|
||||
// (pseudo) root node //
|
||||
testSet(tree, DhSectionPos.encodePos((byte) 10, 0, 0), 0);
|
||||
testSet(tree, DhSectionPos.encode((byte) 10, 0, 0), 0);
|
||||
|
||||
// first child (0,0) //
|
||||
testSet(tree, DhSectionPos.encodePos((byte) 9, 0, 0), 1);
|
||||
testSet(tree, DhSectionPos.encodePos((byte) 9, 1, 0), 2);
|
||||
testSet(tree, DhSectionPos.encodePos((byte) 9, 0, 1), 3);
|
||||
testSet(tree, DhSectionPos.encodePos((byte) 9, 1, 1), 4);
|
||||
testSet(tree, DhSectionPos.encode((byte) 9, 0, 0), 1);
|
||||
testSet(tree, DhSectionPos.encode((byte) 9, 1, 0), 2);
|
||||
testSet(tree, DhSectionPos.encode((byte) 9, 0, 1), 3);
|
||||
testSet(tree, DhSectionPos.encode((byte) 9, 1, 1), 4);
|
||||
|
||||
// second child (0,0) (0,0) //
|
||||
testSet(tree, DhSectionPos.encodePos((byte) 8, 0, 0), 5);
|
||||
testSet(tree, DhSectionPos.encodePos((byte) 8, 1, 0), 6);
|
||||
testSet(tree, DhSectionPos.encodePos((byte) 8, 0, 1), 7);
|
||||
testSet(tree, DhSectionPos.encodePos((byte) 8, 1, 1), 8);
|
||||
testSet(tree, DhSectionPos.encode((byte) 8, 0, 0), 5);
|
||||
testSet(tree, DhSectionPos.encode((byte) 8, 1, 0), 6);
|
||||
testSet(tree, DhSectionPos.encode((byte) 8, 0, 1), 7);
|
||||
testSet(tree, DhSectionPos.encode((byte) 8, 1, 1), 8);
|
||||
// second child (0,0) (1,1) //
|
||||
testSet(tree, DhSectionPos.encodePos((byte) 8, 2, 2), 9);
|
||||
testSet(tree, DhSectionPos.encodePos((byte) 8, 3, 2), 10);
|
||||
testSet(tree, DhSectionPos.encodePos((byte) 8, 2, 3), 11);
|
||||
testSet(tree, DhSectionPos.encodePos((byte) 8, 3, 3), 12);
|
||||
testSet(tree, DhSectionPos.encode((byte) 8, 2, 2), 9);
|
||||
testSet(tree, DhSectionPos.encode((byte) 8, 3, 2), 10);
|
||||
testSet(tree, DhSectionPos.encode((byte) 8, 2, 3), 11);
|
||||
testSet(tree, DhSectionPos.encode((byte) 8, 3, 3), 12);
|
||||
|
||||
// third child (0,0) (1,0) (0,0) //
|
||||
testSet(tree, DhSectionPos.encodePos((byte) 7, 5, 0), 9);
|
||||
testSet(tree, DhSectionPos.encodePos((byte) 7, 6, 0), 10);
|
||||
testSet(tree, DhSectionPos.encodePos((byte) 7, 5, 1), 11);
|
||||
testSet(tree, DhSectionPos.encodePos((byte) 7, 6, 1), 12);
|
||||
testSet(tree, DhSectionPos.encode((byte) 7, 5, 0), 9);
|
||||
testSet(tree, DhSectionPos.encode((byte) 7, 6, 0), 10);
|
||||
testSet(tree, DhSectionPos.encode((byte) 7, 5, 1), 11);
|
||||
testSet(tree, DhSectionPos.encode((byte) 7, 6, 1), 12);
|
||||
|
||||
}
|
||||
|
||||
@@ -95,13 +95,13 @@ public class QuadTreeTest
|
||||
|
||||
|
||||
// root node //
|
||||
testSet(tree, DhSectionPos.encodePos((byte) 10, -1, -1), 0);
|
||||
testSet(tree, DhSectionPos.encode((byte) 10, -1, -1), 0);
|
||||
|
||||
// first child (-1,-1) //
|
||||
testSet(tree, DhSectionPos.encodePos((byte) 9, -2, -1), 1);
|
||||
testSet(tree, DhSectionPos.encodePos((byte) 9, -1, -1), 2);
|
||||
testSet(tree, DhSectionPos.encodePos((byte) 9, -2, -2), 3);
|
||||
testSet(tree, DhSectionPos.encodePos((byte) 9, -1, -2), 4);
|
||||
testSet(tree, DhSectionPos.encode((byte) 9, -2, -1), 1);
|
||||
testSet(tree, DhSectionPos.encode((byte) 9, -1, -1), 2);
|
||||
testSet(tree, DhSectionPos.encode((byte) 9, -2, -2), 3);
|
||||
testSet(tree, DhSectionPos.encode((byte) 9, -1, -2), 4);
|
||||
|
||||
// TODO
|
||||
// // second child (-1,-1) (0,0) //
|
||||
@@ -132,36 +132,36 @@ public class QuadTreeTest
|
||||
|
||||
|
||||
// wrong detail level on purpose, if the detail level was 0 (block) this should work
|
||||
long outOfBoundsPos = DhSectionPos.encodePos(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, (treeParams.getWidthInBlocks() / 2), 0);
|
||||
long outOfBoundsPos = DhSectionPos.encode(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, (treeParams.getWidthInBlocks() / 2), 0);
|
||||
testSet(tree, outOfBoundsPos, -1, IndexOutOfBoundsException.class);
|
||||
Assert.assertEquals("incorrect leaf node count", 0, tree.leafNodeCount());
|
||||
|
||||
|
||||
// out of bounds //
|
||||
outOfBoundsPos = DhSectionPos.encodePos(LodUtil.BLOCK_DETAIL_LEVEL, (treeParams.getWidthInBlocks() / 2) + 1, 0);
|
||||
outOfBoundsPos = DhSectionPos.encode(LodUtil.BLOCK_DETAIL_LEVEL, (treeParams.getWidthInBlocks() / 2) + 1, 0);
|
||||
testSet(tree, outOfBoundsPos, -1, IndexOutOfBoundsException.class);
|
||||
Assert.assertEquals("incorrect leaf node count", 0, tree.leafNodeCount());
|
||||
|
||||
outOfBoundsPos = DhSectionPos.encodePos(LodUtil.BLOCK_DETAIL_LEVEL, (treeParams.getWidthInBlocks() / 2), 0);
|
||||
outOfBoundsPos = DhSectionPos.encode(LodUtil.BLOCK_DETAIL_LEVEL, (treeParams.getWidthInBlocks() / 2), 0);
|
||||
testSet(tree, outOfBoundsPos, -1, IndexOutOfBoundsException.class);
|
||||
Assert.assertEquals("incorrect leaf node count", 0, tree.leafNodeCount());
|
||||
|
||||
|
||||
// in bounds //
|
||||
outOfBoundsPos = DhSectionPos.encodePos(LodUtil.BLOCK_DETAIL_LEVEL, (treeParams.getWidthInBlocks() / 2) - 1, 0);
|
||||
outOfBoundsPos = DhSectionPos.encode(LodUtil.BLOCK_DETAIL_LEVEL, (treeParams.getWidthInBlocks() / 2) - 1, 0);
|
||||
testSet(tree, outOfBoundsPos, 0);
|
||||
Assert.assertEquals("incorrect leaf node count", 1, tree.leafNodeCount());
|
||||
|
||||
outOfBoundsPos = DhSectionPos.encodePos(LodUtil.BLOCK_DETAIL_LEVEL, (treeParams.getWidthInBlocks() / 2) - 3, 0);
|
||||
outOfBoundsPos = DhSectionPos.encode(LodUtil.BLOCK_DETAIL_LEVEL, (treeParams.getWidthInBlocks() / 2) - 3, 0);
|
||||
testSet(tree, outOfBoundsPos, 0);
|
||||
Assert.assertEquals("incorrect leaf node count", 2, tree.leafNodeCount());
|
||||
|
||||
// TODO this position probably has trouble with getting the center.
|
||||
outOfBoundsPos = DhSectionPos.encodePos(LodUtil.BLOCK_DETAIL_LEVEL, (treeParams.getWidthInBlocks() / 2) - 2, 0);
|
||||
outOfBoundsPos = DhSectionPos.encode(LodUtil.BLOCK_DETAIL_LEVEL, (treeParams.getWidthInBlocks() / 2) - 2, 0);
|
||||
testSet(tree, outOfBoundsPos, 0);
|
||||
Assert.assertEquals("incorrect leaf node count", 3, tree.leafNodeCount());
|
||||
|
||||
outOfBoundsPos = DhSectionPos.encodePos(LodUtil.BLOCK_DETAIL_LEVEL, (treeParams.getWidthInBlocks() / 2) - 4, 0);
|
||||
outOfBoundsPos = DhSectionPos.encode(LodUtil.BLOCK_DETAIL_LEVEL, (treeParams.getWidthInBlocks() / 2) - 4, 0);
|
||||
testSet(tree, outOfBoundsPos, 0);
|
||||
Assert.assertEquals("incorrect leaf node count", 4, tree.leafNodeCount());
|
||||
|
||||
@@ -174,15 +174,15 @@ public class QuadTreeTest
|
||||
Assert.assertEquals("Test may need to be re-calculated for different max detail level.", 9, tree.treeMinDetailLevel);
|
||||
|
||||
|
||||
long rootPos = DhSectionPos.encodePos((byte) 9, 0, -1);
|
||||
long rootPos = DhSectionPos.encode((byte) 9, 0, -1);
|
||||
testSet(tree, rootPos, 1);
|
||||
|
||||
// pos is in tree, but out of range
|
||||
long midPos = DhSectionPos.encodePos((byte) 8, 0, -1);
|
||||
long midPos = DhSectionPos.encode((byte) 8, 0, -1);
|
||||
testSet(tree, midPos, 2, IndexOutOfBoundsException.class);
|
||||
|
||||
// pos is in tree, but out of range
|
||||
long leafPos = DhSectionPos.encodePos((byte) 7, 0, -2);
|
||||
long leafPos = DhSectionPos.encode((byte) 7, 0, -2);
|
||||
testSet(tree, leafPos, 3, IndexOutOfBoundsException.class);
|
||||
|
||||
}
|
||||
@@ -198,13 +198,13 @@ public class QuadTreeTest
|
||||
|
||||
|
||||
// (pseudo) root nodes //
|
||||
testSet(tree, DhSectionPos.encodePos((byte) 10, 0, 0), 1);
|
||||
testSet(tree, DhSectionPos.encode((byte) 10, 0, 0), 1);
|
||||
|
||||
// first child (0,0) //
|
||||
long nw = DhSectionPos.encodePos(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, 0, 0);
|
||||
long ne = DhSectionPos.encodePos(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, 1, 0);
|
||||
long sw = DhSectionPos.encodePos(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, 0, 1);
|
||||
long se = DhSectionPos.encodePos(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, 1, 1);
|
||||
long nw = DhSectionPos.encode(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, 0, 0);
|
||||
long ne = DhSectionPos.encode(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, 1, 0);
|
||||
long sw = DhSectionPos.encode(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, 0, 1);
|
||||
long se = DhSectionPos.encode(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, 1, 1);
|
||||
|
||||
testSet(tree, nw, 2);
|
||||
testSet(tree, ne, 3);
|
||||
@@ -260,12 +260,12 @@ public class QuadTreeTest
|
||||
Assert.assertEquals("Tree center incorrect", DhBlockPos2D.ZERO, tree.getCenterBlockPos());
|
||||
|
||||
// on the negative X edge
|
||||
long edgePos = DhSectionPos.encodePos(LodUtil.BLOCK_DETAIL_LEVEL, -treeParams.getWidthInBlocks() / 2, 0);
|
||||
long edgePos = DhSectionPos.encode(LodUtil.BLOCK_DETAIL_LEVEL, -treeParams.getWidthInBlocks() / 2, 0);
|
||||
testSet(tree, edgePos, 1);
|
||||
Assert.assertEquals("incorrect leaf node count", 1, tree.leafNodeCount());
|
||||
|
||||
// +1 root node from the negative X edge
|
||||
long adjacentEdgePos = DhSectionPos.encodePos(LodUtil.BLOCK_DETAIL_LEVEL, (-treeParams.getWidthInBlocks() / 2) + pseudoRootNodeWidthInBlocks, 0);
|
||||
long adjacentEdgePos = DhSectionPos.encode(LodUtil.BLOCK_DETAIL_LEVEL, (-treeParams.getWidthInBlocks() / 2) + pseudoRootNodeWidthInBlocks, 0);
|
||||
testSet(tree, adjacentEdgePos, 2);
|
||||
Assert.assertEquals("incorrect leaf node count", 2, tree.leafNodeCount());
|
||||
|
||||
@@ -285,14 +285,14 @@ public class QuadTreeTest
|
||||
|
||||
|
||||
// (pseudo) root nodes //
|
||||
testSet(tree, DhSectionPos.encodePos((byte) 10, 0, 0), 1);
|
||||
testSet(tree, DhSectionPos.encodePos((byte) 10, 1, 0), 2);
|
||||
testSet(tree, DhSectionPos.encode((byte) 10, 0, 0), 1);
|
||||
testSet(tree, DhSectionPos.encode((byte) 10, 1, 0), 2);
|
||||
|
||||
// first child (0,0) //
|
||||
testSet(tree, DhSectionPos.encodePos((byte) 9, 0, 0), 3);
|
||||
testSet(tree, DhSectionPos.encodePos((byte) 9, 1, 0), 4);
|
||||
testSet(tree, DhSectionPos.encodePos((byte) 9, 0, 1), 5);
|
||||
testSet(tree, DhSectionPos.encodePos((byte) 9, 1, 1), 6);
|
||||
testSet(tree, DhSectionPos.encode((byte) 9, 0, 0), 3);
|
||||
testSet(tree, DhSectionPos.encode((byte) 9, 1, 0), 4);
|
||||
testSet(tree, DhSectionPos.encode((byte) 9, 0, 1), 5);
|
||||
testSet(tree, DhSectionPos.encode((byte) 9, 1, 1), 6);
|
||||
|
||||
|
||||
|
||||
@@ -332,19 +332,19 @@ public class QuadTreeTest
|
||||
@Test
|
||||
public void NewQuadTreeIterationTest()
|
||||
{
|
||||
QuadNode<Integer> rootNode = new QuadNode<>(DhSectionPos.encodePos((byte) 10, 0, 0), LodUtil.BLOCK_DETAIL_LEVEL);
|
||||
QuadNode<Integer> rootNode = new QuadNode<>(DhSectionPos.encode((byte) 10, 0, 0), LodUtil.BLOCK_DETAIL_LEVEL);
|
||||
|
||||
rootNode.setValue(DhSectionPos.encodePos((byte) 10, 0, 0), 0);
|
||||
rootNode.setValue(DhSectionPos.encode((byte) 10, 0, 0), 0);
|
||||
|
||||
rootNode.setValue(DhSectionPos.encodePos((byte) 9, 0, 0), 1);
|
||||
rootNode.setValue(DhSectionPos.encodePos((byte) 9, 1, 0), 1);
|
||||
rootNode.setValue(DhSectionPos.encodePos((byte) 9, 0, 1), 1);
|
||||
rootNode.setValue(DhSectionPos.encodePos((byte) 9, 1, 1), null);
|
||||
rootNode.setValue(DhSectionPos.encode((byte) 9, 0, 0), 1);
|
||||
rootNode.setValue(DhSectionPos.encode((byte) 9, 1, 0), 1);
|
||||
rootNode.setValue(DhSectionPos.encode((byte) 9, 0, 1), 1);
|
||||
rootNode.setValue(DhSectionPos.encode((byte) 9, 1, 1), null);
|
||||
|
||||
rootNode.setValue(DhSectionPos.encodePos((byte) 8, 0, 0), 2);
|
||||
rootNode.setValue(DhSectionPos.encodePos((byte) 8, 1, 0), 2);
|
||||
rootNode.setValue(DhSectionPos.encodePos((byte) 8, 0, 1), 2);
|
||||
rootNode.setValue(DhSectionPos.encodePos((byte) 8, 1, 1), null);
|
||||
rootNode.setValue(DhSectionPos.encode((byte) 8, 0, 0), 2);
|
||||
rootNode.setValue(DhSectionPos.encode((byte) 8, 1, 0), 2);
|
||||
rootNode.setValue(DhSectionPos.encode((byte) 8, 0, 1), 2);
|
||||
rootNode.setValue(DhSectionPos.encode((byte) 8, 1, 1), null);
|
||||
|
||||
|
||||
|
||||
@@ -411,7 +411,7 @@ public class QuadTreeTest
|
||||
{
|
||||
AbstractTestTreeParams treeParams = new TinyTestTree();
|
||||
final QuadTree<Integer> tree = new QuadTree<>(treeParams.getWidthInBlocks(), treeParams.getPositiveEdgeCenterPos(), LodUtil.BLOCK_DETAIL_LEVEL);
|
||||
testSet(tree, DhSectionPos.encodePos(tree.treeMinDetailLevel, 0, 0), 0);
|
||||
testSet(tree, DhSectionPos.encode(tree.treeMinDetailLevel, 0, 0), 0);
|
||||
|
||||
// confirm the root node were added
|
||||
int rootNodeCount = 0;
|
||||
@@ -499,10 +499,10 @@ public class QuadTreeTest
|
||||
Assert.assertEquals("incorrect tree width", treeParams.getWidthInBlocks(), tree.diameterInBlocks());
|
||||
|
||||
|
||||
testSet(tree, DhSectionPos.encodePos(tree.treeMinDetailLevel, 0, 0), 0);
|
||||
testSet(tree, DhSectionPos.encode(tree.treeMinDetailLevel, 0, 0), 0);
|
||||
|
||||
testSet(tree, DhSectionPos.encodePos(tree.treeMinDetailLevel, -1, -1), -1, IndexOutOfBoundsException.class);
|
||||
testSet(tree, DhSectionPos.encodePos(tree.treeMinDetailLevel, 1, 1), -1, IndexOutOfBoundsException.class);
|
||||
testSet(tree, DhSectionPos.encode(tree.treeMinDetailLevel, -1, -1), -1, IndexOutOfBoundsException.class);
|
||||
testSet(tree, DhSectionPos.encode(tree.treeMinDetailLevel, 1, 1), -1, IndexOutOfBoundsException.class);
|
||||
|
||||
int rootNodeCount = 0;
|
||||
LongIterator rootNodeIterator = tree.rootNodePosIterator();
|
||||
@@ -529,18 +529,18 @@ public class QuadTreeTest
|
||||
|
||||
|
||||
// 2x2 valid positions (overlap the tree's width)
|
||||
testSet(tree, DhSectionPos.encodePos(tree.treeMinDetailLevel, 0, 0), 0);
|
||||
testSet(tree, DhSectionPos.encodePos(tree.treeMinDetailLevel, -1, 0), 0);
|
||||
testSet(tree, DhSectionPos.encodePos(tree.treeMinDetailLevel, 0, -1), 0);
|
||||
testSet(tree, DhSectionPos.encodePos(tree.treeMinDetailLevel, -1, -1), 0);
|
||||
testSet(tree, DhSectionPos.encode(tree.treeMinDetailLevel, 0, 0), 0);
|
||||
testSet(tree, DhSectionPos.encode(tree.treeMinDetailLevel, -1, 0), 0);
|
||||
testSet(tree, DhSectionPos.encode(tree.treeMinDetailLevel, 0, -1), 0);
|
||||
testSet(tree, DhSectionPos.encode(tree.treeMinDetailLevel, -1, -1), 0);
|
||||
|
||||
// invalid positions
|
||||
testSet(tree, DhSectionPos.encodePos(tree.treeMinDetailLevel, -1, 1), -1, IndexOutOfBoundsException.class);
|
||||
testSet(tree, DhSectionPos.encodePos(tree.treeMinDetailLevel, 0, 1), -1, IndexOutOfBoundsException.class);
|
||||
testSet(tree, DhSectionPos.encode(tree.treeMinDetailLevel, -1, 1), -1, IndexOutOfBoundsException.class);
|
||||
testSet(tree, DhSectionPos.encode(tree.treeMinDetailLevel, 0, 1), -1, IndexOutOfBoundsException.class);
|
||||
|
||||
testSet(tree, DhSectionPos.encodePos(tree.treeMinDetailLevel, 1, 0), -1, IndexOutOfBoundsException.class);
|
||||
testSet(tree, DhSectionPos.encodePos(tree.treeMinDetailLevel, 1, 1), -1, IndexOutOfBoundsException.class);
|
||||
testSet(tree, DhSectionPos.encodePos(tree.treeMinDetailLevel, 1, -1), -1, IndexOutOfBoundsException.class);
|
||||
testSet(tree, DhSectionPos.encode(tree.treeMinDetailLevel, 1, 0), -1, IndexOutOfBoundsException.class);
|
||||
testSet(tree, DhSectionPos.encode(tree.treeMinDetailLevel, 1, 1), -1, IndexOutOfBoundsException.class);
|
||||
testSet(tree, DhSectionPos.encode(tree.treeMinDetailLevel, 1, -1), -1, IndexOutOfBoundsException.class);
|
||||
|
||||
|
||||
int rootNodeCount = 0;
|
||||
@@ -565,17 +565,17 @@ public class QuadTreeTest
|
||||
Assert.assertEquals("Test detail level's need to be adjusted. This isn't necessarily a failed test.", 10, tree.treeMinDetailLevel);
|
||||
|
||||
// valid detail levels
|
||||
testSet(tree, DhSectionPos.encodePos((byte) 10, 0, 0), 1);
|
||||
testSet(tree, DhSectionPos.encodePos((byte) 9, 0, 0), 2);
|
||||
testSet(tree, DhSectionPos.encodePos((byte) 8, 0, 0), 3);
|
||||
testSet(tree, DhSectionPos.encode((byte) 10, 0, 0), 1);
|
||||
testSet(tree, DhSectionPos.encode((byte) 9, 0, 0), 2);
|
||||
testSet(tree, DhSectionPos.encode((byte) 8, 0, 0), 3);
|
||||
|
||||
// detail level too low
|
||||
testSet(tree, DhSectionPos.encodePos((byte) 7, 0, 0), -1, IndexOutOfBoundsException.class);
|
||||
testSet(tree, DhSectionPos.encodePos((byte) 6, 0, 0), -1, IndexOutOfBoundsException.class);
|
||||
testSet(tree, DhSectionPos.encode((byte) 7, 0, 0), -1, IndexOutOfBoundsException.class);
|
||||
testSet(tree, DhSectionPos.encode((byte) 6, 0, 0), -1, IndexOutOfBoundsException.class);
|
||||
|
||||
// detail level too high
|
||||
testSet(tree, DhSectionPos.encodePos((byte) 11, 0, 0), -1, IndexOutOfBoundsException.class);
|
||||
testSet(tree, DhSectionPos.encodePos((byte) 12, 0, 0), -1, IndexOutOfBoundsException.class);
|
||||
testSet(tree, DhSectionPos.encode((byte) 11, 0, 0), -1, IndexOutOfBoundsException.class);
|
||||
testSet(tree, DhSectionPos.encode((byte) 12, 0, 0), -1, IndexOutOfBoundsException.class);
|
||||
|
||||
}
|
||||
|
||||
@@ -587,7 +587,7 @@ public class QuadTreeTest
|
||||
Assert.assertEquals("Test detail level's need to be adjusted. This isn't necessarily a failed test.", 10, tree.treeMinDetailLevel);
|
||||
|
||||
// create the root node
|
||||
testSet(tree, DhSectionPos.encodePos((byte) 10, 0, 0), 1);
|
||||
testSet(tree, DhSectionPos.encode((byte) 10, 0, 0), 1);
|
||||
|
||||
|
||||
|
||||
@@ -678,7 +678,7 @@ public class QuadTreeTest
|
||||
@Test
|
||||
public void quadNodeChildPositionIndexTest()
|
||||
{
|
||||
QuadNode<Integer> rootNode = new QuadNode<>(DhSectionPos.encodePos((byte) 10, 0, 0), (byte) 0);
|
||||
QuadNode<Integer> rootNode = new QuadNode<>(DhSectionPos.encode((byte) 10, 0, 0), (byte) 0);
|
||||
LongIterator directChildPosIterator = rootNode.getChildPosIterator();
|
||||
while (directChildPosIterator.hasNext())
|
||||
{
|
||||
@@ -708,7 +708,7 @@ public class QuadTreeTest
|
||||
|
||||
|
||||
// center root node
|
||||
long centerNodePos = DhSectionPos.encodePos((byte) 1, 0, 0);
|
||||
long centerNodePos = DhSectionPos.encode((byte) 1, 0, 0);
|
||||
|
||||
// create node
|
||||
tree.setValue(centerNodePos, 0);
|
||||
@@ -727,7 +727,7 @@ public class QuadTreeTest
|
||||
|
||||
|
||||
// edge root node
|
||||
long offsetNodePos = DhSectionPos.encodePos((byte) 1, -17, -16);
|
||||
long offsetNodePos = DhSectionPos.encode((byte) 1, -17, -16);
|
||||
|
||||
// create node
|
||||
tree.setValue(offsetNodePos, 0);
|
||||
@@ -772,7 +772,7 @@ public class QuadTreeTest
|
||||
|
||||
|
||||
//
|
||||
testSet(tree, DhSectionPos.encodePos((byte) 0, 0, 0), 1);
|
||||
testSet(tree, DhSectionPos.encode((byte) 0, 0, 0), 1);
|
||||
Assert.assertEquals(1, tree.count());
|
||||
tree.setCenterBlockPos(new DhBlockPos2D(treeWidth + (treeWidth / 2), 0));
|
||||
Assert.assertEquals(0, tree.count());
|
||||
@@ -783,21 +783,21 @@ public class QuadTreeTest
|
||||
//@Test
|
||||
public void autoDeleteNullQuadNodeChildTest()
|
||||
{
|
||||
QuadNode<Integer> rootNode = new QuadNode<>(DhSectionPos.encodePos((byte) 10, 0, 0), LodUtil.BLOCK_DETAIL_LEVEL);
|
||||
QuadNode<Integer> rootNode = new QuadNode<>(DhSectionPos.encode((byte) 10, 0, 0), LodUtil.BLOCK_DETAIL_LEVEL);
|
||||
|
||||
|
||||
rootNode.setValue(DhSectionPos.encodePos((byte) 10, 0, 0), 0);
|
||||
rootNode.setValue(DhSectionPos.encode((byte) 10, 0, 0), 0);
|
||||
|
||||
long midNodePos = DhSectionPos.encodePos((byte) 9, 0, 0);
|
||||
long midNodePos = DhSectionPos.encode((byte) 9, 0, 0);
|
||||
//rootNode.setValue(midNodePos, null); // holds detail 8
|
||||
rootNode.setValue(DhSectionPos.encodePos((byte) 9, 1, 0), 1);
|
||||
rootNode.setValue(DhSectionPos.encodePos((byte) 9, 0, 1), 1);
|
||||
rootNode.setValue(DhSectionPos.encodePos((byte) 9, 1, 1), 1);
|
||||
rootNode.setValue(DhSectionPos.encode((byte) 9, 1, 0), 1);
|
||||
rootNode.setValue(DhSectionPos.encode((byte) 9, 0, 1), 1);
|
||||
rootNode.setValue(DhSectionPos.encode((byte) 9, 1, 1), 1);
|
||||
|
||||
rootNode.setValue(DhSectionPos.encodePos((byte) 8, 0, 0), 2);
|
||||
rootNode.setValue(DhSectionPos.encodePos((byte) 8, 1, 0), 2);
|
||||
rootNode.setValue(DhSectionPos.encodePos((byte) 8, 0, 1), 2);
|
||||
rootNode.setValue(DhSectionPos.encodePos((byte) 8, 1, 1), 2);
|
||||
rootNode.setValue(DhSectionPos.encode((byte) 8, 0, 0), 2);
|
||||
rootNode.setValue(DhSectionPos.encode((byte) 8, 1, 0), 2);
|
||||
rootNode.setValue(DhSectionPos.encode((byte) 8, 0, 1), 2);
|
||||
rootNode.setValue(DhSectionPos.encode((byte) 8, 1, 1), 2);
|
||||
|
||||
|
||||
|
||||
@@ -810,12 +810,12 @@ public class QuadTreeTest
|
||||
// test removing nodes //
|
||||
|
||||
// remove two leaf nodes from the root
|
||||
long leafPos = DhSectionPos.encodePos((byte) 9, 1, 1);
|
||||
long leafPos = DhSectionPos.encode((byte) 9, 1, 1);
|
||||
rootNode.setValue(leafPos, null);
|
||||
Assert.assertEquals(3, rootNode.getNonNullChildCount());
|
||||
Assert.assertNull("Node wasn't deleted", rootNode.getNode(leafPos));
|
||||
|
||||
leafPos = DhSectionPos.encodePos((byte) 9, 0, 1);
|
||||
leafPos = DhSectionPos.encode((byte) 9, 0, 1);
|
||||
rootNode.setValue(leafPos, null);
|
||||
Assert.assertEquals(2, rootNode.getNonNullChildCount());
|
||||
Assert.assertNull("Node wasn't deleted", rootNode.getNode(leafPos));
|
||||
@@ -827,13 +827,13 @@ public class QuadTreeTest
|
||||
Assert.assertEquals(4, rootNode.getNode(midNodePos).getNonNullChildCount());
|
||||
|
||||
// remove all but one, mid-node should still be present
|
||||
rootNode.setValue(DhSectionPos.encodePos((byte) 8, 0, 0), null);
|
||||
rootNode.setValue(DhSectionPos.encodePos((byte) 8, 0, 1), null);
|
||||
rootNode.setValue(DhSectionPos.encodePos((byte) 8, 1, 0), null);
|
||||
rootNode.setValue(DhSectionPos.encode((byte) 8, 0, 0), null);
|
||||
rootNode.setValue(DhSectionPos.encode((byte) 8, 0, 1), null);
|
||||
rootNode.setValue(DhSectionPos.encode((byte) 8, 1, 0), null);
|
||||
Assert.assertEquals(1, rootNode.getNode(midNodePos).getNonNullChildCount());
|
||||
|
||||
// remove last mid-node child, mid-node should now be removed
|
||||
rootNode.setValue(DhSectionPos.encodePos((byte) 8, 1, 1), null);
|
||||
rootNode.setValue(DhSectionPos.encode((byte) 8, 1, 1), null);
|
||||
Assert.assertNull("Mid node not deleted.", rootNode.getNode(midNodePos));
|
||||
Assert.assertEquals(3, rootNode.getNonNullChildCount());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user