Rename DhLodPos getters to make them more specific
This commit is contained in:
+1
-1
@@ -129,7 +129,7 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
|
||||
*/
|
||||
private static DhApiResult<DhApiTerrainDataPoint[][][]> getTerrainDataOverAreaForPositionDetailLevel(IDhApiLevelWrapper levelWrapper, DhLodPos requestedAreaPos)
|
||||
{
|
||||
DhLodPos startingBlockPos = requestedAreaPos.getCorner(LodUtil.BLOCK_DETAIL_LEVEL);
|
||||
DhLodPos startingBlockPos = requestedAreaPos.getCornerLodPos(LodUtil.BLOCK_DETAIL_LEVEL);
|
||||
int widthOfAreaInBlocks = BitShiftUtil.powerOfTwo(requestedAreaPos.detailLevel);
|
||||
|
||||
DhApiTerrainDataPoint[][][] returnArray = new DhApiTerrainDataPoint[widthOfAreaInBlocks][widthOfAreaInBlocks][];
|
||||
|
||||
+1
-1
@@ -254,7 +254,7 @@ public class ColumnRenderBuffer extends AbstractRenderBuffer
|
||||
|
||||
if (buffer == null)
|
||||
buffer = new ColumnRenderBuffer(
|
||||
new DhBlockPos(data.sectionPos.getCorner().getCorner(), clientLevel.getMinY())
|
||||
new DhBlockPos(data.sectionPos.getCorner().getCornerBlockPos(), clientLevel.getMinY())
|
||||
);
|
||||
try {
|
||||
buffer.uploadBuffer(builder, method);
|
||||
|
||||
@@ -23,7 +23,7 @@ public class FullDataDownSampler {
|
||||
int sectionSizeNeeded = 1 << target.getDataDetail();
|
||||
|
||||
ArrayList<CompletableFuture<ILodDataSource>> futures;
|
||||
DhLodPos basePos = target.getSectionPos().getSectionBBoxPos().getCorner(FullDataSource.SECTION_SIZE_OFFSET);
|
||||
DhLodPos basePos = target.getSectionPos().getSectionBBoxPos().getCornerLodPos(FullDataSource.SECTION_SIZE_OFFSET);
|
||||
if (sectionSizeNeeded <= FullDataSource.SECTION_SIZE_OFFSET) {
|
||||
futures = new ArrayList<>(sectionSizeNeeded * sectionSizeNeeded);
|
||||
for (int ox = 0; ox < sectionSizeNeeded; ox++) {
|
||||
@@ -91,7 +91,7 @@ public class FullDataDownSampler {
|
||||
int overlappedTrgDataSize = FullDataSource.SECTION_SIZE / srcDataPerTrgData;
|
||||
|
||||
DhLodPos trgOffset = trgPos.getCorner(target.getDataDetail());
|
||||
DhLodPos srcOffset = srcPos.getSectionBBoxPos().getCorner(target.getDataDetail());
|
||||
DhLodPos srcOffset = srcPos.getSectionBBoxPos().getCornerLodPos(target.getDataDetail());
|
||||
int offsetX = trgOffset.x - srcOffset.x;
|
||||
int offsetZ = trgOffset.z - srcOffset.z;
|
||||
LodUtil.assertTrue(offsetX >= 0 && offsetX < FullDataSource.SECTION_SIZE
|
||||
|
||||
@@ -66,7 +66,7 @@ public class FullDataSource extends FullArrayView implements ILodDataSource
|
||||
if (data.dataDetail == 0 && this.getDataDetail() == 0)
|
||||
{
|
||||
DhBlockPos2D chunkBlockPos = new DhBlockPos2D(data.x * 16, data.z * 16);
|
||||
DhBlockPos2D blockOffset = chunkBlockPos.subtract(this.sectionPos.getCorner().getCorner());
|
||||
DhBlockPos2D blockOffset = chunkBlockPos.subtract(this.sectionPos.getCorner().getCornerBlockPos());
|
||||
LodUtil.assertTrue(blockOffset.x >= 0 && blockOffset.x < SECTION_SIZE && blockOffset.z >= 0 && blockOffset.z < SECTION_SIZE);
|
||||
this.isEmpty = false;
|
||||
data.shadowCopyTo(this.subView(16, blockOffset.x, blockOffset.z));
|
||||
@@ -85,7 +85,7 @@ public class FullDataSource extends FullArrayView implements ILodDataSource
|
||||
{
|
||||
int dataPerFull = 1 << this.getDataDetail();
|
||||
int fullSize = 16 / dataPerFull;
|
||||
DhLodPos dataOffset = data.getBBoxLodPos().getCorner(this.getDataDetail());
|
||||
DhLodPos dataOffset = data.getBBoxLodPos().getCornerLodPos(this.getDataDetail());
|
||||
DhLodPos baseOffset = this.sectionPos.getCorner(this.getDataDetail());
|
||||
int offsetX = dataOffset.x - baseOffset.x;
|
||||
int offsetZ = dataOffset.z - baseOffset.z;
|
||||
@@ -277,7 +277,7 @@ public class FullDataSource extends FullArrayView implements ILodDataSource
|
||||
{
|
||||
int count = 1 << detailDiff;
|
||||
int dataPerCount = SECTION_SIZE / count;
|
||||
DhLodPos subDataPos = lowerSectPos.getSectionBBoxPos().getCorner(targetDataDetail);
|
||||
DhLodPos subDataPos = lowerSectPos.getSectionBBoxPos().getCornerLodPos(targetDataDetail);
|
||||
int dataOffsetX = subDataPos.x - minDataPos.x;
|
||||
int dataOffsetZ = subDataPos.z - minDataPos.z;
|
||||
LodUtil.assertTrue(dataOffsetX >= 0 && dataOffsetX < SECTION_SIZE && dataOffsetZ >= 0 && dataOffsetZ < SECTION_SIZE);
|
||||
|
||||
+8
-8
@@ -35,8 +35,8 @@ public class FullToColumnTransformer {
|
||||
columnSource.markNotEmpty();
|
||||
|
||||
if (dataDetail == columnSource.getDataDetail()) {
|
||||
int baseX = pos.getCorner().getCorner().x;
|
||||
int baseZ = pos.getCorner().getCorner().z;
|
||||
int baseX = pos.getCorner().getCornerBlockPos().x;
|
||||
int baseZ = pos.getCorner().getCornerBlockPos().z;
|
||||
for (int x = 0; x < pos.getWidth(dataDetail).numberOfLodSectionsWide; x++) {
|
||||
for (int z = 0; z < pos.getWidth(dataDetail).numberOfLodSectionsWide; z++) {
|
||||
ColumnArrayView columnArrayView = columnSource.getVerticalDataPointView(x, z);
|
||||
@@ -75,8 +75,8 @@ public class FullToColumnTransformer {
|
||||
columnSource.markNotEmpty();
|
||||
|
||||
if (dataDetail == columnSource.getDataDetail()) {
|
||||
int baseX = pos.getCorner().getCorner().x;
|
||||
int baseZ = pos.getCorner().getCorner().z;
|
||||
int baseX = pos.getCorner().getCornerBlockPos().x;
|
||||
int baseZ = pos.getCorner().getCornerBlockPos().z;
|
||||
for (int x = 0; x < pos.getWidth(dataDetail).numberOfLodSectionsWide; x++) {
|
||||
for (int z = 0; z < pos.getWidth(dataDetail).numberOfLodSectionsWide; z++) {
|
||||
SingleFullArrayView fullArrayView = data.tryGet(x, z);
|
||||
@@ -99,10 +99,10 @@ public class FullToColumnTransformer {
|
||||
throw new UnsupportedOperationException("To be implemented");
|
||||
|
||||
final DhSectionPos pos = render.getSectionPos();
|
||||
final int renderOffsetX = (data.x*16) - pos.getCorner().getCorner().x;
|
||||
final int renderOffsetZ = (data.z*16) - pos.getCorner().getCorner().z;
|
||||
final int blockX = pos.getCorner().getCorner().x;
|
||||
final int blockZ = pos.getCorner().getCorner().z;
|
||||
final int renderOffsetX = (data.x*16) - pos.getCorner().getCornerBlockPos().x;
|
||||
final int renderOffsetZ = (data.z*16) - pos.getCorner().getCornerBlockPos().z;
|
||||
final int blockX = pos.getCorner().getCornerBlockPos().x;
|
||||
final int blockZ = pos.getCorner().getCornerBlockPos().z;
|
||||
final int perRenderWidth = 1 << render.getDataDetail();
|
||||
final int perDataWidth = 1 << data.dataDetail;
|
||||
render.markNotEmpty();
|
||||
|
||||
@@ -189,7 +189,7 @@ public class DataFileHandler implements IDataSourceProvider
|
||||
outerLoop:
|
||||
while (--sectionDetail >= this.minDetailLevel)
|
||||
{
|
||||
DhLodPos minPos = pos.getCorner().getCorner(sectionDetail);
|
||||
DhLodPos minPos = pos.getCorner().getCornerLodPos(sectionDetail);
|
||||
int count = pos.getSectionBBoxPos().getBlockWidth(sectionDetail);
|
||||
|
||||
for (int xOffset = 0; xOffset < count; xOffset++)
|
||||
|
||||
@@ -43,8 +43,8 @@ public class WorldGenerationQueue implements Closeable
|
||||
(a, b) -> {
|
||||
if (a.detailLevel != b.detailLevel)
|
||||
return a.detailLevel - b.detailLevel;
|
||||
int aDist = a.getCenter().toPos2D().chebyshevDist(Pos2D.ZERO);
|
||||
int bDist = b.getCenter().toPos2D().chebyshevDist(Pos2D.ZERO);
|
||||
int aDist = a.getCenterBlockPos().toPos2D().chebyshevDist(Pos2D.ZERO);
|
||||
int bDist = b.getCenterBlockPos().toPos2D().chebyshevDist(Pos2D.ZERO);
|
||||
if (aDist != bDist)
|
||||
return aDist - bDist;
|
||||
if (a.x != b.x)
|
||||
@@ -125,7 +125,7 @@ public class WorldGenerationQueue implements Closeable
|
||||
byte subDetail = (byte) (this.maxGranularity + requiredDataDetail);
|
||||
int subPosWidthCount = pos.getBlockWidth(subDetail);
|
||||
|
||||
DhLodPos cornerSubPos = pos.getCorner(subDetail);
|
||||
DhLodPos cornerSubPos = pos.getCornerLodPos(subDetail);
|
||||
CompletableFuture<Boolean>[] subFutures = new CompletableFuture[subPosWidthCount * subPosWidthCount];
|
||||
ArrayList<WorldGenTask> subTasks = new ArrayList<>(subPosWidthCount * subPosWidthCount);
|
||||
SplitTaskTracker splitTaskTracker = new SplitTaskTracker(tracker, new CompletableFuture<>());
|
||||
@@ -228,7 +228,7 @@ public class WorldGenerationQueue implements Closeable
|
||||
{
|
||||
if (i == targetChildId)
|
||||
continue;
|
||||
WorldGenTaskGroup group = this.taskGroups.get(parentPos.getChildByIndex(i));
|
||||
WorldGenTaskGroup group = this.taskGroups.get(parentPos.getChildPosByIndex(i));
|
||||
if (group == null || group.dataDetail != target.dataDetail)
|
||||
{
|
||||
allPassed = false;
|
||||
@@ -244,7 +244,7 @@ public class WorldGenerationQueue implements Closeable
|
||||
if (i == targetChildId)
|
||||
groups[i] = target;
|
||||
else
|
||||
groups[i] = this.taskGroups.remove(parentPos.getChildByIndex(i));
|
||||
groups[i] = this.taskGroups.remove(parentPos.getChildPosByIndex(i));
|
||||
LodUtil.assertTrue(groups[i] != null && groups[i].dataDetail == target.dataDetail);
|
||||
}
|
||||
|
||||
@@ -394,7 +394,7 @@ public class WorldGenerationQueue implements Closeable
|
||||
if (currentDetailChecking == -1)
|
||||
currentDetailChecking = group.dataDetail;
|
||||
LodUtil.assertTrue(currentDetailChecking == group.dataDetail);
|
||||
int chebDistToOrigin = group.pos.getCenter().toPos2D().chebyshevDist(Pos2D.ZERO);
|
||||
int chebDistToOrigin = group.pos.getCenterBlockPos().toPos2D().chebyshevDist(Pos2D.ZERO);
|
||||
if (chebDistToOrigin > lastChebDist)
|
||||
{
|
||||
if (!continueNextRound)
|
||||
@@ -402,7 +402,7 @@ public class WorldGenerationQueue implements Closeable
|
||||
continueNextRound = false;
|
||||
lastChebDist = chebDistToOrigin;
|
||||
}
|
||||
long dist = group.pos.getCenter().distSquared(targetPos);
|
||||
long dist = group.pos.getCenterBlockPos().distSquared(targetPos);
|
||||
if (best != null && dist >= cachedDist)
|
||||
continue;
|
||||
cachedDist = dist;
|
||||
@@ -462,7 +462,7 @@ public class WorldGenerationQueue implements Closeable
|
||||
LodUtil.assertTrue(granularity >= this.minGranularity && granularity <= this.maxGranularity);
|
||||
LodUtil.assertTrue(dataDetail >= this.minDataDetail && dataDetail <= this.maxDataDetail);
|
||||
|
||||
DhChunkPos chunkPosMin = new DhChunkPos(pos.getCorner());
|
||||
DhChunkPos chunkPosMin = new DhChunkPos(pos.getCornerBlockPos());
|
||||
LOGGER.info("Generating section {} with granularity {} at {}", pos, granularity, chunkPosMin);
|
||||
task.genFuture = startGenerationEvent(this.generator, chunkPosMin, granularity, dataDetail, task.group::accept);
|
||||
task.genFuture.whenComplete((v, ex) -> {
|
||||
|
||||
@@ -16,6 +16,7 @@ import java.util.Objects;
|
||||
public class DhLodPos implements Comparable<DhLodPos>
|
||||
{
|
||||
public final byte detailLevel;
|
||||
|
||||
public final int x;
|
||||
public final int z;
|
||||
|
||||
@@ -44,16 +45,16 @@ public class DhLodPos implements Comparable<DhLodPos>
|
||||
return BitShiftUtil.powerOfTwo(this.detailLevel - detailLevel);
|
||||
}
|
||||
|
||||
public DhBlockPos2D getCenter()
|
||||
public DhBlockPos2D getCenterBlockPos()
|
||||
{
|
||||
return new DhBlockPos2D(
|
||||
this.getX().toBlockWidth() + BitShiftUtil.half(this.getBlockWidth()),
|
||||
this.getZ().toBlockWidth() + BitShiftUtil.half(this.getBlockWidth()));
|
||||
}
|
||||
public DhBlockPos2D getCorner() { return new DhBlockPos2D(this.getX().toBlockWidth(), this.getZ().toBlockWidth()); }
|
||||
public DhBlockPos2D getCornerBlockPos() { 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)
|
||||
public DhLodPos getCornerLodPos(byte newDetail)
|
||||
{
|
||||
LodUtil.assertTrue(newDetail <= this.detailLevel);
|
||||
return new DhLodPos(newDetail,
|
||||
@@ -72,7 +73,7 @@ public class DhLodPos implements Comparable<DhLodPos>
|
||||
*
|
||||
* @param child0to3 must be an int between 0 and 3
|
||||
*/
|
||||
public DhLodPos getChildByIndex(int child0to3) throws IllegalArgumentException, IllegalStateException
|
||||
public DhLodPos getChildPosByIndex(int child0to3) throws IllegalArgumentException, IllegalStateException
|
||||
{
|
||||
if (child0to3 < 0 || child0to3 > 3)
|
||||
throw new IllegalArgumentException("child0to3 must be between 0 and 3");
|
||||
|
||||
@@ -148,7 +148,7 @@ public class LodQuadTree implements AutoCloseable {
|
||||
*/
|
||||
public byte calculateExpectedDetailLevel(DhBlockPos2D playerPos, DhSectionPos sectionPos) {
|
||||
return DetailDistanceUtil.getDetailLevelFromDistance(
|
||||
playerPos.dist(sectionPos.getCenter().getCenter()));
|
||||
playerPos.dist(sectionPos.getCenter().getCenterBlockPos()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -72,8 +72,8 @@ public class RenderBufferHandler {
|
||||
|
||||
// Now that we have the axis directions, we can sort the render list
|
||||
Comparator<LoadedRenderBuffer> sortFarToNear = (a, b) -> {
|
||||
Pos2D aPos = a.pos.getCenter().getCenter().toPos2D();
|
||||
Pos2D bPos = b.pos.getCenter().getCenter().toPos2D();
|
||||
Pos2D aPos = a.pos.getCenter().getCenterBlockPos().toPos2D();
|
||||
Pos2D bPos = b.pos.getCenter().getCenterBlockPos().toPos2D();
|
||||
for (ELodDirection axisDirection : axisDirections) {
|
||||
if (axisDirection.getAxis().isVertical()) continue; // We works on the horizontal plane only for section sorting
|
||||
int abDiff;
|
||||
@@ -218,7 +218,7 @@ public class RenderBufferHandler {
|
||||
byte topDetail = (byte) (target.getNumbersOfSectionLevels() - 1);
|
||||
MovableGridRingList<LodRenderSection> referenceList = target.getRingList(topDetail);
|
||||
Pos2D center = referenceList.getCenter();
|
||||
//boolean moved = renderBufferNodes.getCenter().x != center.x || renderBufferNodes.getCenter().y != center.y;
|
||||
//boolean moved = renderBufferNodes.getCenterBlockPos().x != center.x || renderBufferNodes.getCenterBlockPos().y != center.y;
|
||||
renderBufferNodes.move(center.x, center.y, RenderBufferNode::close); // Note: may lock the list
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user