Rename BaseMetaData.dataLevel -> dataDetailLevel

This commit is contained in:
James Seibel
2023-10-06 22:23:40 -05:00
parent bbcf1d0071
commit 8f0c820c09
10 changed files with 31 additions and 35 deletions
@@ -107,9 +107,9 @@ public class CompleteFullDataSource extends FullDataArrayAccessor implements IFu
public FullDataSourceSummaryData readSourceSummaryInfo(FullDataMetaFile dataFile, DhDataInputStream inputStream, IDhLevel level) throws IOException
{
int dataDetail = inputStream.readInt();
if (dataDetail != dataFile.baseMetaData.dataLevel)
if (dataDetail != dataFile.baseMetaData.dataDetailLevel)
{
throw new IOException(LodUtil.formatLog("Data level mismatch: " + dataDetail + " != " + dataFile.baseMetaData.dataLevel));
throw new IOException(LodUtil.formatLog("Data level mismatch: " + dataDetail + " != " + dataFile.baseMetaData.dataDetailLevel));
}
int width = inputStream.readInt();
@@ -147,10 +147,10 @@ public class HighDetailIncompleteFullDataSource implements IIncompleteFullDataSo
LodUtil.assertTrue(dataFile.pos.getDetailLevel() > SPARSE_UNIT_DETAIL);
LodUtil.assertTrue(dataFile.pos.getDetailLevel() <= MAX_SECTION_DETAIL);
int dataDetail = inputStream.readShort();
if (dataDetail != dataFile.baseMetaData.dataLevel)
int dataDetailLevel = inputStream.readShort();
if (dataDetailLevel != dataFile.baseMetaData.dataDetailLevel)
{
throw new IOException(LodUtil.formatLog("Data level mismatch: {} != {}", dataDetail, dataFile.baseMetaData.dataLevel));
throw new IOException(LodUtil.formatLog("Data level mismatch: {} != {}", dataDetailLevel, dataFile.baseMetaData.dataDetailLevel));
}
// confirm that the detail level is correct
@@ -121,10 +121,10 @@ public class LowDetailIncompleteFullDataSource extends FullDataArrayAccessor imp
@Override
public FullDataSourceSummaryData readSourceSummaryInfo(FullDataMetaFile dataFile, DhDataInputStream inputStream, IDhLevel level) throws IOException
{
int dataDetail = inputStream.readInt();
if (dataDetail != dataFile.baseMetaData.dataLevel)
int dataDetailLevel = inputStream.readInt();
if (dataDetailLevel != dataFile.baseMetaData.dataDetailLevel)
{
throw new IOException(LodUtil.formatLog("Data level mismatch: " + dataDetail + " != " + dataFile.baseMetaData.dataLevel));
throw new IOException(LodUtil.formatLog("Data level mismatch: " + dataDetailLevel + " != " + dataFile.baseMetaData.dataDetailLevel));
}
int width = inputStream.readInt();
@@ -213,7 +213,7 @@ public class ColumnRenderSource
{
outputStream.flush();
outputStream.writeByte(this.getDataDetail());
outputStream.writeByte(this.getDataDetailLevel());
outputStream.writeInt(this.verticalDataCount);
if (this.isEmpty)
@@ -319,11 +319,11 @@ public class ColumnRenderSource
final int blockOffsetX = (chunkDataView.chunkPos.x * LodUtil.CHUNK_WIDTH) - sourceBlockX;
final int blockOffsetZ = (chunkDataView.chunkPos.z * LodUtil.CHUNK_WIDTH) - sourceBlockZ;
final int sourceDataPointBlockWidth = BitShiftUtil.powerOfTwo(this.getDataDetail());
final int sourceDataPointBlockWidth = BitShiftUtil.powerOfTwo(this.getDataDetailLevel());
boolean dataChanged = false;
if (chunkDataView.detailLevel == this.getDataDetail())
if (chunkDataView.detailLevel == this.getDataDetailLevel())
{
this.markNotEmpty();
// confirm the render source contains this chunk
@@ -360,17 +360,17 @@ public class ColumnRenderSource
}
this.fillDebugFlag(blockOffsetX, blockOffsetZ, LodUtil.CHUNK_WIDTH, LodUtil.CHUNK_WIDTH, ColumnRenderSource.DebugSourceFlag.DIRECT);
}
else if (chunkDataView.detailLevel < this.getDataDetail() && this.getDataDetail() <= chunkDataView.getSectionPos().getDetailLevel())
else if (chunkDataView.detailLevel < this.getDataDetailLevel() && this.getDataDetailLevel() <= chunkDataView.getSectionPos().getDetailLevel())
{
this.markNotEmpty();
// multiple chunk data points converting to 1 column data point
DhLodPos dataCornerPos = chunkDataView.getSectionPos().getMinCornerLodPos(chunkDataView.detailLevel);
DhLodPos sourceCornerPos = renderSourcePos.getMinCornerLodPos(this.getDataDetail());
DhLodPos sourceStartingChangePos = dataCornerPos.convertToDetailLevel(this.getDataDetail());
DhLodPos sourceCornerPos = renderSourcePos.getMinCornerLodPos(this.getDataDetailLevel());
DhLodPos sourceStartingChangePos = dataCornerPos.convertToDetailLevel(this.getDataDetailLevel());
int relStartX = Math.floorMod(sourceStartingChangePos.x, this.getWidthInDataPoints());
int relStartZ = Math.floorMod(sourceStartingChangePos.z, this.getWidthInDataPoints());
int dataToSourceScale = sourceCornerPos.getWidthAtDetail(chunkDataView.detailLevel);
int columnsInChunk = chunkDataView.getSectionPos().getWidthCountForLowerDetailedSection(this.getDataDetail());
int columnsInChunk = chunkDataView.getSectionPos().getWidthCountForLowerDetailedSection(this.getDataDetailLevel());
for (int xOffset = 0; xOffset < columnsInChunk; xOffset++)
{
@@ -390,12 +390,12 @@ public class ColumnRenderSource
}
this.fillDebugFlag(relStartX, relStartZ, columnsInChunk, columnsInChunk, ColumnRenderSource.DebugSourceFlag.DIRECT);
}
else if (chunkDataView.getSectionPos().getDetailLevel() < this.getDataDetail())
else if (chunkDataView.getSectionPos().getDetailLevel() < this.getDataDetailLevel())
{
// The entire chunk is being converted to a single column data point, possibly.
DhLodPos dataCornerPos = chunkDataView.getSectionPos().getMinCornerLodPos(chunkDataView.detailLevel);
DhLodPos sourceCornerPos = renderSourcePos.getMinCornerLodPos(this.getDataDetail());
DhLodPos sourceStartingChangePos = dataCornerPos.convertToDetailLevel(this.getDataDetail());
DhLodPos sourceCornerPos = renderSourcePos.getMinCornerLodPos(this.getDataDetailLevel());
DhLodPos sourceStartingChangePos = dataCornerPos.convertToDetailLevel(this.getDataDetailLevel());
int chunksPerColumn = sourceStartingChangePos.getWidthAtDetail(chunkDataView.getSectionPos().getDetailLevel());
if (chunkDataView.getSectionPos().getX() % chunksPerColumn != 0 || chunkDataView.getSectionPos().getZ() % chunksPerColumn != 0)
{
@@ -443,7 +443,7 @@ public class ColumnRenderSource
public DhSectionPos getSectionPos() { return this.sectionPos; }
public byte getDataDetail() { return (byte) (this.sectionPos.getDetailLevel() - SECTION_SIZE_OFFSET); }
public byte getDataDetailLevel() { return (byte) (this.sectionPos.getDetailLevel() - SECTION_SIZE_OFFSET); }
/** @return how many data points wide this {@link ColumnRenderSource} is. */
public int getWidthInDataPoints() { return BitShiftUtil.powerOfTwo(this.getDetailOffset()); }
@@ -184,7 +184,7 @@ public class ColumnRenderBufferBuilder
// return;
// }
byte detailLevel = renderSource.getDataDetail();
byte detailLevel = renderSource.getDataDetailLevel();
for (int x = 0; x < ColumnRenderSource.SECTION_SIZE; x++)
{
for (int z = 0; z < ColumnRenderSource.SECTION_SIZE; z++)
@@ -251,7 +251,7 @@ public class ColumnRenderBufferBuilder
continue;
}
adjDetailLevel = adjRenderSource.getDataDetail();
adjDetailLevel = adjRenderSource.getDataDetailLevel();
if (adjDetailLevel != detailLevel)
{
//TODO: Implement this
@@ -129,7 +129,7 @@ public class FullDataToRenderDataTransformer
columnSource.markNotEmpty();
if (dataDetail == columnSource.getDataDetail())
if (dataDetail == columnSource.getDataDetailLevel())
{
int baseX = pos.getMinCornerLodPos().getCornerBlockPos().x;
int baseZ = pos.getMinCornerLodPos().getCornerBlockPos().z;
@@ -179,7 +179,7 @@ public class FullDataToRenderDataTransformer
columnSource.markNotEmpty();
if (dataDetail == columnSource.getDataDetail())
if (dataDetail == columnSource.getDataDetailLevel())
{
int baseX = pos.getMinCornerLodPos().getCornerBlockPos().x;
int baseZ = pos.getMinCornerLodPos().getCornerBlockPos().z;
@@ -700,7 +700,7 @@ public class FullDataMetaFile extends AbstractMetaDataContainerFile implements I
// set the meta data properties //
this.baseMetaData.dataLevel = fullDataSource.getDataDetailLevel();
this.baseMetaData.dataDetailLevel = fullDataSource.getDataDetailLevel();
this.fullDataSourceLoader = AbstractFullDataSourceLoader.getLoader(fullDataSource.getClass(), fullDataSource.getBinaryDataFormatVersion());
LodUtil.assertTrue(this.fullDataSourceLoader != null, "No loader for " + fullDataSource.getClass() + " (v" + fullDataSource.getBinaryDataFormatVersion() + ")");
@@ -21,10 +21,7 @@ package com.seibel.distanthorizons.core.file.metaData;
import java.io.*;
import java.nio.ByteBuffer;
import java.nio.channels.ByteChannel;
import java.nio.channels.Channels;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.FileChannel;
import java.nio.file.*;
import java.util.zip.Adler32;
import java.util.zip.CheckedOutputStream;
@@ -32,7 +29,6 @@ import java.util.zip.CheckedOutputStream;
import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiWorldGenerationStep;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
import com.seibel.distanthorizons.core.pos.DhSectionPos;
import com.seibel.distanthorizons.core.util.FileUtil;
import com.seibel.distanthorizons.core.util.LodUtil;
import com.seibel.distanthorizons.core.util.objects.dataStreams.DhDataOutputStream;
import org.apache.logging.log4j.Logger;
@@ -174,7 +170,7 @@ public abstract class AbstractMetaDataContainerFile
buffer.putInt(this.pos.getZ());
buffer.putInt(0); //FIXME this.baseMetaData.checksum);
buffer.put(this.pos.getDetailLevel());
buffer.put(this.baseMetaData.dataLevel);
buffer.put(this.baseMetaData.dataDetailLevel);
buffer.put(this.baseMetaData.binaryDataFormatVersion);
buffer.put(this.baseMetaData.worldGenStep != null ? this.baseMetaData.worldGenStep.value : EDhApiWorldGenerationStep.EMPTY.value); // TODO this null check shouldn't be necessary
buffer.putLong(this.baseMetaData.dataTypeId);
@@ -27,7 +27,7 @@ import com.seibel.distanthorizons.core.dataObjects.render.ColumnRenderSource;
import java.util.concurrent.atomic.AtomicLong;
/**
* Contains and represents the meta information ({@link DhSectionPos}, {@link BaseMetaData#dataLevel}, etc.)
* Contains and represents the meta information ({@link DhSectionPos}, {@link BaseMetaData#dataDetailLevel}, etc.)
* stored at the beginning of files that use the {@link AbstractMetaDataContainerFile}. <Br>
* Which, as of the time of writing, includes: {@link IFullDataSource} and {@link ColumnRenderSource} files.
*/
@@ -36,7 +36,7 @@ public class BaseMetaData
public DhSectionPos pos;
public int checksum;
public AtomicLong dataVersion = new AtomicLong(Long.MAX_VALUE);
public byte dataLevel; // TODO what does this represent?
public byte dataDetailLevel;
public EDhApiWorldGenerationStep worldGenStep;
// Loader stuff //
@@ -46,12 +46,12 @@ public class BaseMetaData
public BaseMetaData(DhSectionPos pos, int checksum, byte dataLevel, EDhApiWorldGenerationStep worldGenStep, long dataTypeId, byte binaryDataFormatVersion, long dataVersion)
public BaseMetaData(DhSectionPos pos, int checksum, byte dataDetailLevel, EDhApiWorldGenerationStep worldGenStep, long dataTypeId, byte binaryDataFormatVersion, long dataVersion)
{
this.pos = pos;
this.checksum = checksum;
this.dataVersion = new AtomicLong(dataVersion);
this.dataLevel = dataLevel;
this.dataDetailLevel = dataDetailLevel;
this.worldGenStep = worldGenStep;
this.dataTypeId = dataTypeId;
@@ -195,7 +195,7 @@ public class RenderDataMetaFile extends AbstractMetaDataContainerFile implements
ColumnRenderSource newColumnRenderSource = new ColumnRenderSource(this.pos, verticalSize, this.clientLevel.getMinY());
this.baseMetaData = new BaseMetaData(
newColumnRenderSource.getSectionPos(), -1, newColumnRenderSource.getDataDetail(),
newColumnRenderSource.getSectionPos(), -1, newColumnRenderSource.getDataDetailLevel(),
newColumnRenderSource.worldGenStep, RENDER_SOURCE_TYPE_ID,
newColumnRenderSource.getRenderDataFormatVersion(), Long.MAX_VALUE);
@@ -352,7 +352,7 @@ public class RenderDataMetaFile extends AbstractMetaDataContainerFile implements
// update the meta data
this.baseMetaData.dataVersion.set(renderDataVersionRef.value);
this.baseMetaData.dataLevel = renderSource.getDataDetail();
this.baseMetaData.dataDetailLevel = renderSource.getDataDetailLevel();
this.baseMetaData.dataTypeId = RENDER_SOURCE_TYPE_ID;
this.baseMetaData.binaryDataFormatVersion = renderSource.getRenderDataFormatVersion();