Full Data source constant renaming
and remove an unneeded TODO comment
This commit is contained in:
+9
-9
@@ -42,10 +42,10 @@ public class FullDataDownSampler {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
futures = new ArrayList<>(CompleteFullDataSource.SECTION_SIZE * CompleteFullDataSource.SECTION_SIZE);
|
||||
int multiplier = sectionSizeNeeded / CompleteFullDataSource.SECTION_SIZE;
|
||||
for (int ox = 0; ox < CompleteFullDataSource.SECTION_SIZE; ox++) {
|
||||
for (int oz = 0; oz < CompleteFullDataSource.SECTION_SIZE; oz++) {
|
||||
futures = new ArrayList<>(CompleteFullDataSource.WIDTH * CompleteFullDataSource.WIDTH);
|
||||
int multiplier = sectionSizeNeeded / CompleteFullDataSource.WIDTH;
|
||||
for (int ox = 0; ox < CompleteFullDataSource.WIDTH; ox++) {
|
||||
for (int oz = 0; oz < CompleteFullDataSource.WIDTH; oz++) {
|
||||
CompletableFuture<IFullDataSource> future = provider.read(new DhSectionPos(
|
||||
CompleteFullDataSource.SECTION_SIZE_OFFSET, basePos.x + ox * multiplier, basePos.z + oz * multiplier));
|
||||
future = future.whenComplete((source, ex) -> {
|
||||
@@ -81,22 +81,22 @@ public class FullDataDownSampler {
|
||||
DhLodPos srcOffset = srcPos.getSectionBBoxPos().convertToDetailLevel(target.getDataDetailLevel());
|
||||
int offsetX = trgOffset.x - srcOffset.x;
|
||||
int offsetZ = trgOffset.z - srcOffset.z;
|
||||
LodUtil.assertTrue(offsetX >= 0 && offsetX < CompleteFullDataSource.SECTION_SIZE
|
||||
&& offsetZ >= 0 && offsetZ < CompleteFullDataSource.SECTION_SIZE);
|
||||
LodUtil.assertTrue(offsetX >= 0 && offsetX < CompleteFullDataSource.WIDTH
|
||||
&& offsetZ >= 0 && offsetZ < CompleteFullDataSource.WIDTH);
|
||||
target.markNotEmpty();
|
||||
source.get(0,0).deepCopyTo(target.get(offsetX, offsetZ));
|
||||
|
||||
} else if (detailDiff > 0) {
|
||||
// The source occupies multiple data-points in the target
|
||||
int srcDataPerTrgData = 1 << detailDiff;
|
||||
int overlappedTrgDataSize = CompleteFullDataSource.SECTION_SIZE / srcDataPerTrgData;
|
||||
int overlappedTrgDataSize = CompleteFullDataSource.WIDTH / srcDataPerTrgData;
|
||||
|
||||
DhLodPos trgOffset = trgPos.getCorner(target.getDataDetailLevel());
|
||||
DhLodPos srcOffset = srcPos.getSectionBBoxPos().getCornerLodPos(target.getDataDetailLevel());
|
||||
int offsetX = trgOffset.x - srcOffset.x;
|
||||
int offsetZ = trgOffset.z - srcOffset.z;
|
||||
LodUtil.assertTrue(offsetX >= 0 && offsetX < CompleteFullDataSource.SECTION_SIZE
|
||||
&& offsetZ >= 0 && offsetZ < CompleteFullDataSource.SECTION_SIZE);
|
||||
LodUtil.assertTrue(offsetX >= 0 && offsetX < CompleteFullDataSource.WIDTH
|
||||
&& offsetZ >= 0 && offsetZ < CompleteFullDataSource.WIDTH);
|
||||
target.markNotEmpty();
|
||||
|
||||
for (int ox = 0; ox < overlappedTrgDataSize; ox++) {
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ public class CompleteFullDataSourceLoader extends AbstractFullDataSourceLoader
|
||||
{
|
||||
public CompleteFullDataSourceLoader()
|
||||
{
|
||||
super(CompleteFullDataSource.class, CompleteFullDataSource.TYPE_ID, new byte[]{ CompleteFullDataSource.LATEST_VERSION});
|
||||
super(CompleteFullDataSource.class, CompleteFullDataSource.TYPE_ID, new byte[]{ CompleteFullDataSource.DATA_FORMAT_VERSION });
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
package com.seibel.lod.core.dataObjects.fullData.loader;
|
||||
|
||||
import com.seibel.lod.core.dataObjects.fullData.sources.CompleteFullDataSource;
|
||||
import com.seibel.lod.core.dataObjects.fullData.sources.IFullDataSource;
|
||||
import com.seibel.lod.core.dataObjects.fullData.sources.HighDetailIncompleteFullDataSource;
|
||||
import com.seibel.lod.core.file.fullDatafile.FullDataMetaFile;
|
||||
@@ -13,7 +12,7 @@ public class HighDetailIncompleteFullDataSourceLoader extends AbstractFullDataSo
|
||||
{
|
||||
public HighDetailIncompleteFullDataSourceLoader()
|
||||
{
|
||||
super(HighDetailIncompleteFullDataSource.class, HighDetailIncompleteFullDataSource.TYPE_ID, new byte[] { HighDetailIncompleteFullDataSource.LATEST_VERSION });
|
||||
super(HighDetailIncompleteFullDataSource.class, HighDetailIncompleteFullDataSource.TYPE_ID, new byte[] { HighDetailIncompleteFullDataSource.DATA_FORMAT_VERSION });
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
package com.seibel.lod.core.dataObjects.fullData.loader;
|
||||
|
||||
import com.seibel.lod.core.dataObjects.fullData.sources.CompleteFullDataSource;
|
||||
import com.seibel.lod.core.dataObjects.fullData.sources.IFullDataSource;
|
||||
import com.seibel.lod.core.dataObjects.fullData.sources.LowDetailIncompleteFullDataSource;
|
||||
import com.seibel.lod.core.file.fullDatafile.FullDataMetaFile;
|
||||
@@ -12,7 +11,7 @@ import java.io.IOException;
|
||||
public class LowDetailIncompleteFullDataSourceLoader extends AbstractFullDataSourceLoader
|
||||
{
|
||||
public LowDetailIncompleteFullDataSourceLoader() {
|
||||
super(LowDetailIncompleteFullDataSource.class, LowDetailIncompleteFullDataSource.TYPE_ID, new byte[]{ LowDetailIncompleteFullDataSource.LATEST_VERSION});
|
||||
super(LowDetailIncompleteFullDataSource.class, LowDetailIncompleteFullDataSource.TYPE_ID, new byte[]{ LowDetailIncompleteFullDataSource.DATA_FORMAT_VERSION });
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+18
-14
@@ -28,9 +28,13 @@ import java.io.*;
|
||||
public class CompleteFullDataSource extends FullDataArrayAccessor implements IFullDataSource, IStreamableFullDataSource<IStreamableFullDataSource.FullDataSourceSummaryData, long[][]>
|
||||
{
|
||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
|
||||
|
||||
public static final byte SECTION_SIZE_OFFSET = DhSectionPos.SECTION_MINIMUM_DETAIL_LEVEL;
|
||||
public static final int SECTION_SIZE = BitShiftUtil.powerOfTwo(SECTION_SIZE_OFFSET);
|
||||
public static final byte LATEST_VERSION = 0;
|
||||
/** measured in dataPoints */
|
||||
public static final int WIDTH = BitShiftUtil.powerOfTwo(SECTION_SIZE_OFFSET);
|
||||
|
||||
public static final byte DATA_FORMAT_VERSION = 0;
|
||||
/** written to the binary file to mark what {@link IFullDataSource} the binary file corresponds to */
|
||||
public static final long TYPE_ID = "CompleteFullDataSource".hashCode();
|
||||
|
||||
private final DhSectionPos sectionPos;
|
||||
@@ -46,14 +50,14 @@ public class CompleteFullDataSource extends FullDataArrayAccessor implements IFu
|
||||
public static CompleteFullDataSource createEmpty(DhSectionPos pos) { return new CompleteFullDataSource(pos); }
|
||||
private CompleteFullDataSource(DhSectionPos sectionPos)
|
||||
{
|
||||
super(new FullDataPointIdMap(), new long[SECTION_SIZE*SECTION_SIZE][0], SECTION_SIZE);
|
||||
super(new FullDataPointIdMap(), new long[WIDTH * WIDTH][0], WIDTH);
|
||||
this.sectionPos = sectionPos;
|
||||
}
|
||||
|
||||
public CompleteFullDataSource(DhSectionPos pos, FullDataPointIdMap mapping, long[][] data)
|
||||
{
|
||||
super(mapping, data, SECTION_SIZE);
|
||||
LodUtil.assertTrue(data.length == SECTION_SIZE * SECTION_SIZE);
|
||||
super(mapping, data, WIDTH);
|
||||
LodUtil.assertTrue(data.length == WIDTH * WIDTH);
|
||||
|
||||
this.sectionPos = pos;
|
||||
this.isEmpty = false;
|
||||
@@ -90,9 +94,9 @@ public class CompleteFullDataSource extends FullDataArrayAccessor implements IFu
|
||||
}
|
||||
|
||||
int width = dataInputStream.readInt();
|
||||
if (width != SECTION_SIZE)
|
||||
if (width != WIDTH)
|
||||
{
|
||||
throw new IOException(LodUtil.formatLog("Section width mismatch: "+width+" != "+SECTION_SIZE+" (Currently only 1 section width is supported)"));
|
||||
throw new IOException(LodUtil.formatLog("Section width mismatch: "+width+" != "+ WIDTH +" (Currently only 1 section width is supported)"));
|
||||
}
|
||||
|
||||
int minY = dataInputStream.readInt();
|
||||
@@ -274,7 +278,7 @@ public class CompleteFullDataSource extends FullDataArrayAccessor implements IFu
|
||||
{
|
||||
DhBlockPos2D chunkBlockPos = new DhBlockPos2D(chunkDataView.pos.x * LodUtil.CHUNK_WIDTH, chunkDataView.pos.z * LodUtil.CHUNK_WIDTH);
|
||||
DhBlockPos2D blockOffset = chunkBlockPos.subtract(this.sectionPos.getCorner().getCornerBlockPos());
|
||||
LodUtil.assertTrue(blockOffset.x >= 0 && blockOffset.x < SECTION_SIZE && blockOffset.z >= 0 && blockOffset.z < SECTION_SIZE);
|
||||
LodUtil.assertTrue(blockOffset.x >= 0 && blockOffset.x < WIDTH && blockOffset.z >= 0 && blockOffset.z < WIDTH);
|
||||
this.isEmpty = false;
|
||||
|
||||
chunkDataView.shadowCopyTo(this.subView(LodUtil.CHUNK_WIDTH, blockOffset.x, blockOffset.z));
|
||||
@@ -300,7 +304,7 @@ public class CompleteFullDataSource extends FullDataArrayAccessor implements IFu
|
||||
|
||||
int offsetX = dataOffset.x - baseOffset.x;
|
||||
int offsetZ = dataOffset.z - baseOffset.z;
|
||||
LodUtil.assertTrue(offsetX >= 0 && offsetX < SECTION_SIZE && offsetZ >= 0 && offsetZ < SECTION_SIZE);
|
||||
LodUtil.assertTrue(offsetX >= 0 && offsetX < WIDTH && offsetZ >= 0 && offsetZ < WIDTH);
|
||||
|
||||
this.isEmpty = false;
|
||||
for (int xOffset = 0; xOffset < fullSize; xOffset++)
|
||||
@@ -326,7 +330,7 @@ public class CompleteFullDataSource extends FullDataArrayAccessor implements IFu
|
||||
|
||||
int offsetX = dataOffset.x - baseOffset.x;
|
||||
int offsetZ = dataOffset.z - baseOffset.z;
|
||||
LodUtil.assertTrue(offsetX >= 0 && offsetX < SECTION_SIZE && offsetZ >= 0 && offsetZ < SECTION_SIZE);
|
||||
LodUtil.assertTrue(offsetX >= 0 && offsetX < WIDTH && offsetZ >= 0 && offsetZ < WIDTH);
|
||||
|
||||
this.isEmpty = false;
|
||||
chunkDataView.get(0, 0).deepCopyTo(this.get(offsetX, offsetZ));
|
||||
@@ -389,7 +393,7 @@ public class CompleteFullDataSource extends FullDataArrayAccessor implements IFu
|
||||
public byte getDataDetailLevel() { return (byte) (this.sectionPos.sectionDetailLevel -SECTION_SIZE_OFFSET); }
|
||||
|
||||
@Override
|
||||
public byte getDataVersion() { return LATEST_VERSION; }
|
||||
public byte getBinaryDataFormatVersion() { return DATA_FORMAT_VERSION; }
|
||||
|
||||
@Override
|
||||
public EDhApiWorldGenerationStep getWorldGenStep() { return this.worldGenStep; }
|
||||
@@ -420,11 +424,11 @@ public class CompleteFullDataSource extends FullDataArrayAccessor implements IFu
|
||||
if (detailDiff <= SECTION_SIZE_OFFSET)
|
||||
{
|
||||
int count = 1 << detailDiff;
|
||||
int dataPerCount = SECTION_SIZE / count;
|
||||
int dataPerCount = WIDTH / count;
|
||||
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);
|
||||
LodUtil.assertTrue(dataOffsetX >= 0 && dataOffsetX < WIDTH && dataOffsetZ >= 0 && dataOffsetZ < WIDTH);
|
||||
|
||||
for (int xOffset = 0; xOffset < count; xOffset++)
|
||||
{
|
||||
@@ -441,7 +445,7 @@ public class CompleteFullDataSource extends FullDataArrayAccessor implements IFu
|
||||
DhLodPos subDataPos = lowerSectPos.getSectionBBoxPos().convertToDetailLevel(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);
|
||||
LodUtil.assertTrue(dataOffsetX >= 0 && dataOffsetX < WIDTH && dataOffsetZ >= 0 && dataOffsetZ < WIDTH);
|
||||
subData.get(0, 0).deepCopyTo(get(dataOffsetX, dataOffsetZ));
|
||||
}
|
||||
}
|
||||
|
||||
+42
-37
@@ -23,8 +23,8 @@ import java.util.BitSet;
|
||||
* Handles incomplete full data with a detail level equal to or lower than
|
||||
* {@link HighDetailIncompleteFullDataSource#MAX_SECTION_DETAIL}. <br><br>
|
||||
*
|
||||
* Different then other {@link IIncompleteFullDataSource}'s, this object doesn't extend {@link FullDataArrayAccessor},
|
||||
* instead it contains several {@link FullDataArrayAccessor}s.
|
||||
* Compared to other {@link IIncompleteFullDataSource}'s, this object doesn't extend {@link FullDataArrayAccessor},
|
||||
* instead it contains several "sections" of data, represented by {@link FullDataArrayAccessor}s. <br><br>
|
||||
*
|
||||
* Formerly "SparseFullDataSource".
|
||||
*
|
||||
@@ -36,23 +36,28 @@ public class HighDetailIncompleteFullDataSource implements IIncompleteFullDataSo
|
||||
{
|
||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
|
||||
|
||||
// TODO James would like to rename, comment, and potentially remove some of these constants.
|
||||
// But he doesn't currently have the understanding to do so.
|
||||
public static final byte SPARSE_UNIT_DETAIL = LodUtil.CHUNK_DETAIL_LEVEL;
|
||||
public static final byte SPARSE_UNIT_SIZE = (byte) BitShiftUtil.powerOfTwo(SPARSE_UNIT_DETAIL);
|
||||
|
||||
public static final byte SECTION_SIZE_OFFSET = 6;
|
||||
public static final byte SECTION_SIZE_OFFSET = DhSectionPos.SECTION_MINIMUM_DETAIL_LEVEL;
|
||||
public static final int SECTION_SIZE = (byte) BitShiftUtil.powerOfTwo(SECTION_SIZE_OFFSET);
|
||||
/** aka max detail level */
|
||||
public static final byte MAX_SECTION_DETAIL = SECTION_SIZE_OFFSET + SPARSE_UNIT_DETAIL;
|
||||
public static final byte LATEST_VERSION = 0;
|
||||
|
||||
public static final byte DATA_FORMAT_VERSION = 0;
|
||||
/** written to the binary file to mark what {@link IFullDataSource} the binary file corresponds to */
|
||||
public static final long TYPE_ID = "HighDetailIncompleteFullDataSource".hashCode();
|
||||
|
||||
|
||||
protected final FullDataPointIdMap mapping;
|
||||
private final DhSectionPos sectionPos;
|
||||
private final FullDataArrayAccessor[] sparseData;
|
||||
private final DhLodPos chunkPos;
|
||||
|
||||
public final int chunks;
|
||||
public final int dataPerChunk;
|
||||
public final int sectionCount;
|
||||
public final int dataPointsPerSection;
|
||||
public boolean isEmpty = true;
|
||||
public EDhApiWorldGenerationStep worldGenStep = EDhApiWorldGenerationStep.EMPTY;
|
||||
|
||||
@@ -69,10 +74,10 @@ public class HighDetailIncompleteFullDataSource implements IIncompleteFullDataSo
|
||||
LodUtil.assertTrue(sectionPos.sectionDetailLevel <= MAX_SECTION_DETAIL);
|
||||
|
||||
this.sectionPos = sectionPos;
|
||||
this.chunks = 1 << (byte) (sectionPos.sectionDetailLevel - SPARSE_UNIT_DETAIL);
|
||||
this.dataPerChunk = SECTION_SIZE / this.chunks;
|
||||
this.sectionCount = BitShiftUtil.powerOfTwo(sectionPos.sectionDetailLevel - SPARSE_UNIT_DETAIL);
|
||||
this.dataPointsPerSection = SECTION_SIZE / this.sectionCount;
|
||||
|
||||
this.sparseData = new FullDataArrayAccessor[this.chunks * this.chunks];
|
||||
this.sparseData = new FullDataArrayAccessor[this.sectionCount * this.sectionCount];
|
||||
this.chunkPos = sectionPos.getCorner(SPARSE_UNIT_DETAIL);
|
||||
this.mapping = new FullDataPointIdMap();
|
||||
}
|
||||
@@ -83,10 +88,10 @@ public class HighDetailIncompleteFullDataSource implements IIncompleteFullDataSo
|
||||
LodUtil.assertTrue(sectionPos.sectionDetailLevel <= MAX_SECTION_DETAIL);
|
||||
|
||||
this.sectionPos = sectionPos;
|
||||
this.chunks = 1 << (byte) (sectionPos.sectionDetailLevel - SPARSE_UNIT_DETAIL);
|
||||
this.dataPerChunk = SECTION_SIZE / this.chunks;
|
||||
this.sectionCount = 1 << (byte) (sectionPos.sectionDetailLevel - SPARSE_UNIT_DETAIL);
|
||||
this.dataPointsPerSection = SECTION_SIZE / this.sectionCount;
|
||||
|
||||
LodUtil.assertTrue(this.chunks * this.chunks == data.length);
|
||||
LodUtil.assertTrue(this.sectionCount * this.sectionCount == data.length);
|
||||
this.sparseData = data;
|
||||
this.chunkPos = sectionPos.getCorner(SPARSE_UNIT_DETAIL);
|
||||
this.isEmpty = false;
|
||||
@@ -393,7 +398,7 @@ public class HighDetailIncompleteFullDataSource implements IIncompleteFullDataSo
|
||||
public byte getDataDetailLevel() { return (byte) (this.sectionPos.sectionDetailLevel - SECTION_SIZE_OFFSET); }
|
||||
|
||||
@Override
|
||||
public byte getDataVersion() { return LATEST_VERSION; }
|
||||
public byte getBinaryDataFormatVersion() { return DATA_FORMAT_VERSION; }
|
||||
|
||||
@Override
|
||||
public EDhApiWorldGenerationStep getWorldGenStep() { return this.worldGenStep; }
|
||||
@@ -405,8 +410,8 @@ public class HighDetailIncompleteFullDataSource implements IIncompleteFullDataSo
|
||||
{
|
||||
int offsetX = chunkX - this.chunkPos.x;
|
||||
int offsetZ = chunkZ - this.chunkPos.z;
|
||||
LodUtil.assertTrue(offsetX >= 0 && offsetZ >= 0 && offsetX < this.chunks && offsetZ < this.chunks);
|
||||
return offsetX * this.chunks + offsetZ;
|
||||
LodUtil.assertTrue(offsetX >= 0 && offsetZ >= 0 && offsetX < this.sectionCount && offsetZ < this.sectionCount);
|
||||
return offsetX * this.sectionCount + offsetZ;
|
||||
}
|
||||
|
||||
|
||||
@@ -414,15 +419,15 @@ public class HighDetailIncompleteFullDataSource implements IIncompleteFullDataSo
|
||||
public void update(ChunkSizedFullDataAccessor chunkDataView)
|
||||
{
|
||||
int arrayOffset = this.calculateOffset(chunkDataView.pos.x, chunkDataView.pos.z);
|
||||
FullDataArrayAccessor newArray = new FullDataArrayAccessor(this.mapping, new long[this.dataPerChunk * this.dataPerChunk][], this.dataPerChunk);
|
||||
FullDataArrayAccessor newArray = new FullDataArrayAccessor(this.mapping, new long[this.dataPointsPerSection * this.dataPointsPerSection][], this.dataPointsPerSection);
|
||||
if (this.getDataDetailLevel() == chunkDataView.detailLevel)
|
||||
{
|
||||
chunkDataView.shadowCopyTo(newArray);
|
||||
}
|
||||
else
|
||||
{
|
||||
int count = this.dataPerChunk;
|
||||
int dataPerCount = SPARSE_UNIT_SIZE / this.dataPerChunk;
|
||||
int count = this.dataPointsPerSection;
|
||||
int dataPerCount = SPARSE_UNIT_SIZE / this.dataPointsPerSection;
|
||||
|
||||
for (int xOffset = 0; xOffset < count; xOffset++)
|
||||
{
|
||||
@@ -478,18 +483,18 @@ public class HighDetailIncompleteFullDataSource implements IIncompleteFullDataSo
|
||||
|
||||
int offsetX = dataPos.x-basePos.x;
|
||||
int offsetZ = dataPos.z-basePos.z;
|
||||
LodUtil.assertTrue(offsetX >= 0 && offsetX < this.chunks && offsetZ >= 0 && offsetZ < this.chunks);
|
||||
LodUtil.assertTrue(offsetX >= 0 && offsetX < this.sectionCount && offsetZ >= 0 && offsetZ < this.sectionCount);
|
||||
|
||||
for (int xOffset = 0; xOffset < sparseDataSource.chunks; xOffset++)
|
||||
for (int xOffset = 0; xOffset < sparseDataSource.sectionCount; xOffset++)
|
||||
{
|
||||
for (int zOffset = 0; zOffset < sparseDataSource.chunks; zOffset++)
|
||||
for (int zOffset = 0; zOffset < sparseDataSource.sectionCount; zOffset++)
|
||||
{
|
||||
FullDataArrayAccessor sourceChunk = sparseDataSource.sparseData[xOffset * sparseDataSource.chunks + zOffset];
|
||||
FullDataArrayAccessor sourceChunk = sparseDataSource.sparseData[xOffset * sparseDataSource.sectionCount + zOffset];
|
||||
if (sourceChunk != null)
|
||||
{
|
||||
FullDataArrayAccessor newFullDataAccessor = new FullDataArrayAccessor(this.mapping, new long[this.dataPerChunk * this.dataPerChunk][], this.dataPerChunk);
|
||||
FullDataArrayAccessor newFullDataAccessor = new FullDataArrayAccessor(this.mapping, new long[this.dataPointsPerSection * this.dataPointsPerSection][], this.dataPointsPerSection);
|
||||
newFullDataAccessor.downsampleFrom(sourceChunk);
|
||||
this.sparseData[(xOffset + offsetX) * this.chunks + (zOffset + offsetZ)] = newFullDataAccessor;
|
||||
this.sparseData[(xOffset + offsetX) * this.sectionCount + (zOffset + offsetZ)] = newFullDataAccessor;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -504,20 +509,20 @@ public class HighDetailIncompleteFullDataSource implements IIncompleteFullDataSo
|
||||
|
||||
int coveredChunks = pos.getWidth(SPARSE_UNIT_DETAIL).numberOfLodSectionsWide;
|
||||
int sourceDataPerChunk = SPARSE_UNIT_SIZE >>> completeDataSource.getDataDetailLevel();
|
||||
LodUtil.assertTrue((coveredChunks * sourceDataPerChunk) == CompleteFullDataSource.SECTION_SIZE);
|
||||
LodUtil.assertTrue((coveredChunks * sourceDataPerChunk) == CompleteFullDataSource.WIDTH);
|
||||
|
||||
int xDataOffset = dataPos.x - basePos.x;
|
||||
int zDataOffset = dataPos.z - basePos.z;
|
||||
LodUtil.assertTrue(xDataOffset >= 0 && xDataOffset < this.chunks && zDataOffset >= 0 && zDataOffset < this.chunks);
|
||||
LodUtil.assertTrue(xDataOffset >= 0 && xDataOffset < this.sectionCount && zDataOffset >= 0 && zDataOffset < this.sectionCount);
|
||||
|
||||
for (int xOffset = 0; xOffset < coveredChunks; xOffset++)
|
||||
{
|
||||
for (int zOffset = 0; zOffset < coveredChunks; zOffset++)
|
||||
{
|
||||
FullDataArrayAccessor sourceChunk = completeDataSource.subView(sourceDataPerChunk, xOffset * sourceDataPerChunk, zOffset * sourceDataPerChunk);
|
||||
FullDataArrayAccessor newFullDataAccessor = new FullDataArrayAccessor(this.mapping, new long[this.dataPerChunk * this.dataPerChunk][], this.dataPerChunk);
|
||||
FullDataArrayAccessor newFullDataAccessor = new FullDataArrayAccessor(this.mapping, new long[this.dataPointsPerSection * this.dataPointsPerSection][], this.dataPointsPerSection);
|
||||
newFullDataAccessor.downsampleFrom(sourceChunk);
|
||||
this.sparseData[(xOffset + xDataOffset) * this.chunks + (zOffset + zDataOffset)] = newFullDataAccessor;
|
||||
this.sparseData[(xOffset + xDataOffset) * this.sectionCount + (zOffset + zDataOffset)] = newFullDataAccessor;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -531,17 +536,17 @@ public class HighDetailIncompleteFullDataSource implements IIncompleteFullDataSo
|
||||
{
|
||||
LodUtil.assertTrue(dataSource.getSectionPos().equals(this.sectionPos));
|
||||
LodUtil.assertTrue(dataSource.getDataDetailLevel() == this.getDataDetailLevel());
|
||||
for (int x = 0; x < this.chunks; x++)
|
||||
for (int x = 0; x < this.sectionCount; x++)
|
||||
{
|
||||
for (int z = 0; z < this.chunks; z++)
|
||||
for (int z = 0; z < this.sectionCount; z++)
|
||||
{
|
||||
FullDataArrayAccessor array = this.sparseData[x * this.chunks + z];
|
||||
FullDataArrayAccessor array = this.sparseData[x * this.sectionCount + z];
|
||||
if (array == null)
|
||||
continue;
|
||||
|
||||
// Otherwise, apply data to dataSource
|
||||
dataSource.markNotEmpty();
|
||||
FullDataArrayAccessor view = dataSource.subView(this.dataPerChunk, x * this.dataPerChunk, z * this.dataPerChunk);
|
||||
FullDataArrayAccessor view = dataSource.subView(this.dataPointsPerSection, x * this.dataPointsPerSection, z * this.dataPointsPerSection);
|
||||
array.shadowCopyTo(view);
|
||||
}
|
||||
}
|
||||
@@ -570,16 +575,16 @@ public class HighDetailIncompleteFullDataSource implements IIncompleteFullDataSo
|
||||
|
||||
public SingleColumnFullDataAccessor tryGet(int relativeX, int relativeZ)
|
||||
{
|
||||
LodUtil.assertTrue(relativeX >=0 && relativeX <SECTION_SIZE && relativeZ >=0 && relativeZ <SECTION_SIZE);
|
||||
int chunkX = relativeX / this.dataPerChunk;
|
||||
int chunkZ = relativeZ / this.dataPerChunk;
|
||||
FullDataArrayAccessor chunk = this.sparseData[chunkX * this.chunks + chunkZ];
|
||||
LodUtil.assertTrue(relativeX >=0 && relativeX < SECTION_SIZE && relativeZ >=0 && relativeZ < SECTION_SIZE);
|
||||
int chunkX = relativeX / this.dataPointsPerSection;
|
||||
int chunkZ = relativeZ / this.dataPointsPerSection;
|
||||
FullDataArrayAccessor chunk = this.sparseData[chunkX * this.sectionCount + chunkZ];
|
||||
if (chunk == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return chunk.get(relativeX % this.dataPerChunk, relativeZ % this.dataPerChunk);
|
||||
return chunk.get(relativeX % this.dataPointsPerSection, relativeZ % this.dataPointsPerSection);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-2
@@ -9,7 +9,6 @@ import com.seibel.lod.core.dataObjects.render.ColumnRenderSource;
|
||||
import com.seibel.lod.core.file.fullDatafile.FullDataMetaFile;
|
||||
import com.seibel.lod.core.level.IDhLevel;
|
||||
import com.seibel.lod.core.pos.DhSectionPos;
|
||||
import com.seibel.lod.core.dataObjects.fullData.accessor.FullDataArrayAccessor;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
@@ -37,7 +36,7 @@ public interface IFullDataSource
|
||||
DhSectionPos getSectionPos();
|
||||
|
||||
byte getDataDetailLevel();
|
||||
byte getDataVersion();
|
||||
byte getBinaryDataFormatVersion();
|
||||
EDhApiWorldGenerationStep getWorldGenStep();
|
||||
|
||||
void update(ChunkSizedFullDataAccessor data);
|
||||
|
||||
+2
-2
@@ -12,8 +12,8 @@ public interface IIncompleteFullDataSource extends IFullDataSource
|
||||
/**
|
||||
* Attempts to convert this {@link IIncompleteFullDataSource} into a {@link CompleteFullDataSource}.
|
||||
*
|
||||
* @return this if the promotion failed, a new {@link CompleteFullDataSource} if successful.
|
||||
* @return a new {@link CompleteFullDataSource} if successful, this if the promotion failed, .
|
||||
*/
|
||||
IFullDataSource tryPromotingToCompleteDataSource(); // TODO make this return CompleteFullDataSource instead, if it fails just return null
|
||||
IFullDataSource tryPromotingToCompleteDataSource();
|
||||
|
||||
}
|
||||
|
||||
+29
-23
@@ -10,6 +10,7 @@ import com.seibel.lod.core.level.IDhLevel;
|
||||
import com.seibel.lod.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.lod.core.pos.DhLodPos;
|
||||
import com.seibel.lod.core.pos.DhSectionPos;
|
||||
import com.seibel.lod.core.util.BitShiftUtil;
|
||||
import com.seibel.lod.core.util.FullDataPointUtil;
|
||||
import com.seibel.lod.core.util.LodUtil;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -31,11 +32,16 @@ import java.util.BitSet;
|
||||
public class LowDetailIncompleteFullDataSource extends FullDataArrayAccessor implements IIncompleteFullDataSource, IStreamableFullDataSource<IStreamableFullDataSource.FullDataSourceSummaryData, long[][]>
|
||||
{
|
||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
|
||||
public static final byte SECTION_SIZE_OFFSET = 6;
|
||||
public static final int SECTION_SIZE = 1 << SECTION_SIZE_OFFSET; // TODO this is width not size
|
||||
public static final byte LATEST_VERSION = 0; // TODO rename to data format version
|
||||
|
||||
public static final byte SECTION_SIZE_OFFSET = DhSectionPos.SECTION_MINIMUM_DETAIL_LEVEL;
|
||||
/** measured in dataPoints */
|
||||
public static final int WIDTH = BitShiftUtil.powerOfTwo(SECTION_SIZE_OFFSET);
|
||||
|
||||
public static final byte DATA_FORMAT_VERSION = 0; // TODO rename to data format version
|
||||
/** written to the binary file to mark what {@link IFullDataSource} the binary file corresponds to */
|
||||
public static final long TYPE_ID = "LowDetailIncompleteFullDataSource".hashCode();
|
||||
|
||||
|
||||
private final DhSectionPos sectionPos;
|
||||
private final BitSet isColumnNotEmpty;
|
||||
|
||||
@@ -51,18 +57,18 @@ public class LowDetailIncompleteFullDataSource extends FullDataArrayAccessor imp
|
||||
public static LowDetailIncompleteFullDataSource createEmpty(DhSectionPos pos) { return new LowDetailIncompleteFullDataSource(pos); }
|
||||
private LowDetailIncompleteFullDataSource(DhSectionPos sectionPos)
|
||||
{
|
||||
super(new FullDataPointIdMap(), new long[SECTION_SIZE*SECTION_SIZE][0], SECTION_SIZE);
|
||||
super(new FullDataPointIdMap(), new long[WIDTH * WIDTH][0], WIDTH);
|
||||
LodUtil.assertTrue(sectionPos.sectionDetailLevel > HighDetailIncompleteFullDataSource.MAX_SECTION_DETAIL);
|
||||
|
||||
this.sectionPos = sectionPos;
|
||||
this.isColumnNotEmpty = new BitSet(SECTION_SIZE*SECTION_SIZE);
|
||||
this.isColumnNotEmpty = new BitSet(WIDTH * WIDTH);
|
||||
this.worldGenStep = EDhApiWorldGenerationStep.EMPTY;
|
||||
}
|
||||
|
||||
private LowDetailIncompleteFullDataSource(DhSectionPos pos, FullDataPointIdMap mapping, EDhApiWorldGenerationStep worldGenStep, BitSet isColumnNotEmpty, long[][] data)
|
||||
{
|
||||
super(mapping, data, SECTION_SIZE);
|
||||
LodUtil.assertTrue(data.length == SECTION_SIZE*SECTION_SIZE);
|
||||
super(mapping, data, WIDTH);
|
||||
LodUtil.assertTrue(data.length == WIDTH * WIDTH);
|
||||
|
||||
this.sectionPos = pos;
|
||||
this.isColumnNotEmpty = isColumnNotEmpty;
|
||||
@@ -102,9 +108,9 @@ public class LowDetailIncompleteFullDataSource extends FullDataArrayAccessor imp
|
||||
}
|
||||
|
||||
int width = dataInputStream.readInt();
|
||||
if (width != SECTION_SIZE)
|
||||
if (width != WIDTH)
|
||||
{
|
||||
throw new IOException(LodUtil.formatLog("Section size mismatch: "+width+" != "+SECTION_SIZE+" (Currently only 1 section size is supported)"));
|
||||
throw new IOException(LodUtil.formatLog("Section size mismatch: "+width+" != "+ WIDTH +" (Currently only 1 section size is supported)"));
|
||||
}
|
||||
|
||||
int minY = dataInputStream.readInt();
|
||||
@@ -185,10 +191,10 @@ public class LowDetailIncompleteFullDataSource extends FullDataArrayAccessor imp
|
||||
|
||||
// data column presence
|
||||
int length = dataInputStream.readInt();
|
||||
if (length < 0 || length > (SECTION_SIZE*SECTION_SIZE/8+64)*2) // TODO replace magic numbers or comment what they mean
|
||||
if (length < 0 || length > (WIDTH * WIDTH /8+64)*2) // TODO replace magic numbers or comment what they mean
|
||||
{
|
||||
throw new IOException(LodUtil.formatLog("Spotty Flag BitSet size outside reasonable range: {} (expects {} to {})",
|
||||
length, 1, SECTION_SIZE * SECTION_SIZE / 8 + 63));
|
||||
length, 1, WIDTH * WIDTH / 8 + 63));
|
||||
}
|
||||
|
||||
byte[] bytes = new byte[length];
|
||||
@@ -198,7 +204,7 @@ public class LowDetailIncompleteFullDataSource extends FullDataArrayAccessor imp
|
||||
|
||||
|
||||
// Data array content
|
||||
long[][] dataPointArray = new long[SECTION_SIZE*SECTION_SIZE][];
|
||||
long[][] dataPointArray = new long[WIDTH * WIDTH][];
|
||||
dataPresentFlag = dataInputStream.readInt();
|
||||
if (dataPresentFlag != IFullDataSource.DATA_GUARD_BYTE)
|
||||
{
|
||||
@@ -279,7 +285,7 @@ public class LowDetailIncompleteFullDataSource extends FullDataArrayAccessor imp
|
||||
DhLodPos dataOffset = data.getLodPos().convertToDetailLevel(this.getDataDetailLevel());
|
||||
int offsetX = dataOffset.x - baseOffset.x;
|
||||
int offsetZ = dataOffset.z - baseOffset.z;
|
||||
LodUtil.assertTrue(offsetX >= 0 && offsetX < SECTION_SIZE && offsetZ >= 0 && offsetZ < SECTION_SIZE);
|
||||
LodUtil.assertTrue(offsetX >= 0 && offsetX < WIDTH && offsetZ >= 0 && offsetZ < WIDTH);
|
||||
this.isEmpty = false;
|
||||
data.get(0,0).deepCopyTo(this.get(offsetX, offsetZ));
|
||||
}
|
||||
@@ -331,7 +337,7 @@ public class LowDetailIncompleteFullDataSource extends FullDataArrayAccessor imp
|
||||
|
||||
int offsetX = dataLodPos.x - thisLodPos.x;
|
||||
int offsetZ = dataLodPos.z - thisLodPos.z;
|
||||
LodUtil.assertTrue(offsetX >= 0 && offsetX < SECTION_SIZE && offsetZ >= 0 && offsetZ < SECTION_SIZE);
|
||||
LodUtil.assertTrue(offsetX >= 0 && offsetX < WIDTH && offsetZ >= 0 && offsetZ < WIDTH);
|
||||
|
||||
int chunksPerData = 1 << (this.getDataDetailLevel() - HighDetailIncompleteFullDataSource.SPARSE_UNIT_DETAIL);
|
||||
int dataSpan = this.sectionPos.getWidth(this.getDataDetailLevel()).numberOfLodSectionsWide;
|
||||
@@ -341,13 +347,13 @@ public class LowDetailIncompleteFullDataSource extends FullDataArrayAccessor imp
|
||||
for (int zOffset = 0; zOffset < dataSpan; zOffset++)
|
||||
{
|
||||
SingleColumnFullDataAccessor column = sparseSource.tryGet(
|
||||
xOffset * chunksPerData * sparseSource.dataPerChunk,
|
||||
zOffset * chunksPerData * sparseSource.dataPerChunk);
|
||||
xOffset * chunksPerData * sparseSource.dataPointsPerSection,
|
||||
zOffset * chunksPerData * sparseSource.dataPointsPerSection);
|
||||
|
||||
if (column != null)
|
||||
{
|
||||
column.deepCopyTo(this.get(offsetX + xOffset, offsetZ + zOffset));
|
||||
this.isColumnNotEmpty.set((offsetX + xOffset) * SECTION_SIZE + offsetZ + zOffset, true);
|
||||
this.isColumnNotEmpty.set((offsetX + xOffset) * WIDTH + offsetZ + zOffset, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -370,7 +376,7 @@ public class LowDetailIncompleteFullDataSource extends FullDataArrayAccessor imp
|
||||
if (column != null)
|
||||
{
|
||||
column.deepCopyTo(this.get(offsetX, offsetZ));
|
||||
this.isColumnNotEmpty.set(offsetX * SECTION_SIZE + offsetZ, true);
|
||||
this.isColumnNotEmpty.set(offsetX * WIDTH + offsetZ, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -394,7 +400,7 @@ public class LowDetailIncompleteFullDataSource extends FullDataArrayAccessor imp
|
||||
{
|
||||
for (int zOffset = 0; zOffset < dataWidth; zOffset++)
|
||||
{
|
||||
this.isColumnNotEmpty.set((offsetX + xOffset) * SECTION_SIZE + offsetZ + zOffset, true);
|
||||
this.isColumnNotEmpty.set((offsetX + xOffset) * WIDTH + offsetZ + zOffset, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -412,7 +418,7 @@ public class LowDetailIncompleteFullDataSource extends FullDataArrayAccessor imp
|
||||
dataPos = dataPos.convertToDetailLevel(this.getDataDetailLevel());
|
||||
int offsetX = dataPos.x - basePos.x;
|
||||
int offsetZ = dataPos.z - basePos.z;
|
||||
this.isColumnNotEmpty.set(offsetX * SECTION_SIZE + offsetZ, true);
|
||||
this.isColumnNotEmpty.set(offsetX * WIDTH + offsetZ, true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -425,7 +431,7 @@ public class LowDetailIncompleteFullDataSource extends FullDataArrayAccessor imp
|
||||
{
|
||||
return this;
|
||||
}
|
||||
else if (this.isColumnNotEmpty.cardinality() != SECTION_SIZE * SECTION_SIZE)
|
||||
else if (this.isColumnNotEmpty.cardinality() != WIDTH * WIDTH)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
@@ -440,7 +446,7 @@ public class LowDetailIncompleteFullDataSource extends FullDataArrayAccessor imp
|
||||
//======//
|
||||
|
||||
@Override
|
||||
public SingleColumnFullDataAccessor tryGet(int relativeX, int relativeZ) { return this.isColumnNotEmpty.get(relativeX * SECTION_SIZE + relativeZ) ? this.get(relativeX, relativeZ) : null; }
|
||||
public SingleColumnFullDataAccessor tryGet(int relativeX, int relativeZ) { return this.isColumnNotEmpty.get(relativeX * WIDTH + relativeZ) ? this.get(relativeX, relativeZ) : null; }
|
||||
|
||||
|
||||
|
||||
@@ -453,7 +459,7 @@ public class LowDetailIncompleteFullDataSource extends FullDataArrayAccessor imp
|
||||
@Override
|
||||
public byte getDataDetailLevel() { return (byte) (this.sectionPos.sectionDetailLevel - SECTION_SIZE_OFFSET); }
|
||||
@Override
|
||||
public byte getDataVersion() { return LATEST_VERSION; }
|
||||
public byte getBinaryDataFormatVersion() { return DATA_FORMAT_VERSION; }
|
||||
|
||||
@Override
|
||||
public EDhApiWorldGenerationStep getWorldGenStep() { return this.worldGenStep; }
|
||||
|
||||
@@ -291,9 +291,9 @@ public class FullDataMetaFile extends AbstractMetaDataContainerFile
|
||||
}
|
||||
|
||||
private static BaseMetaData makeMetaData(IFullDataSource data) {
|
||||
AbstractFullDataSourceLoader loader = AbstractFullDataSourceLoader.getLoader(data.getClass(), data.getDataVersion());
|
||||
AbstractFullDataSourceLoader loader = AbstractFullDataSourceLoader.getLoader(data.getClass(), data.getBinaryDataFormatVersion());
|
||||
return new BaseMetaData(data.getSectionPos(), -1,
|
||||
data.getDataDetailLevel(), data.getWorldGenStep(), (loader == null ? 0 : loader.datatypeId), data.getDataVersion());
|
||||
data.getDataDetailLevel(), data.getWorldGenStep(), (loader == null ? 0 : loader.datatypeId), data.getBinaryDataFormatVersion());
|
||||
}
|
||||
|
||||
// "unchecked": Suppress casting of CompletableFuture<?> to CompletableFuture<LodDataSource>
|
||||
@@ -399,11 +399,11 @@ public class FullDataMetaFile extends AbstractMetaDataContainerFile
|
||||
// Write/Update data
|
||||
LodUtil.assertTrue(metaData != null);
|
||||
metaData.dataLevel = fullDataSource.getDataDetailLevel();
|
||||
fullDataSourceLoader = AbstractFullDataSourceLoader.getLoader(fullDataSource.getClass(), fullDataSource.getDataVersion());
|
||||
LodUtil.assertTrue(fullDataSourceLoader != null, "No loader for "+fullDataSource.getClass()+" (v"+fullDataSource.getDataVersion()+")");
|
||||
fullDataSourceLoader = AbstractFullDataSourceLoader.getLoader(fullDataSource.getClass(), fullDataSource.getBinaryDataFormatVersion());
|
||||
LodUtil.assertTrue(fullDataSourceLoader != null, "No loader for "+fullDataSource.getClass()+" (v"+fullDataSource.getBinaryDataFormatVersion()+")");
|
||||
dataType = fullDataSource.getClass();
|
||||
metaData.dataTypeId = (fullDataSourceLoader == null) ? 0 : fullDataSourceLoader.datatypeId;
|
||||
metaData.loaderVersion = fullDataSource.getDataVersion();
|
||||
metaData.loaderVersion = fullDataSource.getBinaryDataFormatVersion();
|
||||
super.writeData((outputStream) -> fullDataSource.writeToStream(outputStream, level));
|
||||
doesFileExist = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user