Rename DhSectionPos.getMinCornerLodPos()

This commit is contained in:
James Seibel
2023-09-14 20:11:09 -05:00
parent 4d863adac5
commit 1c247e0da2
10 changed files with 35 additions and 38 deletions
@@ -115,7 +115,7 @@ public class FullDataDownSampler
{
return;
}
DhLodPos trgOffset = trgPos.getCorner(target.getDataDetailLevel());
DhLodPos trgOffset = trgPos.getMinCornerLodPos(target.getDataDetailLevel());
DhLodPos srcOffset = srcPos.getSectionBBoxPos().convertToDetailLevel(target.getDataDetailLevel());
int offsetX = trgOffset.x - srcOffset.x;
int offsetZ = trgOffset.z - srcOffset.z;
@@ -131,7 +131,7 @@ public class FullDataDownSampler
int srcDataPerTrgData = 1 << detailDiff;
int overlappedTrgDataSize = CompleteFullDataSource.WIDTH / srcDataPerTrgData;
DhLodPos trgOffset = trgPos.getCorner(target.getDataDetailLevel());
DhLodPos trgOffset = trgPos.getMinCornerLodPos(target.getDataDetailLevel());
DhLodPos srcOffset = srcPos.getSectionBBoxPos().getCornerLodPos(target.getDataDetailLevel());
int offsetX = trgOffset.x - srcOffset.x;
int offsetZ = trgOffset.z - srcOffset.z;
@@ -281,7 +281,7 @@ public class CompleteFullDataSource extends FullDataArrayAccessor implements IFu
if (this.getDataDetailLevel() == LodUtil.BLOCK_DETAIL_LEVEL)
{
DhBlockPos2D chunkBlockPos = new DhBlockPos2D(chunkDataView.pos.x * LodUtil.CHUNK_WIDTH, chunkDataView.pos.z * LodUtil.CHUNK_WIDTH);
DhBlockPos2D blockOffset = chunkBlockPos.subtract(this.sectionPos.getCorner().getCornerBlockPos());
DhBlockPos2D blockOffset = chunkBlockPos.subtract(this.sectionPos.getMinCornerLodPos().getCornerBlockPos());
LodUtil.assertTrue(blockOffset.x >= 0 && blockOffset.x < WIDTH && blockOffset.z >= 0 && blockOffset.z < WIDTH);
this.isEmpty = false;
@@ -304,7 +304,7 @@ public class CompleteFullDataSource extends FullDataArrayAccessor implements IFu
int dataPerFull = 1 << this.getDataDetailLevel();
int fullSize = LodUtil.CHUNK_WIDTH / dataPerFull;
DhLodPos dataOffset = chunkDataView.getLodPos().getCornerLodPos(this.getDataDetailLevel());
DhLodPos baseOffset = this.sectionPos.getCorner(this.getDataDetailLevel());
DhLodPos baseOffset = this.sectionPos.getMinCornerLodPos(this.getDataDetailLevel());
int offsetX = dataOffset.x - baseOffset.x;
int offsetZ = dataOffset.z - baseOffset.z;
@@ -329,7 +329,7 @@ public class CompleteFullDataSource extends FullDataArrayAccessor implements IFu
return;
}
DhLodPos baseOffset = this.sectionPos.getCorner(this.getDataDetailLevel());
DhLodPos baseOffset = this.sectionPos.getMinCornerLodPos(this.getDataDetailLevel());
DhLodPos dataOffset = chunkDataView.getLodPos().convertToDetailLevel(this.getDataDetailLevel());
int offsetX = dataOffset.x - baseOffset.x;
@@ -428,7 +428,7 @@ public class CompleteFullDataSource extends FullDataArrayAccessor implements IFu
DhSectionPos lowerSectPos = subData.sectionPos;
byte detailDiff = (byte) (this.sectionPos.sectionDetailLevel - subData.sectionPos.sectionDetailLevel);
byte targetDataDetail = this.getDataDetailLevel();
DhLodPos minDataPos = this.sectionPos.getCorner(targetDataDetail);
DhLodPos minDataPos = this.sectionPos.getMinCornerLodPos(targetDataDetail);
if (detailDiff <= SECTION_SIZE_OFFSET)
{
int count = 1 << detailDiff;
@@ -104,7 +104,7 @@ public class HighDetailIncompleteFullDataSource implements IIncompleteFullDataSo
this.dataPointsPerSection = SECTION_SIZE / this.sectionCount;
this.sparseData = new FullDataArrayAccessor[this.sectionCount * this.sectionCount];
this.chunkPos = sectionPos.getCorner(SPARSE_UNIT_DETAIL);
this.chunkPos = sectionPos.getMinCornerLodPos(SPARSE_UNIT_DETAIL);
this.mapping = new FullDataPointIdMap(sectionPos);
}
@@ -119,7 +119,7 @@ public class HighDetailIncompleteFullDataSource implements IIncompleteFullDataSo
LodUtil.assertTrue(this.sectionCount * this.sectionCount == data.length);
this.sparseData = data;
this.chunkPos = sectionPos.getCorner(SPARSE_UNIT_DETAIL);
this.chunkPos = sectionPos.getMinCornerLodPos(SPARSE_UNIT_DETAIL);
this.isEmpty = false;
this.mapping = mapping;
}
@@ -520,8 +520,8 @@ public class HighDetailIncompleteFullDataSource implements IIncompleteFullDataSo
DhSectionPos pos = completeDataSource.getSectionPos();
this.isEmpty = false;
DhLodPos basePos = this.sectionPos.getCorner(SPARSE_UNIT_DETAIL);
DhLodPos dataPos = pos.getCorner(SPARSE_UNIT_DETAIL);
DhLodPos basePos = this.sectionPos.getMinCornerLodPos(SPARSE_UNIT_DETAIL);
DhLodPos dataPos = pos.getMinCornerLodPos(SPARSE_UNIT_DETAIL);
int coveredChunks = pos.getWidthCountForLowerDetailedSection(SPARSE_UNIT_DETAIL);
int sourceDataPerChunk = SPARSE_UNIT_SIZE >>> completeDataSource.getDataDetailLevel();
@@ -547,8 +547,8 @@ public class HighDetailIncompleteFullDataSource implements IIncompleteFullDataSo
DhSectionPos pos = sparseDataSource.getSectionPos();
this.isEmpty = false;
DhLodPos basePos = this.sectionPos.getCorner(SPARSE_UNIT_DETAIL);
DhLodPos dataPos = pos.getCorner(SPARSE_UNIT_DETAIL);
DhLodPos basePos = this.sectionPos.getMinCornerLodPos(SPARSE_UNIT_DETAIL);
DhLodPos dataPos = pos.getMinCornerLodPos(SPARSE_UNIT_DETAIL);
int offsetX = dataPos.x - basePos.x;
int offsetZ = dataPos.z - basePos.z;
@@ -329,7 +329,7 @@ public class LowDetailIncompleteFullDataSource extends FullDataArrayAccessor imp
return;
}
DhLodPos baseOffset = this.sectionPos.getCorner(this.getDataDetailLevel());
DhLodPos baseOffset = this.sectionPos.getMinCornerLodPos(this.getDataDetailLevel());
DhLodPos dataOffset = data.getLodPos().convertToDetailLevel(this.getDataDetailLevel());
int offsetX = dataOffset.x - baseOffset.x;
int offsetZ = dataOffset.z - baseOffset.z;
@@ -384,14 +384,14 @@ public class LowDetailIncompleteFullDataSource extends FullDataArrayAccessor imp
private void sampleFrom(HighDetailIncompleteFullDataSource sparseSource)
{
DhLodPos thisLodPos = this.sectionPos.getCorner(this.getDataDetailLevel());
DhLodPos thisLodPos = this.sectionPos.getMinCornerLodPos(this.getDataDetailLevel());
DhSectionPos pos = sparseSource.getSectionPos();
this.isEmpty = false;
if (this.getDataDetailLevel() > this.sectionPos.sectionDetailLevel)
{
DhLodPos dataLodPos = pos.getCorner(this.getDataDetailLevel());
DhLodPos dataLodPos = pos.getMinCornerLodPos(this.getDataDetailLevel());
int offsetX = dataLodPos.x - thisLodPos.x;
int offsetZ = dataLodPos.z - thisLodPos.z;
@@ -447,8 +447,8 @@ public class LowDetailIncompleteFullDataSource extends FullDataArrayAccessor imp
if (this.getDataDetailLevel() > this.sectionPos.sectionDetailLevel) // TODO what does this mean?
{
DhLodPos thisLodPos = this.sectionPos.getCorner(this.getDataDetailLevel());
DhLodPos dataLodPos = pos.getCorner(this.getDataDetailLevel());
DhLodPos thisLodPos = this.sectionPos.getMinCornerLodPos(this.getDataDetailLevel());
DhLodPos dataLodPos = pos.getMinCornerLodPos(this.getDataDetailLevel());
int offsetX = dataLodPos.x - thisLodPos.x;
int offsetZ = dataLodPos.z - thisLodPos.z;
@@ -472,7 +472,7 @@ public class LowDetailIncompleteFullDataSource extends FullDataArrayAccessor imp
}
DhLodPos basePos = this.sectionPos.getCorner(this.getDataDetailLevel());
DhLodPos basePos = this.sectionPos.getMinCornerLodPos(this.getDataDetailLevel());
dataPos = dataPos.convertToDetailLevel(this.getDataDetailLevel());
int offsetX = dataPos.x - basePos.x;
int offsetZ = dataPos.z - basePos.z;
@@ -490,8 +490,8 @@ public class LowDetailIncompleteFullDataSource extends FullDataArrayAccessor imp
if (this.getDataDetailLevel() > this.sectionPos.sectionDetailLevel)
{
DhLodPos thisLodPos = this.sectionPos.getCorner(this.getDataDetailLevel());
DhLodPos dataLodPos = pos.getCorner(this.getDataDetailLevel());
DhLodPos thisLodPos = this.sectionPos.getMinCornerLodPos(this.getDataDetailLevel());
DhLodPos dataLodPos = pos.getMinCornerLodPos(this.getDataDetailLevel());
int offsetX = dataLodPos.x - thisLodPos.x;
int offsetZ = dataLodPos.z - thisLodPos.z;
@@ -515,7 +515,7 @@ public class LowDetailIncompleteFullDataSource extends FullDataArrayAccessor imp
}
DhLodPos basePos = this.sectionPos.getCorner(this.getDataDetailLevel());
DhLodPos basePos = this.sectionPos.getMinCornerLodPos(this.getDataDetailLevel());
dataPos = dataPos.convertToDetailLevel(this.getDataDetailLevel());
int offsetX = dataPos.x - basePos.x;
int offsetZ = dataPos.z - basePos.z;
@@ -312,8 +312,8 @@ public class ColumnRenderSource
final DhSectionPos renderSourcePos = this.getSectionPos();
final int sourceBlockX = renderSourcePos.getCorner().getCornerBlockPos().x;
final int sourceBlockZ = renderSourcePos.getCorner().getCornerBlockPos().z;
final int sourceBlockX = renderSourcePos.getMinCornerLodPos().getCornerBlockPos().x;
final int sourceBlockZ = renderSourcePos.getMinCornerLodPos().getCornerBlockPos().z;
// offset between the incoming chunk data and this render source
final int blockOffsetX = (chunkDataView.pos.x * LodUtil.CHUNK_WIDTH) - sourceBlockX;
@@ -365,7 +365,7 @@ public class ColumnRenderSource
this.markNotEmpty();
// multiple chunk data points converting to 1 column data point
DhLodPos dataCornerPos = chunkDataView.getLodPos().getCornerLodPos(chunkDataView.detailLevel);
DhLodPos sourceCornerPos = renderSourcePos.getCorner(this.getDataDetail());
DhLodPos sourceCornerPos = renderSourcePos.getMinCornerLodPos(this.getDataDetail());
DhLodPos sourceStartingChangePos = dataCornerPos.convertToDetailLevel(this.getDataDetail());
int relStartX = Math.floorMod(sourceStartingChangePos.x, this.getWidthInDataPoints());
int relStartZ = Math.floorMod(sourceStartingChangePos.z, this.getWidthInDataPoints());
@@ -394,7 +394,7 @@ public class ColumnRenderSource
{
// The entire chunk is being converted to a single column data point, possibly.
DhLodPos dataCornerPos = chunkDataView.getLodPos().getCornerLodPos(chunkDataView.detailLevel);
DhLodPos sourceCornerPos = renderSourcePos.getCorner(this.getDataDetail());
DhLodPos sourceCornerPos = renderSourcePos.getMinCornerLodPos(this.getDataDetail());
DhLodPos sourceStartingChangePos = dataCornerPos.convertToDetailLevel(this.getDataDetail());
int chunksPerColumn = sourceStartingChangePos.getWidthAtDetail(chunkDataView.getLodPos().detailLevel);
if (chunkDataView.getLodPos().x % chunksPerColumn != 0 || chunkDataView.getLodPos().z % chunksPerColumn != 0)
@@ -125,7 +125,7 @@ public class ColumnRenderBufferBuilder
if (buffer == null)
{
buffer = new ColumnRenderBuffer(new DhBlockPos(renderSource.sectionPos.getCorner().getCornerBlockPos(), clientLevel.getMinY()), renderSource.sectionPos);
buffer = new ColumnRenderBuffer(new DhBlockPos(renderSource.sectionPos.getMinCornerLodPos().getCornerBlockPos(), clientLevel.getMinY()), renderSource.sectionPos);
}
try
@@ -132,8 +132,8 @@ public class FullDataToRenderDataTransformer
if (dataDetail == columnSource.getDataDetail())
{
int baseX = pos.getCorner().getCornerBlockPos().x;
int baseZ = pos.getCorner().getCornerBlockPos().z;
int baseX = pos.getMinCornerLodPos().getCornerBlockPos().x;
int baseZ = pos.getMinCornerLodPos().getCornerBlockPos().z;
for (int x = 0; x < pos.getWidthCountForLowerDetailedSection(dataDetail); x++)
{
@@ -182,8 +182,8 @@ public class FullDataToRenderDataTransformer
if (dataDetail == columnSource.getDataDetail())
{
int baseX = pos.getCorner().getCornerBlockPos().x;
int baseZ = pos.getCorner().getCornerBlockPos().z;
int baseX = pos.getMinCornerLodPos().getCornerBlockPos().x;
int baseZ = pos.getMinCornerLodPos().getCornerBlockPos().z;
for (int x = 0; x < pos.getWidthCountForLowerDetailedSection(dataDetail); x++)
{
for (int z = 0; z < pos.getWidthCountForLowerDetailedSection(dataDetail); z++)
@@ -232,7 +232,7 @@ public class FullDataFileHandler implements IFullDataSourceProvider
outerLoop:
while (--sectionDetail >= this.minDetailLevel)
{
DhLodPos minPos = posAreaToGet.getCorner().getCornerLodPos(sectionDetail);
DhLodPos minPos = posAreaToGet.getMinCornerLodPos().getCornerLodPos(sectionDetail);
int count = posAreaToGet.getSectionBBoxPos().getWidthAtDetail(sectionDetail);
for (int xOffset = 0; xOffset < count; xOffset++)
@@ -51,7 +51,6 @@ public class DhLodPos implements Comparable<DhLodPos>
//=========//
// getters //
//=========//
@@ -144,9 +144,9 @@ public class DhSectionPos
//=========//
/** @return the corner with the smallest X and Z coordinate */
public DhLodPos getCorner() { return this.getCorner((byte) (this.sectionDetailLevel - 1)); }
public DhLodPos getMinCornerLodPos() { return this.getMinCornerLodPos((byte) (this.sectionDetailLevel - 1)); }
/** @return the corner with the smallest X and Z coordinate */
public DhLodPos getCorner(byte returnDetailLevel)
public DhLodPos getMinCornerLodPos(byte returnDetailLevel)
{
LodUtil.assertTrue(returnDetailLevel <= this.sectionDetailLevel, "returnDetailLevel must be less than sectionDetail");
@@ -256,14 +256,12 @@ public class DhSectionPos
// comparisons //
//=============//
/** NOTE: This does not consider yOffset! */
public boolean overlaps(DhSectionPos other) { return this.getSectionBBoxPos().overlapsExactly(other.getSectionBBoxPos()); }
/** NOTE: This does not consider yOffset! */
public boolean contains(DhSectionPos otherPos)
{
DhBlockPos2D thisMinBlockPos = this.getCorner(LodUtil.BLOCK_DETAIL_LEVEL).getCornerBlockPos();
DhBlockPos2D otherCornerBlockPos = otherPos.getCorner(LodUtil.BLOCK_DETAIL_LEVEL).getCornerBlockPos();
DhBlockPos2D thisMinBlockPos = this.getMinCornerLodPos(LodUtil.BLOCK_DETAIL_LEVEL).getCornerBlockPos();
DhBlockPos2D otherCornerBlockPos = otherPos.getMinCornerLodPos(LodUtil.BLOCK_DETAIL_LEVEL).getCornerBlockPos();
int thisBlockWidth = this.getBlockWidth() - 1; // minus 1 to account for zero based positional indexing
DhBlockPos2D thisMaxBlockPos = new DhBlockPos2D(thisMinBlockPos.x + thisBlockWidth, thisMinBlockPos.z + thisBlockWidth);