Minor refactoring

This commit is contained in:
James Seibel
2022-11-14 21:39:38 -06:00
parent 60af4429eb
commit d283922741
2 changed files with 15 additions and 8 deletions
@@ -232,19 +232,25 @@ public class DataFileHandler implements IDataSourceProvider {
/** This call is concurrent. I.e. it supports being called by multiple threads at the same time. */
@Override
public void write(DhSectionPos sectionPos, ChunkSizedData chunkData) {
public void write(DhSectionPos sectionPos, ChunkSizedData chunkData)
{
DhLodPos chunkPos = new DhLodPos((byte) (chunkData.dataDetail+4), chunkData.x, chunkData.z);
LodUtil.assertTrue(chunkPos.overlaps(sectionPos.getSectionBBoxPos()), "Chunk {} does not overlap section {}", chunkPos, sectionPos);
chunkPos = chunkPos.convertUpwardsTo((byte) minDetailLevel); // TODO: Handle if chunkData has higher detail than lowestDetail.
recursiveWrite(new DhSectionPos(chunkPos.detailLevel, chunkPos.x, chunkPos.z), chunkData);
chunkPos = chunkPos.convertUpwardsTo((byte) this.minDetailLevel); // TODO: Handle if chunkData has higher detail than lowestDetail.
this.recursiveWrite(new DhSectionPos(chunkPos.detailLevel, chunkPos.x, chunkPos.z), chunkData);
}
private void recursiveWrite(DhSectionPos sectionPos, ChunkSizedData chunkData) {
DataMetaFile metaFile = files.get(sectionPos);
if (metaFile != null) { // Fast path: if there is a file for this section, just write to it.
private void recursiveWrite(DhSectionPos sectionPos, ChunkSizedData chunkData)
{
DataMetaFile metaFile = this.files.get(sectionPos);
if (metaFile != null)
{
// Fast path: if there is a file for this section, just write to it.
metaFile.addToWriteQueue(chunkData);
}
if (sectionPos.sectionDetail <= topDetailLevel.get()) {
recursiveWrite(sectionPos.getParentPos(), chunkData);
if (sectionPos.sectionDetail <= this.topDetailLevel.get())
{
this.recursiveWrite(sectionPos.getParentPos(), chunkData);
}
}
@@ -52,6 +52,7 @@ public class DhLodPos implements Comparable<DhLodPos>
}
public DhBlockPos2D getCorner() { 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)
{
LodUtil.assertTrue(newDetail <= this.detailLevel);