rename DhSectionPos.sectionDetail -> sectionDetailLevel
This commit is contained in:
@@ -91,7 +91,7 @@ public class ColumnRenderSource implements ILodRenderSource, IColumnDatatype
|
||||
*/
|
||||
public ColumnRenderSource(DhSectionPos sectionPos, ColumnRenderLoader.ParsedColumnData parsedColumnData, IDhLevel level) throws IOException
|
||||
{
|
||||
if (sectionPos.sectionDetail - SECTION_SIZE_OFFSET != parsedColumnData.detailLevel)
|
||||
if (sectionPos.sectionDetailLevel - SECTION_SIZE_OFFSET != parsedColumnData.detailLevel)
|
||||
{
|
||||
throw new IOException("Invalid data: detail level does not match");
|
||||
}
|
||||
@@ -317,7 +317,7 @@ public class ColumnRenderSource implements ILodRenderSource, IColumnDatatype
|
||||
|
||||
public DhSectionPos getSectionPos() { return this.sectionPos; }
|
||||
|
||||
public byte getDataDetail() { return (byte) (this.sectionPos.sectionDetail - SECTION_SIZE_OFFSET); }
|
||||
public byte getDataDetail() { return (byte) (this.sectionPos.sectionDetailLevel - SECTION_SIZE_OFFSET); }
|
||||
|
||||
@Override
|
||||
public byte getDetailOffset() { return SECTION_SIZE_OFFSET; }
|
||||
|
||||
@@ -50,7 +50,7 @@ public class FullDataSource extends FullArrayView implements ILodDataSource
|
||||
@Override
|
||||
public DhSectionPos getSectionPos() { return this.sectionPos; }
|
||||
@Override
|
||||
public byte getDataDetail() { return (byte) (this.sectionPos.sectionDetail-SECTION_SIZE_OFFSET); }
|
||||
public byte getDataDetail() { return (byte) (this.sectionPos.sectionDetailLevel -SECTION_SIZE_OFFSET); }
|
||||
|
||||
@Override
|
||||
public byte getDataVersion() { return LATEST_VERSION; }
|
||||
@@ -234,22 +234,22 @@ public class FullDataSource extends FullArrayView implements ILodDataSource
|
||||
{
|
||||
if (!posToWrite.overlaps(posToTest))
|
||||
return false;
|
||||
if (posToTest.sectionDetail > posToWrite.sectionDetail)
|
||||
if (posToTest.sectionDetailLevel > posToWrite.sectionDetailLevel)
|
||||
return false;
|
||||
if (posToWrite.sectionDetail - posToTest.sectionDetail <= SECTION_SIZE_OFFSET)
|
||||
if (posToWrite.sectionDetailLevel - posToTest.sectionDetailLevel <= SECTION_SIZE_OFFSET)
|
||||
return true;
|
||||
byte sectPerData = (byte) (1 << (posToWrite.sectionDetail - posToTest.sectionDetail - SECTION_SIZE_OFFSET));
|
||||
byte sectPerData = (byte) (1 << (posToWrite.sectionDetailLevel - posToTest.sectionDetailLevel - SECTION_SIZE_OFFSET));
|
||||
return posToTest.sectionX % sectPerData == 0 && posToTest.sectionZ % sectPerData == 0;
|
||||
}
|
||||
|
||||
public void writeFromLower(FullDataSource subData)
|
||||
{
|
||||
LodUtil.assertTrue(this.sectionPos.overlaps(subData.sectionPos));
|
||||
LodUtil.assertTrue(subData.sectionPos.sectionDetail < this.sectionPos.sectionDetail);
|
||||
LodUtil.assertTrue(subData.sectionPos.sectionDetailLevel < this.sectionPos.sectionDetailLevel);
|
||||
if (!neededForPosition(this.sectionPos, subData.sectionPos))
|
||||
return;
|
||||
DhSectionPos lowerSectPos = subData.sectionPos;
|
||||
byte detailDiff = (byte) (this.sectionPos.sectionDetail - subData.sectionPos.sectionDetail);
|
||||
byte detailDiff = (byte) (this.sectionPos.sectionDetailLevel - subData.sectionPos.sectionDetailLevel);
|
||||
byte targetDataDetail = this.getDataDetail();
|
||||
DhLodPos minDataPos = this.sectionPos.getCorner(targetDataDetail);
|
||||
if (detailDiff <= SECTION_SIZE_OFFSET)
|
||||
|
||||
@@ -40,10 +40,10 @@ public class SparseDataSource implements IIncompleteDataSource
|
||||
|
||||
protected SparseDataSource(DhSectionPos sectionPos)
|
||||
{
|
||||
LodUtil.assertTrue(sectionPos.sectionDetail > SPARSE_UNIT_DETAIL);
|
||||
LodUtil.assertTrue(sectionPos.sectionDetail <= MAX_SECTION_DETAIL);
|
||||
LodUtil.assertTrue(sectionPos.sectionDetailLevel > SPARSE_UNIT_DETAIL);
|
||||
LodUtil.assertTrue(sectionPos.sectionDetailLevel <= MAX_SECTION_DETAIL);
|
||||
this.sectionPos = sectionPos;
|
||||
this.chunks = 1 << (byte) (sectionPos.sectionDetail - SPARSE_UNIT_DETAIL);
|
||||
this.chunks = 1 << (byte) (sectionPos.sectionDetailLevel - SPARSE_UNIT_DETAIL);
|
||||
this.dataPerChunk = SECTION_SIZE / this.chunks;
|
||||
this.sparseData = new FullArrayView[this.chunks * this.chunks];
|
||||
this.chunkPos = sectionPos.getCorner(SPARSE_UNIT_DETAIL);
|
||||
@@ -51,10 +51,10 @@ public class SparseDataSource implements IIncompleteDataSource
|
||||
}
|
||||
protected SparseDataSource(DhSectionPos sectionPos, FullDataPointIdMap mapping, FullArrayView[] data)
|
||||
{
|
||||
LodUtil.assertTrue(sectionPos.sectionDetail > SPARSE_UNIT_DETAIL);
|
||||
LodUtil.assertTrue(sectionPos.sectionDetail <= MAX_SECTION_DETAIL);
|
||||
LodUtil.assertTrue(sectionPos.sectionDetailLevel > SPARSE_UNIT_DETAIL);
|
||||
LodUtil.assertTrue(sectionPos.sectionDetailLevel <= MAX_SECTION_DETAIL);
|
||||
this.sectionPos = sectionPos;
|
||||
this.chunks = 1 << (byte) (sectionPos.sectionDetail - SPARSE_UNIT_DETAIL);
|
||||
this.chunks = 1 << (byte) (sectionPos.sectionDetailLevel - SPARSE_UNIT_DETAIL);
|
||||
this.dataPerChunk = SECTION_SIZE / this.chunks;
|
||||
LodUtil.assertTrue(this.chunks * this.chunks == data.length);
|
||||
this.sparseData = data;
|
||||
@@ -68,7 +68,7 @@ public class SparseDataSource implements IIncompleteDataSource
|
||||
@Override
|
||||
public DhSectionPos getSectionPos() { return this.sectionPos; }
|
||||
@Override
|
||||
public byte getDataDetail() { return (byte) (this.sectionPos.sectionDetail-SECTION_SIZE_OFFSET); }
|
||||
public byte getDataDetail() { return (byte) (this.sectionPos.sectionDetailLevel -SECTION_SIZE_OFFSET); }
|
||||
|
||||
@Override
|
||||
public byte getDataVersion() { return LATEST_VERSION; }
|
||||
@@ -126,7 +126,7 @@ public class SparseDataSource implements IIncompleteDataSource
|
||||
public void sampleFrom(ILodDataSource source)
|
||||
{
|
||||
DhSectionPos pos = source.getSectionPos();
|
||||
LodUtil.assertTrue(pos.sectionDetail < this.sectionPos.sectionDetail);
|
||||
LodUtil.assertTrue(pos.sectionDetailLevel < this.sectionPos.sectionDetailLevel);
|
||||
LodUtil.assertTrue(pos.overlaps(this.sectionPos));
|
||||
if (source.isEmpty())
|
||||
return;
|
||||
@@ -259,8 +259,8 @@ public class SparseDataSource implements IIncompleteDataSource
|
||||
|
||||
public static SparseDataSource loadData(DataMetaFile dataFile, InputStream dataStream, IDhLevel level) throws IOException
|
||||
{
|
||||
LodUtil.assertTrue(dataFile.pos.sectionDetail > SPARSE_UNIT_DETAIL);
|
||||
LodUtil.assertTrue(dataFile.pos.sectionDetail <= MAX_SECTION_DETAIL);
|
||||
LodUtil.assertTrue(dataFile.pos.sectionDetailLevel > SPARSE_UNIT_DETAIL);
|
||||
LodUtil.assertTrue(dataFile.pos.sectionDetailLevel <= MAX_SECTION_DETAIL);
|
||||
|
||||
DataInputStream dos = new DataInputStream(dataStream); // DO NOT CLOSE! It would close all related streams
|
||||
{
|
||||
@@ -282,7 +282,7 @@ public class SparseDataSource implements IIncompleteDataSource
|
||||
"Section size mismatch: {} != {} (Currently only 1 section size is supported)", size, SECTION_SIZE));
|
||||
}
|
||||
|
||||
int chunks = 1 << (byte) (dataFile.pos.sectionDetail - sparseDetail);
|
||||
int chunks = 1 << (byte) (dataFile.pos.sectionDetailLevel - sparseDetail);
|
||||
int dataPerChunk = size / chunks;
|
||||
|
||||
int minY = dos.readInt();
|
||||
|
||||
@@ -33,7 +33,7 @@ public class SpottyDataSource extends FullArrayView implements IIncompleteDataSo
|
||||
protected SpottyDataSource(DhSectionPos sectionPos)
|
||||
{
|
||||
super(new FullDataPointIdMap(), new long[SECTION_SIZE*SECTION_SIZE][0], SECTION_SIZE);
|
||||
LodUtil.assertTrue(sectionPos.sectionDetail > SparseDataSource.MAX_SECTION_DETAIL);
|
||||
LodUtil.assertTrue(sectionPos.sectionDetailLevel > SparseDataSource.MAX_SECTION_DETAIL);
|
||||
this.sectionPos = sectionPos;
|
||||
this.isColumnNotEmpty = new BitSet(SECTION_SIZE*SECTION_SIZE);
|
||||
}
|
||||
@@ -41,7 +41,7 @@ public class SpottyDataSource extends FullArrayView implements IIncompleteDataSo
|
||||
@Override
|
||||
public DhSectionPos getSectionPos() { return this.sectionPos; }
|
||||
@Override
|
||||
public byte getDataDetail() { return (byte) (this.sectionPos.sectionDetail-SECTION_SIZE_OFFSET); }
|
||||
public byte getDataDetail() { return (byte) (this.sectionPos.sectionDetailLevel -SECTION_SIZE_OFFSET); }
|
||||
|
||||
@Override
|
||||
public byte getDataVersion() { return LATEST_VERSION; }
|
||||
@@ -201,11 +201,11 @@ public class SpottyDataSource extends FullArrayView implements IIncompleteDataSo
|
||||
{
|
||||
if (!posToWrite.overlaps(posToTest))
|
||||
return false;
|
||||
if (posToTest.sectionDetail > posToWrite.sectionDetail)
|
||||
if (posToTest.sectionDetailLevel > posToWrite.sectionDetailLevel)
|
||||
return false;
|
||||
if (posToWrite.sectionDetail - posToTest.sectionDetail <= SECTION_SIZE_OFFSET)
|
||||
if (posToWrite.sectionDetailLevel - posToTest.sectionDetailLevel <= SECTION_SIZE_OFFSET)
|
||||
return true;
|
||||
byte sectPerData = (byte) (1 << (posToWrite.sectionDetail - posToTest.sectionDetail - SECTION_SIZE_OFFSET));
|
||||
byte sectPerData = (byte) (1 << (posToWrite.sectionDetailLevel - posToTest.sectionDetailLevel - SECTION_SIZE_OFFSET));
|
||||
return posToTest.sectionX % sectPerData == 0 && posToTest.sectionZ % sectPerData == 0;
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ public class SpottyDataSource extends FullArrayView implements IIncompleteDataSo
|
||||
public void sampleFrom(ILodDataSource source)
|
||||
{
|
||||
DhSectionPos pos = source.getSectionPos();
|
||||
LodUtil.assertTrue(pos.sectionDetail < this.sectionPos.sectionDetail);
|
||||
LodUtil.assertTrue(pos.sectionDetailLevel < this.sectionPos.sectionDetailLevel);
|
||||
LodUtil.assertTrue(pos.overlaps(this.sectionPos));
|
||||
if (source.isEmpty())
|
||||
return;
|
||||
@@ -237,7 +237,7 @@ public class SpottyDataSource extends FullArrayView implements IIncompleteDataSo
|
||||
DhSectionPos pos = sparseSource.getSectionPos();
|
||||
this.isEmpty = false;
|
||||
|
||||
if (this.getDataDetail() > this.sectionPos.sectionDetail)
|
||||
if (this.getDataDetail() > this.sectionPos.sectionDetailLevel)
|
||||
{
|
||||
DhLodPos basePos = this.sectionPos.getCorner(this.getDataDetail());
|
||||
DhLodPos dataPos = pos.getCorner(this.getDataDetail());
|
||||
@@ -286,7 +286,7 @@ public class SpottyDataSource extends FullArrayView implements IIncompleteDataSo
|
||||
this.isEmpty = false;
|
||||
this.downsampleFrom(fullSource);
|
||||
|
||||
if (this.getDataDetail() > this.sectionPos.sectionDetail)
|
||||
if (this.getDataDetail() > this.sectionPos.sectionDetailLevel)
|
||||
{
|
||||
DhLodPos basePos = this.sectionPos.getCorner(this.getDataDetail());
|
||||
DhLodPos dataPos = pos.getCorner(this.getDataDetail());
|
||||
|
||||
@@ -145,7 +145,7 @@ public class DataFileHandler implements IDataSourceProvider
|
||||
fileToUse = metaFiles.iterator().next();
|
||||
}
|
||||
// Add file to the list of files.
|
||||
this.topDetailLevel.updateAndGet(v -> Math.max(v, fileToUse.pos.sectionDetail));
|
||||
this.topDetailLevel.updateAndGet(v -> Math.max(v, fileToUse.pos.sectionDetailLevel));
|
||||
this.files.put(pos, fileToUse);
|
||||
}
|
||||
}
|
||||
@@ -176,7 +176,7 @@ public class DataFileHandler implements IDataSourceProvider
|
||||
|
||||
protected void selfSearch(DhSectionPos basePos, DhSectionPos pos, ArrayList<DataMetaFile> existFiles, ArrayList<DhSectionPos> missing)
|
||||
{
|
||||
byte detail = pos.sectionDetail;
|
||||
byte detail = pos.sectionDetailLevel;
|
||||
boolean allEmpty = true;
|
||||
outerLoop:
|
||||
while (--detail >= this.minDetailLevel)
|
||||
@@ -218,7 +218,7 @@ public class DataFileHandler implements IDataSourceProvider
|
||||
{
|
||||
existFiles.add(metaFile);
|
||||
}
|
||||
else if (childPos.sectionDetail == this.minDetailLevel)
|
||||
else if (childPos.sectionDetailLevel == this.minDetailLevel)
|
||||
{
|
||||
missing.add(childPos);
|
||||
}
|
||||
@@ -237,7 +237,7 @@ public class DataFileHandler implements IDataSourceProvider
|
||||
if (metaFile != null)
|
||||
{
|
||||
existFiles.add(metaFile);
|
||||
} else if (childPos.sectionDetail == this.minDetailLevel)
|
||||
} else if (childPos.sectionDetailLevel == this.minDetailLevel)
|
||||
{
|
||||
missing.add(childPos);
|
||||
}
|
||||
@@ -257,7 +257,7 @@ public class DataFileHandler implements IDataSourceProvider
|
||||
{
|
||||
existFiles.add(metaFile);
|
||||
}
|
||||
else if (childPos.sectionDetail == this.minDetailLevel)
|
||||
else if (childPos.sectionDetailLevel == this.minDetailLevel)
|
||||
{
|
||||
missing.add(childPos);
|
||||
}
|
||||
@@ -277,7 +277,7 @@ public class DataFileHandler implements IDataSourceProvider
|
||||
{
|
||||
existFiles.add(metaFile);
|
||||
}
|
||||
else if (childPos.sectionDetail == this.minDetailLevel)
|
||||
else if (childPos.sectionDetailLevel == this.minDetailLevel)
|
||||
{
|
||||
missing.add(childPos);
|
||||
}
|
||||
@@ -301,7 +301,7 @@ public class DataFileHandler implements IDataSourceProvider
|
||||
@Override
|
||||
public CompletableFuture<ILodDataSource> read(DhSectionPos pos)
|
||||
{
|
||||
this.topDetailLevel.updateAndGet(v -> Math.max(v, pos.sectionDetail));
|
||||
this.topDetailLevel.updateAndGet(v -> Math.max(v, pos.sectionDetailLevel));
|
||||
DataMetaFile metaFile = this.atomicGetOrMakeFile(pos);
|
||||
if (metaFile == null)
|
||||
{
|
||||
@@ -328,7 +328,7 @@ public class DataFileHandler implements IDataSourceProvider
|
||||
metaFile.addToWriteQueue(chunkData);
|
||||
}
|
||||
|
||||
if (sectionPos.sectionDetail <= this.topDetailLevel.get())
|
||||
if (sectionPos.sectionDetailLevel <= this.topDetailLevel.get())
|
||||
{
|
||||
this.recursiveWrite(sectionPos.getParentPos(), chunkData);
|
||||
}
|
||||
@@ -379,7 +379,7 @@ public class DataFileHandler implements IDataSourceProvider
|
||||
if (missing.size() == 1 && existFiles.isEmpty() && missing.get(0).equals(pos))
|
||||
{
|
||||
// None exist.
|
||||
IIncompleteDataSource incompleteDataSource = pos.sectionDetail <= SparseDataSource.MAX_SECTION_DETAIL ?
|
||||
IIncompleteDataSource incompleteDataSource = pos.sectionDetailLevel <= SparseDataSource.MAX_SECTION_DETAIL ?
|
||||
SparseDataSource.createEmpty(pos) : SpottyDataSource.createEmpty(pos);
|
||||
return CompletableFuture.completedFuture(incompleteDataSource);
|
||||
}
|
||||
@@ -394,7 +394,7 @@ public class DataFileHandler implements IDataSourceProvider
|
||||
}
|
||||
}
|
||||
final ArrayList<CompletableFuture<Void>> futures = new ArrayList<>(existFiles.size());
|
||||
final IIncompleteDataSource dataSource = pos.sectionDetail <= SparseDataSource.MAX_SECTION_DETAIL ?
|
||||
final IIncompleteDataSource dataSource = pos.sectionDetailLevel <= SparseDataSource.MAX_SECTION_DETAIL ?
|
||||
SparseDataSource.createEmpty(pos) :
|
||||
SpottyDataSource.createEmpty(pos);
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ public class GeneratedDataFileHandler extends DataFileHandler
|
||||
if (missing.size() == 1 && existingFiles.isEmpty() && missing.get(0).equals(pos))
|
||||
{
|
||||
// None exist.
|
||||
IIncompleteDataSource dataSource = pos.sectionDetail <= SparseDataSource.MAX_SECTION_DETAIL ?
|
||||
IIncompleteDataSource dataSource = pos.sectionDetailLevel <= SparseDataSource.MAX_SECTION_DETAIL ?
|
||||
SparseDataSource.createEmpty(pos) :
|
||||
SpottyDataSource.createEmpty(pos);
|
||||
|
||||
@@ -80,7 +80,7 @@ public class GeneratedDataFileHandler extends DataFileHandler
|
||||
}
|
||||
|
||||
final ArrayList<CompletableFuture<Void>> futures = new ArrayList<>(existingFiles.size());
|
||||
final IIncompleteDataSource dataSource = pos.sectionDetail <= SparseDataSource.MAX_SECTION_DETAIL ?
|
||||
final IIncompleteDataSource dataSource = pos.sectionDetailLevel <= SparseDataSource.MAX_SECTION_DETAIL ?
|
||||
SparseDataSource.createEmpty(pos) : SpottyDataSource.createEmpty(pos);
|
||||
LOGGER.debug("Creating {} from sampling {} files: {}", pos, existingFiles.size(), existingFiles);
|
||||
|
||||
|
||||
@@ -199,7 +199,7 @@ public abstract class AbstractMetaDataFile
|
||||
buff.putInt(Integer.MIN_VALUE); // Unused
|
||||
buff.putInt(this.pos.sectionZ);
|
||||
buff.putInt(checksum);
|
||||
buff.put(this.pos.sectionDetail);
|
||||
buff.put(this.pos.sectionDetailLevel);
|
||||
buff.put(this.metaData.dataLevel);
|
||||
buff.put(this.metaData.loaderVersion);
|
||||
buff.put(Byte.MIN_VALUE); // Unused
|
||||
|
||||
@@ -208,7 +208,7 @@ public class RenderFileHandler implements IRenderSourceProvider
|
||||
}
|
||||
|
||||
|
||||
if (sectPos.sectionDetail > ColumnRenderSource.SECTION_SIZE_OFFSET)
|
||||
if (sectPos.sectionDetailLevel > ColumnRenderSource.SECTION_SIZE_OFFSET)
|
||||
{
|
||||
this.writeRecursively(sectPos.getChildByIndex(0), chunkData);
|
||||
this.writeRecursively(sectPos.getChildByIndex(1), chunkData);
|
||||
@@ -261,7 +261,7 @@ public class RenderFileHandler implements IRenderSourceProvider
|
||||
public CompletableFuture<ILodRenderSource> onCreateRenderFile(RenderMetaDataFile file)
|
||||
{
|
||||
final int vertSize = Config.Client.Graphics.Quality.verticalQuality
|
||||
.get().calculateMaxVerticalData((byte) (file.pos.sectionDetail - ColumnRenderSource.SECTION_SIZE_OFFSET));
|
||||
.get().calculateMaxVerticalData((byte) (file.pos.sectionDetailLevel - ColumnRenderSource.SECTION_SIZE_OFFSET));
|
||||
|
||||
return CompletableFuture.completedFuture(
|
||||
new ColumnRenderSource(file.pos, vertSize, this.level.getMinY()));
|
||||
|
||||
@@ -30,18 +30,18 @@ public class DhSectionPos
|
||||
public final static byte SECTION_REGION_DETAIL_LEVEL = SECTION_MINIMUM_DETAIL_LEVEL + LodUtil.REGION_DETAIL_LEVEL;
|
||||
|
||||
|
||||
public final byte sectionDetail;
|
||||
public final byte sectionDetailLevel;
|
||||
|
||||
/** in sectionDetail level grid */
|
||||
/** in a sectionDetailLevel grid */
|
||||
public final int sectionX;
|
||||
/** in sectionDetail level grid */
|
||||
/** in a sectionDetailLevel grid */
|
||||
public final int sectionZ;
|
||||
|
||||
|
||||
|
||||
public DhSectionPos(byte sectionDetail, int sectionX, int sectionZ)
|
||||
public DhSectionPos(byte sectionDetailLevel, int sectionX, int sectionZ)
|
||||
{
|
||||
this.sectionDetail = sectionDetail;
|
||||
this.sectionDetailLevel = sectionDetailLevel;
|
||||
this.sectionX = sectionX;
|
||||
this.sectionZ = sectionZ;
|
||||
}
|
||||
@@ -51,7 +51,7 @@ public class DhSectionPos
|
||||
DhLodPos lodPos = new DhLodPos(LodUtil.BLOCK_DETAIL_LEVEL, blockPos.x, blockPos.z);
|
||||
lodPos = lodPos.convertToDetailLevel(SECTION_BLOCK_DETAIL_LEVEL);
|
||||
|
||||
this.sectionDetail = SECTION_BLOCK_DETAIL_LEVEL;
|
||||
this.sectionDetailLevel = SECTION_BLOCK_DETAIL_LEVEL;
|
||||
this.sectionX = lodPos.x;
|
||||
this.sectionZ = lodPos.z;
|
||||
}
|
||||
@@ -61,7 +61,7 @@ public class DhSectionPos
|
||||
DhLodPos lodPos = new DhLodPos(LodUtil.CHUNK_DETAIL_LEVEL, chunkPos.x, chunkPos.z);
|
||||
lodPos = lodPos.convertToDetailLevel(SECTION_CHUNK_DETAIL_LEVEL);
|
||||
|
||||
this.sectionDetail = SECTION_CHUNK_DETAIL_LEVEL;
|
||||
this.sectionDetailLevel = SECTION_CHUNK_DETAIL_LEVEL;
|
||||
this.sectionX = lodPos.x;
|
||||
this.sectionZ = lodPos.z;
|
||||
}
|
||||
@@ -72,35 +72,35 @@ public class DhSectionPos
|
||||
public DhLodPos getCenter() { return this.getCenter((byte) 0); }
|
||||
public DhLodPos getCenter(byte returnDetailLevel)
|
||||
{
|
||||
LodUtil.assertTrue(returnDetailLevel <= this.sectionDetail, "returnDetailLevel must be less than sectionDetail");
|
||||
LodUtil.assertTrue(returnDetailLevel <= this.sectionDetailLevel, "returnDetailLevel must be less than sectionDetail");
|
||||
|
||||
if (returnDetailLevel == this.sectionDetail)
|
||||
return new DhLodPos(this.sectionDetail, this.sectionX, this.sectionZ);
|
||||
if (returnDetailLevel == this.sectionDetailLevel)
|
||||
return new DhLodPos(this.sectionDetailLevel, this.sectionX, this.sectionZ);
|
||||
|
||||
byte offset = (byte) (this.sectionDetail - returnDetailLevel);
|
||||
byte offset = (byte) (this.sectionDetailLevel - returnDetailLevel);
|
||||
return new DhLodPos(returnDetailLevel,
|
||||
(this.sectionX * BitShiftUtil.powerOfTwo(offset)) + BitShiftUtil.powerOfTwo(offset - 1),
|
||||
(this.sectionZ * BitShiftUtil.powerOfTwo(offset)) + BitShiftUtil.powerOfTwo(offset - 1));
|
||||
}
|
||||
|
||||
/** @return the corner with the smallest X and Z coordinate */
|
||||
public DhLodPos getCorner() { return this.getCorner((byte) (this.sectionDetail - 1)); }
|
||||
public DhLodPos getCorner() { return this.getCorner((byte) (this.sectionDetailLevel - 1)); }
|
||||
/** @return the corner with the smallest X and Z coordinate */
|
||||
public DhLodPos getCorner(byte returnDetailLevel)
|
||||
{
|
||||
LodUtil.assertTrue(returnDetailLevel <= this.sectionDetail, "returnDetailLevel must be less than sectionDetail");
|
||||
byte offset = (byte) (this.sectionDetail - returnDetailLevel);
|
||||
LodUtil.assertTrue(returnDetailLevel <= this.sectionDetailLevel, "returnDetailLevel must be less than sectionDetail");
|
||||
byte offset = (byte) (this.sectionDetailLevel - returnDetailLevel);
|
||||
return new DhLodPos(returnDetailLevel,
|
||||
this.sectionX * BitShiftUtil.powerOfTwo(offset),
|
||||
this.sectionZ * BitShiftUtil.powerOfTwo(offset));
|
||||
}
|
||||
|
||||
public DhLodUnit getWidth() { return this.getWidth(this.sectionDetail); }
|
||||
public DhLodUnit getWidth() { return this.getWidth(this.sectionDetailLevel); }
|
||||
public DhLodUnit getWidth(byte returnDetailLevel)
|
||||
{
|
||||
LodUtil.assertTrue(returnDetailLevel <= this.sectionDetail, "returnDetailLevel must be less than sectionDetail");
|
||||
byte offset = (byte) (this.sectionDetail - returnDetailLevel);
|
||||
return new DhLodUnit(this.sectionDetail, BitShiftUtil.powerOfTwo(offset));
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
@@ -119,10 +119,10 @@ public class DhSectionPos
|
||||
{
|
||||
if (child0to3 < 0 || child0to3 > 3)
|
||||
throw new IllegalArgumentException("child0to3 must be between 0 and 3");
|
||||
if (this.sectionDetail <= 0)
|
||||
if (this.sectionDetailLevel <= 0)
|
||||
throw new IllegalStateException("section detail must be greater than 0");
|
||||
|
||||
return new DhSectionPos((byte) (this.sectionDetail - 1),
|
||||
return new DhSectionPos((byte) (this.sectionDetailLevel - 1),
|
||||
this.sectionX * 2 + (child0to3 & 1),
|
||||
this.sectionZ * 2 + BitShiftUtil.half(child0to3 & 2));
|
||||
}
|
||||
@@ -138,27 +138,27 @@ public class DhSectionPos
|
||||
}
|
||||
}
|
||||
|
||||
public DhSectionPos getParentPos() { return new DhSectionPos((byte) (this.sectionDetail + 1), BitShiftUtil.half(this.sectionX), BitShiftUtil.half(this.sectionZ)); }
|
||||
public DhSectionPos getParentPos() { return new DhSectionPos((byte) (this.sectionDetailLevel + 1), BitShiftUtil.half(this.sectionX), BitShiftUtil.half(this.sectionZ)); }
|
||||
|
||||
public DhSectionPos getAdjacentPos(ELodDirection dir)
|
||||
{
|
||||
return new DhSectionPos(this.sectionDetail,
|
||||
return new DhSectionPos(this.sectionDetailLevel,
|
||||
this.sectionX + dir.getNormal().x,
|
||||
this.sectionZ + dir.getNormal().z);
|
||||
}
|
||||
|
||||
public DhLodPos getSectionBBoxPos() { return new DhLodPos(this.sectionDetail, this.sectionX, this.sectionZ); }
|
||||
public DhLodPos getSectionBBoxPos() { return new DhLodPos(this.sectionDetailLevel, this.sectionX, this.sectionZ); }
|
||||
|
||||
/** NOTE: This does not consider yOffset! */
|
||||
public boolean overlaps(DhSectionPos other) { return this.getSectionBBoxPos().overlaps(other.getSectionBBoxPos()); }
|
||||
|
||||
/** Serialize() is different from toString() as it must NEVER be changed, and should be in a short format */
|
||||
public String serialize() { return "[" + this.sectionDetail + ',' + this.sectionX + ',' + this.sectionZ + ']'; }
|
||||
public String serialize() { return "[" + this.sectionDetailLevel + ',' + this.sectionX + ',' + this.sectionZ + ']'; }
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() { return "{" + this.sectionDetail + "*" + this.sectionX + "," + this.sectionZ + "}"; }
|
||||
public String toString() { return "{" + this.sectionDetailLevel + "*" + this.sectionX + "," + this.sectionZ + "}"; }
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
@@ -169,7 +169,7 @@ public class DhSectionPos
|
||||
return false;
|
||||
|
||||
DhSectionPos that = (DhSectionPos) obj;
|
||||
return this.sectionDetail == that.sectionDetail &&
|
||||
return this.sectionDetailLevel == that.sectionDetailLevel &&
|
||||
this.sectionX == that.sectionX &&
|
||||
this.sectionZ == that.sectionZ;
|
||||
}
|
||||
@@ -177,7 +177,7 @@ public class DhSectionPos
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return Integer.hashCode(this.sectionDetail) ^ // XOR
|
||||
return Integer.hashCode(this.sectionDetailLevel) ^ // XOR
|
||||
Integer.hashCode(this.sectionX) ^ // XOR
|
||||
Integer.hashCode(this.sectionZ);
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ public class LodQuadTree implements AutoCloseable {
|
||||
* @return the LodSection
|
||||
*/
|
||||
public LodRenderSection getSection(DhSectionPos pos) {
|
||||
return getSection(pos.sectionDetail, pos.sectionX, pos.sectionZ);
|
||||
return getSection(pos.sectionDetailLevel, pos.sectionX, pos.sectionZ);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -304,7 +304,7 @@ public class LodQuadTree implements AutoCloseable {
|
||||
section.childCount = 4;
|
||||
} else {
|
||||
final DhSectionPos sectPos = section != null ? section.pos : new DhSectionPos(f_sectLevel, pos.x, pos.y);
|
||||
LodUtil.assertTrue(sectPos.sectionDetail == f_sectLevel
|
||||
LodUtil.assertTrue(sectPos.sectionDetailLevel == f_sectLevel
|
||||
&& sectPos.sectionX == pos.x && sectPos.sectionZ == pos.y,
|
||||
"sectPos {} != {} @ {}", sectPos, pos, f_sectLevel);
|
||||
|
||||
@@ -349,7 +349,7 @@ public class LodQuadTree implements AutoCloseable {
|
||||
}
|
||||
// Final quick assert to insure section pos is correct.
|
||||
if (section != null) {
|
||||
LodUtil.assertTrue(section.pos.sectionDetail == f_sectLevel, "section.pos: " + section.pos + " vs level: " + f_sectLevel);
|
||||
LodUtil.assertTrue(section.pos.sectionDetailLevel == f_sectLevel, "section.pos: " + section.pos + " vs level: " + f_sectLevel);
|
||||
LodUtil.assertTrue(section.pos.sectionX == pos.x, "section.pos: " + section.pos + " vs pos: " + pos);
|
||||
LodUtil.assertTrue(section.pos.sectionZ == pos.y, "section.pos: " + section.pos + " vs pos: " + pos);
|
||||
}
|
||||
@@ -402,7 +402,7 @@ public class LodQuadTree implements AutoCloseable {
|
||||
|
||||
// Call load on new sections, and tick on existing ones, and dispose old sections
|
||||
if (section.childCount == -1) {
|
||||
if (section.pos.sectionDetail < numbersOfSectionLevels-1)
|
||||
if (section.pos.sectionDetailLevel < numbersOfSectionLevels-1)
|
||||
LodUtil.assertTrue(getParentSection(section.pos).childCount == 0);
|
||||
ringList.set(pos.x, pos.y, null);
|
||||
section.dispose();
|
||||
@@ -420,8 +420,8 @@ public class LodQuadTree implements AutoCloseable {
|
||||
|
||||
// Assertion steps
|
||||
LodUtil.assertTrue(section.childCount == 4 || section.childCount == 0);
|
||||
if (section.pos.sectionDetail == LAYER_BEGINNING_OFFSET) LodUtil.assertTrue(section.childCount == 0);
|
||||
if (section.pos.sectionDetail != LAYER_BEGINNING_OFFSET) {
|
||||
if (section.pos.sectionDetailLevel == LAYER_BEGINNING_OFFSET) LodUtil.assertTrue(section.childCount == 0);
|
||||
if (section.pos.sectionDetailLevel != LAYER_BEGINNING_OFFSET) {
|
||||
LodRenderSection child0 = getChildSection(section.pos, 0);
|
||||
LodRenderSection child1 = getChildSection(section.pos, 1);
|
||||
LodRenderSection child2 = getChildSection(section.pos, 2);
|
||||
|
||||
@@ -88,7 +88,7 @@ public class RenderBufferHandler {
|
||||
}
|
||||
return abDiff;
|
||||
}
|
||||
return a.pos.sectionDetail - b.pos.sectionDetail; // If all else fails, sort by detail
|
||||
return a.pos.sectionDetailLevel - b.pos.sectionDetailLevel; // If all else fails, sort by detail
|
||||
};
|
||||
Comparator<LoadedRenderBuffer> sortNearToFar = (a, b) -> -sortFarToNear.compare(a, b);
|
||||
// Build the sorted list
|
||||
|
||||
Reference in New Issue
Block a user