Rename, refactor, and document FullData Accessors

This commit is contained in:
James Seibel
2023-04-22 12:45:42 -05:00
parent d8e5d588d9
commit 20dc5032ad
30 changed files with 340 additions and 298 deletions
@@ -7,10 +7,10 @@ import com.seibel.lod.api.objects.data.DhApiTerrainDataPoint;
import com.seibel.lod.api.interfaces.data.IDhApiTerrainDataRepo;
import com.seibel.lod.api.objects.math.DhApiVec3i;
import com.seibel.lod.core.api.internal.SharedApi;
import com.seibel.lod.core.dataObjects.fullData.accessor.SingleFullDataAccessor;
import com.seibel.lod.core.dataObjects.fullData.sources.IFullDataSource;
import com.seibel.lod.core.util.FullDataPointUtil;
import com.seibel.lod.core.dataObjects.fullData.FullDataPointIdMap;
import com.seibel.lod.core.dataObjects.fullData.accessor.SingleFullArrayView;
import com.seibel.lod.core.level.IDhLevel;
import com.seibel.lod.core.pos.DhLodPos;
import com.seibel.lod.core.pos.DhSectionPos;
@@ -209,7 +209,7 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
{
// attempt to get the LOD data from the data source
FullDataPointIdMap mapping = dataSource.getMapping();
SingleFullArrayView dataColumn = dataSource.tryGet(relativePos.x, relativePos.z);
SingleFullDataAccessor dataColumn = dataSource.tryGet(relativePos.x, relativePos.z);
if (dataColumn != null)
{
int dataColumnIndexCount = dataColumn.getSingleLength();
@@ -1,6 +1,6 @@
package com.seibel.lod.core.dataObjects.fullData;
import com.seibel.lod.core.dataObjects.fullData.accessor.SingleFullArrayView;
import com.seibel.lod.core.dataObjects.fullData.accessor.SingleFullDataAccessor;
import com.seibel.lod.core.dataObjects.fullData.sources.CompleteFullDataSource;
import com.seibel.lod.core.dataObjects.fullData.sources.IFullDataSource;
import com.seibel.lod.core.file.fullDatafile.IFullDataSourceProvider;
@@ -101,7 +101,7 @@ public class FullDataDownSampler {
for (int ox = 0; ox < overlappedTrgDataSize; ox++) {
for (int oz = 0; oz < overlappedTrgDataSize; oz++) {
SingleFullArrayView column = target.get(ox + offsetX, oz + offsetZ);
SingleFullDataAccessor column = target.get(ox + offsetX, oz + offsetZ);
column.downsampleFrom(source.subView(srcDataPerTrgData, ox * srcDataPerTrgData, oz * srcDataPerTrgData));
}
}
@@ -6,9 +6,10 @@ import com.seibel.lod.core.pos.DhLodPos;
import com.seibel.lod.core.util.LodUtil;
/**
* Contains the Full Data for a single chunk.
* A more specific version of {@link FullDataArrayAccessor}
* that only contains full data for a single chunk.
*/
public class ChunkSizedFullDataView extends FullDataArrayView
public class ChunkSizedFullDataAccessor extends FullDataArrayAccessor
{
public final DhChunkPos pos;
// TODO replace this var with LodUtil.BLOCK_DETAIL_LEVEL
@@ -16,7 +17,7 @@ public class ChunkSizedFullDataView extends FullDataArrayView
public ChunkSizedFullDataView(DhChunkPos pos)
public ChunkSizedFullDataAccessor(DhChunkPos pos)
{
super(new FullDataPointIdMap(),
new long[LodUtil.CHUNK_WIDTH * LodUtil.CHUNK_WIDTH][0],
@@ -27,15 +28,12 @@ public class ChunkSizedFullDataView extends FullDataArrayView
public void setSingleColumn(long[] data, int x, int z)
{
dataArrays[x * LodUtil.CHUNK_WIDTH + z] = data;
}
public void setSingleColumn(long[] data, int xRelative, int zRelative) { this.dataArrays[xRelative * LodUtil.CHUNK_WIDTH + zRelative] = data; }
public long nonEmptyCount()
{
long count = 0;
for (long[] data : dataArrays)
for (long[] data : this.dataArrays)
{
if (data.length != 0)
{
@@ -45,8 +43,8 @@ public class ChunkSizedFullDataView extends FullDataArrayView
return count;
}
public long emptyCount() { return LodUtil.CHUNK_WIDTH * LodUtil.CHUNK_WIDTH - nonEmptyCount(); }
public long emptyCount() { return (LodUtil.CHUNK_WIDTH * LodUtil.CHUNK_WIDTH) - this.nonEmptyCount(); }
public DhLodPos getLodPos() { return new DhLodPos(LodUtil.CHUNK_DETAIL_LEVEL, pos.x, pos.z); }
public DhLodPos getLodPos() { return new DhLodPos(LodUtil.CHUNK_DETAIL_LEVEL, this.pos.x, this.pos.z); }
}
@@ -3,13 +3,24 @@ package com.seibel.lod.core.dataObjects.fullData.accessor;
import com.seibel.lod.core.dataObjects.fullData.FullDataPointIdMap;
import com.seibel.lod.core.util.FullDataPointUtil;
import com.seibel.lod.core.util.LodUtil;
import com.seibel.lod.core.dataObjects.fullData.sources.CompleteFullDataSource;
import com.seibel.lod.core.dataObjects.fullData.sources.SpottyFullDataSource;
/**
* Contains Full Data points and basic methods for getting and setting them. <br>
* Can be used standalone or as the base for Full data sources.
*
* @see CompleteFullDataSource
* @see SpottyFullDataSource
*/
public class FullDataArrayView implements IFullDataView
public class FullDataArrayAccessor implements IFullDataAccessor
{
protected final FullDataPointIdMap mapping;
/**
* A flattened 2D array (for the X and Z directions) containing an array for the Y direction.
* TODO the flattened array is probably to reduce garbage collection overhead, but is doing it this way worth while? Having a 3D array would be much easier to understand
*/
protected final long[][] dataArrays;
/** measured in data points */
@@ -17,6 +28,7 @@ public class FullDataArrayView implements IFullDataView
/** measured in data points */
protected final int dataWidth;
/** index offset used when getting/setting data in {@link FullDataArrayAccessor#dataArrays}. */
protected final int offset;
@@ -25,7 +37,7 @@ public class FullDataArrayView implements IFullDataView
// constructors //
//==============//
public FullDataArrayView(FullDataPointIdMap mapping, long[][] dataArrays, int width)
public FullDataArrayAccessor(FullDataPointIdMap mapping, long[][] dataArrays, int width)
{
if (dataArrays.length != width * width)
{
@@ -39,7 +51,7 @@ public class FullDataArrayView implements IFullDataView
this.offset = 0;
}
public FullDataArrayView(FullDataArrayView source, int width, int offsetX, int offsetZ)
public FullDataArrayAccessor(FullDataArrayAccessor source, int width, int offsetX, int offsetZ)
{
if (source.width < width || source.width < width + offsetX || source.width < width + offsetZ)
{
@@ -60,10 +72,10 @@ public class FullDataArrayView implements IFullDataView
//=========//
@Override
public FullDataArrayView subView(int size, int xOffset, int zOffset) { return new FullDataArrayView(this, size, xOffset, zOffset); }
public FullDataArrayAccessor subView(int width, int xOffset, int zOffset) { return new FullDataArrayAccessor(this, width, xOffset, zOffset); }
/** WARNING: This will potentially share the underlying array object! */
public void shadowCopyTo(FullDataArrayView target)
public void shadowCopyTo(FullDataArrayAccessor target)
{
if (target.width != this.width)
{
@@ -99,7 +111,7 @@ public class FullDataArrayView implements IFullDataView
}
}
public void downsampleFrom(FullDataArrayView arrayView)
public void downsampleFrom(FullDataArrayAccessor arrayView)
{
LodUtil.assertTrue(arrayView.width > this.width && arrayView.width % this.width == 0);
@@ -108,7 +120,7 @@ public class FullDataArrayView implements IFullDataView
{
for (int zOffset = 0; zOffset < this.width; zOffset++)
{
SingleFullArrayView column = this.get(xOffset, zOffset);
SingleFullDataAccessor column = this.get(xOffset, zOffset);
column.downsampleFrom(arrayView.subView(dataPerUnit, xOffset * dataPerUnit, zOffset * dataPerUnit));
}
}
@@ -124,9 +136,9 @@ public class FullDataArrayView implements IFullDataView
public FullDataPointIdMap getMapping() { return this.mapping; }
@Override
public SingleFullArrayView get(int index) { return this.get(index / this.width, index % this.width); }
public SingleFullDataAccessor get(int index) { return this.get(index / this.width, index % this.width); }
@Override
public SingleFullArrayView get(int relativeX, int relativeZ) { return new SingleFullArrayView(this.mapping, this.dataArrays, relativeX * this.width + relativeZ + this.offset); }
public SingleFullDataAccessor get(int relativeX, int relativeZ) { return new SingleFullDataAccessor(this.mapping, this.dataArrays, relativeX * this.width + relativeZ + this.offset); }
@Override
public int width() { return this.width; }
@@ -0,0 +1,58 @@
package com.seibel.lod.core.dataObjects.fullData.accessor;
import com.seibel.lod.core.dataObjects.fullData.FullDataPointIdMap;
import com.seibel.lod.core.util.LodUtil;
import com.seibel.lod.core.dataObjects.fullData.sources.IFullDataSource;
import com.seibel.lod.core.dataObjects.render.ColumnRenderSource;
import com.seibel.lod.core.util.FullDataPointUtil;
import java.util.Iterator;
/**
* Contains raw full data points, which must be interpreted by the {@link FullDataPointUtil}. <br>
* Often used by {@link IFullDataSource}'s.
*
* @see IFullDataSource
* @see FullDataArrayAccessor
*/
public interface IFullDataAccessor
{
FullDataPointIdMap getMapping();
/** generally used for iterating through the whole data set */
SingleFullDataAccessor get(int index);
SingleFullDataAccessor get(int relativeX, int relativeZ);
/** measured in full data points */
int width();
/**
* Creates a new {@link IFullDataAccessor} with the given width and starting at the given X and Z offsets. <br>
* The returned object will use the same underlining data structure (IE memory addresses) as the source {@link IFullDataAccessor}.
*/
IFullDataAccessor subView(int width, int xOffset, int zOffset);
/** Returns an iterator that goes over each data column */
default Iterator<SingleFullDataAccessor> iterator()
{
return new Iterator<SingleFullDataAccessor>()
{
private int index = 0;
private final int size = width() * width();
@Override
public boolean hasNext() { return this.index < this.size; }
@Override
public SingleFullDataAccessor next()
{
LodUtil.assertTrue(this.hasNext(), "No more data to iterate!");
return get(this.index++);
}
};
}
}
@@ -1,44 +0,0 @@
package com.seibel.lod.core.dataObjects.fullData.accessor;
import com.seibel.lod.core.dataObjects.fullData.FullDataPointIdMap;
import com.seibel.lod.core.util.LodUtil;
import java.util.Iterator;
public interface IFullDataView
{
FullDataPointIdMap getMapping();
/** generally used for iterating through the whole data set */
SingleFullArrayView get(int index);
SingleFullArrayView get(int relativeX, int relativeZ);
/** measured in full data points */
int width();
IFullDataView subView(int size, int xOffset, int zOffset);
/** Returns an iterator that goes over each data column */
default Iterator<SingleFullArrayView> iterator()
{
return new Iterator<SingleFullArrayView>()
{
private int index = 0;
private final int size = width() * width();
@Override
public boolean hasNext() { return this.index < this.size; }
@Override
public SingleFullArrayView next()
{
LodUtil.assertTrue(this.hasNext(), "No more data to iterate!");
return get(this.index++);
}
};
}
}
@@ -1,120 +0,0 @@
package com.seibel.lod.core.dataObjects.fullData.accessor;
import com.seibel.lod.core.dataObjects.fullData.FullDataPointIdMap;
import com.seibel.lod.core.util.FullDataPointUtil;
public class SingleFullArrayView implements IFullDataView
{
private final long[][] dataArrays;
private final int offset;
private final FullDataPointIdMap mapping;
public SingleFullArrayView(FullDataPointIdMap mapping, long[][] dataArrays, int offset)
{
this.dataArrays = dataArrays;
this.offset = offset;
this.mapping = mapping;
}
public boolean doesItExist() { return this.dataArrays[this.offset].length != 0; }
@Override
public FullDataPointIdMap getMapping() { return this.mapping; }
@Override
public SingleFullArrayView get(int index)
{
if (index != 0)
{
throw new IllegalArgumentException("Only contains 1 column of full data!");
}
return this;
}
@Override
public SingleFullArrayView get(int relativeX, int relativeZ)
{
if (relativeX != 0 || relativeZ != 0)
{
throw new IllegalArgumentException("Only contains 1 column of full data!");
}
return this;
}
public long[] getRaw() { return this.dataArrays[this.offset]; }
public long getSingle(int yIndex) { return this.dataArrays[this.offset][yIndex]; }
public void setSingle(int yIndex, long value) { this.dataArrays[this.offset][yIndex] = value; }
public void setNew(long[] newArray) { this.dataArrays[this.offset] = newArray; }
/** @return how many data points are in this column */
public int getSingleLength() { return this.dataArrays[this.offset].length; }
@Override
public int width() { return 1; }
@Override
public IFullDataView subView(int size, int ox, int oz)
{
if (size != 1 || ox != 1 || oz != 1)
{
throw new IllegalArgumentException("Getting invalid range of subView from SingleFullArrayView!");
}
return this;
}
/** WARNING: It may potentially share the underlying array object! */
public void shadowCopyTo(SingleFullArrayView target)
{
if (target.mapping.equals(this.mapping))
{
target.dataArrays[target.offset] = this.dataArrays[this.offset];
}
else
{
int[] remappedEntryIds = target.mapping.mergeAndReturnRemappedEntityIds(this.mapping);
long[] sourceData = this.dataArrays[this.offset];
long[] newData = new long[sourceData.length];
for (int i = 0; i < newData.length; i++)
{
newData[i] = FullDataPointUtil.remap(remappedEntryIds, sourceData[i]);
}
target.dataArrays[target.offset] = newData;
}
}
public void deepCopyTo(SingleFullArrayView target)
{
if (target.mapping.equals(this.mapping))
{
target.dataArrays[target.offset] = this.dataArrays[this.offset].clone();
}
else
{
int[] remappedEntryIds = target.mapping.mergeAndReturnRemappedEntityIds(this.mapping);
long[] sourceData = this.dataArrays[this.offset];
long[] newData = new long[sourceData.length];
for (int i = 0; i < newData.length; i++)
{
newData[i] = FullDataPointUtil.remap(remappedEntryIds, sourceData[i]);
}
target.dataArrays[target.offset] = newData;
}
}
public void downsampleFrom(IFullDataView source)
{
//TODO: Temp downsample method
SingleFullArrayView firstColumn = source.get(0);
firstColumn.deepCopyTo(this);
}
}
@@ -0,0 +1,129 @@
package com.seibel.lod.core.dataObjects.fullData.accessor;
import com.seibel.lod.core.dataObjects.fullData.FullDataPointIdMap;
import com.seibel.lod.core.util.FullDataPointUtil;
/**
*
*/
public class SingleFullDataAccessor implements IFullDataAccessor
{
/**
* A flattened 2D array (for the X and Z directions) containing an array for the Y direction.
* TODO the flattened array is probably to reduce garbage collection overhead, but is doing it this way worth while? Having a 3D array would be much easier to understand
* @see FullDataArrayAccessor#dataArrays
*/
private final long[][] dataArrays;
/** indicates what index of the {@link SingleFullDataAccessor#dataArrays} is used by this accessor */
private final int dataArrayIndex;
private final FullDataPointIdMap mapping;
public SingleFullDataAccessor(FullDataPointIdMap mapping, long[][] dataArrays, int dataArrayIndex)
{
this.dataArrays = dataArrays;
this.dataArrayIndex = dataArrayIndex;
this.mapping = mapping;
}
public boolean doesColumnExist() { return this.dataArrays[this.dataArrayIndex].length != 0; }
@Override
public FullDataPointIdMap getMapping() { return this.mapping; }
@Override
public SingleFullDataAccessor get(int index)
{
if (index != 0)
{
throw new IllegalArgumentException("Only contains 1 column of full data!");
}
return this;
}
@Override
public SingleFullDataAccessor get(int relativeX, int relativeZ)
{
if (relativeX != 0 || relativeZ != 0)
{
throw new IllegalArgumentException("Only contains 1 column of full data!");
}
return this;
}
public long[] getRaw() { return this.dataArrays[this.dataArrayIndex]; }
public long getSingle(int yIndex) { return this.dataArrays[this.dataArrayIndex][yIndex]; }
public void setSingle(int yIndex, long value) { this.dataArrays[this.dataArrayIndex][yIndex] = value; }
public void setNew(long[] newArray) { this.dataArrays[this.dataArrayIndex] = newArray; }
/** @return how many data points are in this column */
public int getSingleLength() { return this.dataArrays[this.dataArrayIndex].length; }
@Override
public int width() { return 1; }
@Override
public IFullDataAccessor subView(int width, int xOffset, int zOffset)
{
if (width != 1 || xOffset != 1 || zOffset != 1)
{
throw new IllegalArgumentException("Getting invalid range of subView from SingleFullDataAccessor!");
}
return this;
}
/** WARNING: It may potentially share the underlying array object! */
public void shadowCopyTo(SingleFullDataAccessor target)
{
if (target.mapping.equals(this.mapping))
{
target.dataArrays[target.dataArrayIndex] = this.dataArrays[this.dataArrayIndex];
}
else
{
int[] remappedEntryIds = target.mapping.mergeAndReturnRemappedEntityIds(this.mapping);
long[] sourceData = this.dataArrays[this.dataArrayIndex];
long[] newData = new long[sourceData.length];
for (int i = 0; i < newData.length; i++)
{
newData[i] = FullDataPointUtil.remap(remappedEntryIds, sourceData[i]);
}
target.dataArrays[target.dataArrayIndex] = newData;
}
}
public void deepCopyTo(SingleFullDataAccessor target)
{
if (target.mapping.equals(this.mapping))
{
target.dataArrays[target.dataArrayIndex] = this.dataArrays[this.dataArrayIndex].clone();
}
else
{
int[] remappedEntryIds = target.mapping.mergeAndReturnRemappedEntityIds(this.mapping);
long[] sourceData = this.dataArrays[this.dataArrayIndex];
long[] newData = new long[sourceData.length];
for (int i = 0; i < newData.length; i++)
{
newData[i] = FullDataPointUtil.remap(remappedEntryIds, sourceData[i]);
}
target.dataArrays[target.dataArrayIndex] = newData;
}
}
public void downsampleFrom(IFullDataAccessor source)
{
//TODO: Temp downsample method
SingleFullDataAccessor firstColumn = source.get(0);
firstColumn.deepCopyTo(this);
}
}
@@ -2,9 +2,9 @@ package com.seibel.lod.core.dataObjects.fullData.sources;
import com.seibel.lod.api.enums.worldGeneration.EDhApiWorldGenerationStep;
import com.seibel.lod.core.dataObjects.fullData.FullDataPointIdMap;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataView;
import com.seibel.lod.core.dataObjects.fullData.accessor.FullDataArrayView;
import com.seibel.lod.core.dataObjects.fullData.accessor.SingleFullArrayView;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataAccessor;
import com.seibel.lod.core.dataObjects.fullData.accessor.FullDataArrayAccessor;
import com.seibel.lod.core.dataObjects.fullData.accessor.SingleFullDataAccessor;
import com.seibel.lod.core.level.IDhLevel;
import com.seibel.lod.core.pos.DhBlockPos2D;
import com.seibel.lod.core.pos.DhLodPos;
@@ -18,12 +18,12 @@ import org.apache.logging.log4j.Logger;
import java.io.*;
/**
*
* This data source contains every datapoint over its given {@link DhSectionPos}.
*/
public class CompleteFullDataSource extends FullDataArrayView implements IFullDataSource
public class CompleteFullDataSource extends FullDataArrayAccessor implements IFullDataSource
{
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
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 = 1 << SECTION_SIZE_OFFSET;
public static final byte LATEST_VERSION = 0;
public static final long TYPE_ID = "CompleteFullDataSource".hashCode();
@@ -63,10 +63,10 @@ public class CompleteFullDataSource extends FullDataArrayView implements IFullDa
public EDhApiWorldGenerationStep getWorldGenStep() { return EDhApiWorldGenerationStep.EMPTY; }
@Override
public SingleFullArrayView tryGet(int relativeX, int relativeZ) { return this.get(relativeX, relativeZ); }
public SingleFullDataAccessor tryGet(int relativeX, int relativeZ) { return this.get(relativeX, relativeZ); }
@Override
public void update(ChunkSizedFullDataView chunkDataView)
public void update(ChunkSizedFullDataAccessor chunkDataView)
{
LodUtil.assertTrue(this.sectionPos.getSectionBBoxPos().overlapsExactly(chunkDataView.getLodPos()));
if (this.getDataDetailLevel() == 0)
@@ -81,8 +81,8 @@ public class CompleteFullDataSource extends FullDataArrayView implements IFullDa
{
for (int z = 0; z < 16; z++)
{
SingleFullArrayView column = this.get(x + blockOffset.x, z + blockOffset.z);
LodUtil.assertTrue(column.doesItExist());
SingleFullDataAccessor column = this.get(x + blockOffset.x, z + blockOffset.z);
LodUtil.assertTrue(column.doesColumnExist());
}
}
}
@@ -101,7 +101,7 @@ public class CompleteFullDataSource extends FullDataArrayView implements IFullDa
{
for (int oz = 0; oz < fullSize; oz++)
{
SingleFullArrayView column = this.get(ox + offsetX, oz + offsetZ);
SingleFullDataAccessor column = this.get(ox + offsetX, oz + offsetZ);
column.downsampleFrom(chunkDataView.subView(dataPerFull, ox * dataPerFull, oz * dataPerFull));
}
}
@@ -246,8 +246,8 @@ public class CompleteFullDataSource extends FullDataArrayView implements IFullDa
{
for (int z = 0; z < this.width; z++)
{
SingleFullArrayView column = this.get(x, z);
if (!column.doesItExist())
SingleFullDataAccessor column = this.get(x, z);
if (!column.doesColumnExist())
continue;
long[] raw = column.getRaw();
@@ -322,7 +322,7 @@ public class CompleteFullDataSource extends FullDataArrayView implements IFullDa
{
for (int oz = 0; oz < count; oz++)
{
SingleFullArrayView column = this.get(ox + dataOffsetX, oz + dataOffsetZ);
SingleFullDataAccessor column = this.get(ox + dataOffsetX, oz + dataOffsetZ);
column.downsampleFrom(subData.subView(dataPerCount, ox * dataPerCount, oz * dataPerCount));
}
}
@@ -2,18 +2,26 @@ package com.seibel.lod.core.dataObjects.fullData.sources;
import com.seibel.lod.api.enums.worldGeneration.EDhApiWorldGenerationStep;
import com.seibel.lod.core.dataObjects.fullData.FullDataPointIdMap;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataView;
import com.seibel.lod.core.dataObjects.fullData.accessor.SingleFullArrayView;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataAccessor;
import com.seibel.lod.core.dataObjects.fullData.accessor.IFullDataAccessor;
import com.seibel.lod.core.dataObjects.fullData.accessor.SingleFullDataAccessor;
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.util.FullDataPointUtil;
import java.io.BufferedOutputStream;
import java.io.IOException;
// TODO make into an abstract class so the read(stream) method can be used as a constructor
// TODO validate how we know which file to use when (probably, TYPE_ID)
// TODO merge with FullDataArrayView and IFullDataView
/**
* Contains full DH data, methods related to file/stream reading/writing, and the data necessary to create {@link ColumnRenderSource}'s. <br>
* {@link IFullDataSource}'s will either implement or contain {@link IFullDataAccessor}'s.
*
* @see IFullDataAccessor
*/
public interface IFullDataSource
{
/**
@@ -32,7 +40,7 @@ public interface IFullDataSource
public abstract byte getDataVersion();
public abstract EDhApiWorldGenerationStep getWorldGenStep();
public abstract void update(ChunkSizedFullDataView data);
public abstract void update(ChunkSizedFullDataAccessor data);
public abstract boolean isEmpty();
@@ -69,7 +77,7 @@ public interface IFullDataSource
* Attempts to get the data column for the given relative x and z position.
* @return null if the data doesn't exist
*/
public abstract SingleFullArrayView tryGet(int relativeX, int relativeZ);
public abstract SingleFullDataAccessor tryGet(int relativeX, int relativeZ);
public abstract FullDataPointIdMap getMapping();
@@ -9,6 +9,6 @@ public interface IIncompleteFullDataSource extends IFullDataSource
*
* @return this if the promotion failed, a new {@link CompleteFullDataSource} if successful.
*/
IFullDataSource tryPromotingToCompleteDataSource();
IFullDataSource tryPromotingToCompleteDataSource(); // TODO make this return CompleteFullDataSource instead, if it fails just return null
}
@@ -2,9 +2,9 @@ package com.seibel.lod.core.dataObjects.fullData.sources;
import com.seibel.lod.api.enums.worldGeneration.EDhApiWorldGenerationStep;
import com.seibel.lod.core.dataObjects.fullData.FullDataPointIdMap;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataView;
import com.seibel.lod.core.dataObjects.fullData.accessor.FullDataArrayView;
import com.seibel.lod.core.dataObjects.fullData.accessor.SingleFullArrayView;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataAccessor;
import com.seibel.lod.core.dataObjects.fullData.accessor.FullDataArrayAccessor;
import com.seibel.lod.core.dataObjects.fullData.accessor.SingleFullDataAccessor;
import com.seibel.lod.core.file.fullDatafile.FullDataMetaFile;
import com.seibel.lod.core.level.IDhLevel;
import com.seibel.lod.core.pos.DhLodPos;
@@ -20,6 +20,7 @@ import java.util.BitSet;
/**
* Handles full data with the detail level {@link SparseFullDataSource#SPARSE_UNIT_DETAIL}.
* In other words, this is the middle ground between {@link SpottyFullDataSource} and {@link CompleteFullDataSource}
* TODO there has to be a better way to name these
*/
public class SparseFullDataSource implements IIncompleteFullDataSource
{
@@ -43,7 +44,7 @@ public class SparseFullDataSource implements IIncompleteFullDataSource
protected final FullDataPointIdMap mapping;
private final DhSectionPos sectionPos;
private final FullDataArrayView[] sparseData;
private final FullDataArrayAccessor[] sparseData;
private final DhLodPos chunkPos;
public final int chunks;
@@ -64,12 +65,12 @@ public class SparseFullDataSource implements IIncompleteFullDataSource
this.sectionPos = sectionPos;
this.chunks = 1 << (byte) (sectionPos.sectionDetailLevel - SPARSE_UNIT_DETAIL);
this.dataPerChunk = SECTION_SIZE / this.chunks;
this.sparseData = new FullDataArrayView[this.chunks * this.chunks];
this.sparseData = new FullDataArrayAccessor[this.chunks * this.chunks];
this.chunkPos = sectionPos.getCorner(SPARSE_UNIT_DETAIL);
this.mapping = new FullDataPointIdMap();
}
protected SparseFullDataSource(DhSectionPos sectionPos, FullDataPointIdMap mapping, FullDataArrayView[] data)
protected SparseFullDataSource(DhSectionPos sectionPos, FullDataPointIdMap mapping, FullDataArrayAccessor[] data)
{
LodUtil.assertTrue(sectionPos.sectionDetailLevel > SPARSE_UNIT_DETAIL);
LodUtil.assertTrue(sectionPos.sectionDetailLevel <= MAX_SECTION_DETAIL);
@@ -114,10 +115,10 @@ public class SparseFullDataSource implements IIncompleteFullDataSource
@Override
public void update(ChunkSizedFullDataView chunkDataView)
public void update(ChunkSizedFullDataAccessor chunkDataView)
{
int arrayOffset = this.calculateOffset(chunkDataView.pos.x, chunkDataView.pos.z);
FullDataArrayView newArray = new FullDataArrayView(this.mapping, new long[this.dataPerChunk * this.dataPerChunk][], this.dataPerChunk);
FullDataArrayAccessor newArray = new FullDataArrayAccessor(this.mapping, new long[this.dataPerChunk * this.dataPerChunk][], this.dataPerChunk);
if (this.getDataDetailLevel() == chunkDataView.detailLevel)
{
chunkDataView.shadowCopyTo(newArray);
@@ -131,7 +132,7 @@ public class SparseFullDataSource implements IIncompleteFullDataSource
{
for (int zOffset = 0; zOffset < count; zOffset++)
{
SingleFullArrayView column = newArray.get(xOffset, zOffset);
SingleFullDataAccessor column = newArray.get(xOffset, zOffset);
column.downsampleFrom(chunkDataView.subView(dataPerCount, xOffset * dataPerCount, zOffset * dataPerCount));
}
}
@@ -186,10 +187,10 @@ public class SparseFullDataSource implements IIncompleteFullDataSource
{
for (int zOffset = 0; zOffset < sparseSource.chunks; zOffset++)
{
FullDataArrayView sourceChunk = sparseSource.sparseData[xOffset * sparseSource.chunks + zOffset];
FullDataArrayAccessor sourceChunk = sparseSource.sparseData[xOffset * sparseSource.chunks + zOffset];
if (sourceChunk != null)
{
FullDataArrayView buff = new FullDataArrayView(this.mapping, new long[this.dataPerChunk * this.dataPerChunk][], this.dataPerChunk);
FullDataArrayAccessor buff = new FullDataArrayAccessor(this.mapping, new long[this.dataPerChunk * this.dataPerChunk][], this.dataPerChunk);
buff.downsampleFrom(sourceChunk);
this.sparseData[(xOffset + offsetX) * this.chunks + (zOffset + offsetZ)] = buff;
}
@@ -214,8 +215,8 @@ public class SparseFullDataSource implements IIncompleteFullDataSource
{
for (int zOffset = 0; zOffset < coveredChunks; zOffset++)
{
FullDataArrayView sourceChunk = fullSource.subView(sourceDataPerChunk, xOffset * sourceDataPerChunk, zOffset * sourceDataPerChunk);
FullDataArrayView buff = new FullDataArrayView(this.mapping, new long[this.dataPerChunk * this.dataPerChunk][], this.dataPerChunk);
FullDataArrayAccessor sourceChunk = fullSource.subView(sourceDataPerChunk, xOffset * sourceDataPerChunk, zOffset * sourceDataPerChunk);
FullDataArrayAccessor buff = new FullDataArrayAccessor(this.mapping, new long[this.dataPerChunk * this.dataPerChunk][], this.dataPerChunk);
buff.downsampleFrom(sourceChunk);
this.sparseData[(xOffset + offsetX) * this.chunks + (zOffset + offsetZ)] = buff;
}
@@ -262,7 +263,7 @@ public class SparseFullDataSource implements IIncompleteFullDataSource
i = dataArrayIndexHasData.nextSetBit(i+1))
{
// column data length
FullDataArrayView array = this.sparseData[i];
FullDataArrayAccessor array = this.sparseData[i];
LodUtil.assertTrue(array != null);
for (int x = 0; x < array.width(); x++)
{
@@ -277,10 +278,10 @@ public class SparseFullDataSource implements IIncompleteFullDataSource
{
for (int z = 0; z < array.width(); z++)
{
SingleFullArrayView column = array.get(x, z);
SingleFullDataAccessor column = array.get(x, z);
LodUtil.assertTrue(column.getMapping() == this.mapping); // the mappings must be exactly equal!
if (column.doesItExist())
if (column.doesColumnExist())
{
long[] raw = column.getRaw();
for (long l : raw)
@@ -447,12 +448,12 @@ public class SparseFullDataSource implements IIncompleteFullDataSource
throw new IOException("invalid id mapping end guard");
}
FullDataArrayView[] fullDataArrays = new FullDataArrayView[chunks * chunks];
FullDataArrayAccessor[] fullDataArrays = new FullDataArrayAccessor[chunks * chunks];
for (int i = 0; i < rawFullDataArrays.length; i++)
{
if (rawFullDataArrays[i] != null)
{
fullDataArrays[i] = new FullDataArrayView(mapping, rawFullDataArrays[i], dataPointsPerChunk);
fullDataArrays[i] = new FullDataArrayAccessor(mapping, rawFullDataArrays[i], dataPointsPerChunk);
}
}
@@ -470,13 +471,13 @@ public class SparseFullDataSource implements IIncompleteFullDataSource
{
for (int z = 0; z < this.chunks; z++)
{
FullDataArrayView array = this.sparseData[x * this.chunks + z];
FullDataArrayAccessor array = this.sparseData[x * this.chunks + z];
if (array == null)
continue;
// Otherwise, apply data to dataSource
dataSource.markNotEmpty();
FullDataArrayView view = dataSource.subView(this.dataPerChunk, x * this.dataPerChunk, z * this.dataPerChunk);
FullDataArrayAccessor view = dataSource.subView(this.dataPerChunk, x * this.dataPerChunk, z * this.dataPerChunk);
array.shadowCopyTo(view);
}
}
@@ -490,7 +491,7 @@ public class SparseFullDataSource implements IIncompleteFullDataSource
}
// promotion can only succeed if every data column is present
for (FullDataArrayView array : this.sparseData)
for (FullDataArrayAccessor array : this.sparseData)
{
if (array == null)
{
@@ -503,16 +504,17 @@ public class SparseFullDataSource implements IIncompleteFullDataSource
return fullDataSource;
}
public SingleFullArrayView tryGet(int relativeX, int relativeZ)
public SingleFullDataAccessor 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;
FullDataArrayView chunk = this.sparseData[chunkX * this.chunks + chunkZ];
FullDataArrayAccessor chunk = this.sparseData[chunkX * this.chunks + chunkZ];
if (chunk == null)
{
return null;
}
return chunk.get(relativeX % this.dataPerChunk, relativeZ % this.dataPerChunk);
}
@@ -2,9 +2,9 @@ package com.seibel.lod.core.dataObjects.fullData.sources;
import com.seibel.lod.api.enums.worldGeneration.EDhApiWorldGenerationStep;
import com.seibel.lod.core.dataObjects.fullData.FullDataPointIdMap;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataView;
import com.seibel.lod.core.dataObjects.fullData.accessor.FullDataArrayView;
import com.seibel.lod.core.dataObjects.fullData.accessor.SingleFullArrayView;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataAccessor;
import com.seibel.lod.core.dataObjects.fullData.accessor.FullDataArrayAccessor;
import com.seibel.lod.core.dataObjects.fullData.accessor.SingleFullDataAccessor;
import com.seibel.lod.core.file.fullDatafile.FullDataMetaFile;
import com.seibel.lod.core.level.IDhLevel;
import com.seibel.lod.core.logging.DhLoggerBuilder;
@@ -20,7 +20,7 @@ import java.util.BitSet;
* more data than sparse, less than complete.
* TODO there has to be a better way to name these
*/
public class SpottyFullDataSource extends FullDataArrayView implements IIncompleteFullDataSource
public class SpottyFullDataSource extends FullDataArrayAccessor implements IIncompleteFullDataSource
{
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
public static final byte SECTION_SIZE_OFFSET = 6;
@@ -218,7 +218,7 @@ public class SpottyFullDataSource extends FullDataArrayView implements IIncomple
//===============//
@Override
public void update(ChunkSizedFullDataView data)
public void update(ChunkSizedFullDataAccessor data)
{
LodUtil.assertTrue(this.sectionPos.getSectionBBoxPos().overlapsExactly(data.getLodPos()));
@@ -289,7 +289,7 @@ public class SpottyFullDataSource extends FullDataArrayView implements IIncomple
{
for (int zOffset = 0; zOffset < dataSpan; zOffset++)
{
SingleFullArrayView column = sparseSource.tryGet(
SingleFullDataAccessor column = sparseSource.tryGet(
xOffset * chunksPerData * sparseSource.dataPerChunk,
zOffset * chunksPerData * sparseSource.dataPerChunk);
@@ -311,7 +311,7 @@ public class SpottyFullDataSource extends FullDataArrayView implements IIncomple
dataPos = dataPos.convertToDetailLevel(this.getDataDetailLevel());
int offsetX = dataPos.x - basePos.x;
int offsetZ = dataPos.z - basePos.z;
SingleFullArrayView column = sparseSource.tryGet(0, 0);
SingleFullDataAccessor column = sparseSource.tryGet(0, 0);
if (column != null) {
column.deepCopyTo(this.get(offsetX, offsetZ));
this.isColumnNotEmpty.set(offsetX * SECTION_SIZE + offsetZ, true);
@@ -382,7 +382,7 @@ public class SpottyFullDataSource extends FullDataArrayView implements IIncomple
//
@Override
public SingleFullArrayView tryGet(int relativeX, int relativeZ) { return this.isColumnNotEmpty.get(relativeX * SECTION_SIZE + relativeZ) ? this.get(relativeX, relativeZ) : null; }
public SingleFullDataAccessor tryGet(int relativeX, int relativeZ) { return this.isColumnNotEmpty.get(relativeX * SECTION_SIZE + relativeZ) ? this.get(relativeX, relativeZ) : null; }
@@ -2,11 +2,11 @@ package com.seibel.lod.core.dataObjects.render;
import com.seibel.lod.api.enums.worldGeneration.EDhApiWorldGenerationStep;
import com.seibel.lod.core.ModInfo;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataAccessor;
import com.seibel.lod.core.dataObjects.render.columnViews.ColumnArrayView;
import com.seibel.lod.core.dataObjects.render.columnViews.ColumnQuadView;
import com.seibel.lod.core.dataObjects.render.columnViews.IColumnDataView;
import com.seibel.lod.core.dataObjects.render.bufferBuilding.ColumnRenderBuffer;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataView;
import com.seibel.lod.core.dataObjects.transformers.FullToColumnTransformer;
import com.seibel.lod.core.level.IDhClientLevel;
import com.seibel.lod.core.pos.DhSectionPos;
@@ -296,7 +296,7 @@ public class ColumnRenderSource
}
}
public void fastWrite(ChunkSizedFullDataView chunkData, IDhClientLevel level)
public void fastWrite(ChunkSizedFullDataAccessor chunkData, IDhClientLevel level)
{
try
{
@@ -3,7 +3,7 @@ package com.seibel.lod.core.dataObjects.transformers;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataView;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataAccessor;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.logging.ConfigBasedLogger;
import com.seibel.lod.core.pos.DhChunkPos;
@@ -25,9 +25,9 @@ public class ChunkToLodBuilder
private static class Task
{
final DhChunkPos chunkPos;
final CompletableFuture<ChunkSizedFullDataView> future;
final CompletableFuture<ChunkSizedFullDataAccessor> future;
Task(DhChunkPos chunkPos, CompletableFuture<ChunkSizedFullDataView> future)
Task(DhChunkPos chunkPos, CompletableFuture<ChunkSizedFullDataAccessor> future)
{
this.chunkPos = chunkPos;
this.future = future;
@@ -44,7 +44,7 @@ public class ChunkToLodBuilder
public CompletableFuture<ChunkSizedFullDataView> tryGenerateData(IChunkWrapper chunkWrapper)
public CompletableFuture<ChunkSizedFullDataAccessor> tryGenerateData(IChunkWrapper chunkWrapper)
{
if (chunkWrapper == null)
{
@@ -61,7 +61,7 @@ public class ChunkToLodBuilder
}
// Otherwise, it means we're the first to do so. Let's submit our task to this entry.
CompletableFuture<ChunkSizedFullDataView> future = new CompletableFuture<>();
CompletableFuture<ChunkSizedFullDataAccessor> future = new CompletableFuture<>();
this.taskToBuild.addLast(new Task(chunkWrapper.getChunkPos(), future));
return future;
}
@@ -135,7 +135,7 @@ public class ChunkToLodBuilder
{
if (LodDataBuilder.canGenerateLodFromChunk(latestChunk))
{
ChunkSizedFullDataView data = LodDataBuilder.createChunkData(latestChunk);
ChunkSizedFullDataAccessor data = LodDataBuilder.createChunkData(latestChunk);
if (data != null)
{
task.future.complete(data);
@@ -1,14 +1,14 @@
package com.seibel.lod.core.dataObjects.transformers;
import com.seibel.lod.core.dataObjects.fullData.FullDataPointIdMap;
import com.seibel.lod.core.dataObjects.fullData.accessor.SingleFullDataAccessor;
import com.seibel.lod.core.dataObjects.fullData.sources.CompleteFullDataSource;
import com.seibel.lod.core.dataObjects.fullData.sources.IIncompleteFullDataSource;
import com.seibel.lod.core.util.RenderDataPointUtil;
import com.seibel.lod.core.dataObjects.render.ColumnRenderSource;
import com.seibel.lod.core.dataObjects.render.columnViews.ColumnArrayView;
import com.seibel.lod.core.dataObjects.render.columnViews.ColumnQuadView;
import com.seibel.lod.core.dataObjects.fullData.accessor.SingleFullArrayView;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataView;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataAccessor;
import com.seibel.lod.core.level.IDhClientLevel;
import com.seibel.lod.core.pos.DhSectionPos;
import com.seibel.lod.core.config.Config;
@@ -75,10 +75,10 @@ public class FullToColumnTransformer
throwIfThreadInterrupted();
ColumnArrayView columnArrayView = columnSource.getVerticalDataPointView(x, z);
SingleFullArrayView fullArrayView = fullDataSource.get(x, z);
SingleFullDataAccessor fullArrayView = fullDataSource.get(x, z);
convertColumnData(level, baseX + x, baseZ + z, columnArrayView, fullArrayView, 1);
if (fullArrayView.doesItExist())
if (fullArrayView.doesColumnExist())
{
LodUtil.assertTrue(columnSource.doesDataPointExist(x, z));
}
@@ -96,7 +96,7 @@ public class FullToColumnTransformer
// for (int x = 0; x < pos.getWidth(dataDetail).value; x++) {
// for (int z = 0; z < pos.getWidth(dataDetail).value; z++) {
// ColumnArrayView columnArrayView = columnSource.getVerticalDataView(x, z);
// SingleFullArrayView fullArrayView = data.get(x, z);
// SingleFullDataAccessor fullArrayView = data.get(x, z);
// convertColumnData(level, columnArrayView, fullArrayView);
// }
// }
@@ -136,7 +136,7 @@ public class FullToColumnTransformer
{
throwIfThreadInterrupted();
SingleFullArrayView fullArrayView = data.tryGet(x, z);
SingleFullDataAccessor fullArrayView = data.tryGet(x, z);
if (fullArrayView == null)
{
continue;
@@ -145,7 +145,7 @@ public class FullToColumnTransformer
ColumnArrayView columnArrayView = columnSource.getVerticalDataPointView(x, z);
convertColumnData(level, baseX + x, baseZ + z, columnArrayView, fullArrayView, 1);
columnSource.fillDebugFlag(x, z, 1, 1, ColumnRenderSource.DebugSourceFlag.SPARSE);
if (fullArrayView.doesItExist())
if (fullArrayView.doesColumnExist())
LodUtil.assertTrue(columnSource.doesDataPointExist(x, z));
}
}
@@ -162,7 +162,7 @@ public class FullToColumnTransformer
* @throws InterruptedException Can be caused by interrupting the thread upstream.
* Generally thrown if the method is running after the client leaves the current world.
*/
public static void writeFullDataChunkToColumnData(ColumnRenderSource render, IDhClientLevel level, ChunkSizedFullDataView chunkDataView) throws InterruptedException
public static void writeFullDataChunkToColumnData(ColumnRenderSource render, IDhClientLevel level, ChunkSizedFullDataAccessor chunkDataView) throws InterruptedException
{
final DhSectionPos pos = render.getSectionPos();
final int renderOffsetX = (chunkDataView.pos.x * LodUtil.CHUNK_WIDTH) - pos.getCorner().getCornerBlockPos().x;
@@ -188,12 +188,12 @@ public class FullToColumnTransformer
throwIfThreadInterrupted();
ColumnArrayView columnArrayView = render.getVerticalDataPointView(renderOffsetX + x, renderOffsetZ + z);
SingleFullArrayView fullArrayView = chunkDataView.get(x, z);
SingleFullDataAccessor fullArrayView = chunkDataView.get(x, z);
convertColumnData(level, blockX + perRenderWidth * (renderOffsetX + x),
blockZ + perRenderWidth * (renderOffsetZ + z),
columnArrayView, fullArrayView, 2);
if (fullArrayView.doesItExist())
if (fullArrayView.doesColumnExist())
{
LodUtil.assertTrue(render.doesDataPointExist(renderOffsetX + x, renderOffsetZ + z));
}
@@ -226,7 +226,7 @@ public class FullToColumnTransformer
ColumnArrayView columnArrayView = tempQuadView.get(ox, oz);
SingleFullArrayView fullArrayView = chunkDataView.get(x * dataPerRender + ox, z * dataPerRender + oz);
SingleFullDataAccessor fullArrayView = chunkDataView.get(x * dataPerRender + ox, z * dataPerRender + oz);
convertColumnData(level, blockX + perRenderWidth * (renderOffsetX + x) + perDataWidth * ox,
blockZ + perRenderWidth * (renderOffsetZ + z) + perDataWidth * oz,
columnArrayView, fullArrayView, 2);
@@ -240,9 +240,9 @@ public class FullToColumnTransformer
}
}
private static void convertColumnData(IDhClientLevel level, int blockX, int blockZ, ColumnArrayView columnArrayView, SingleFullArrayView fullArrayView, int genMode)
private static void convertColumnData(IDhClientLevel level, int blockX, int blockZ, ColumnArrayView columnArrayView, SingleFullDataAccessor fullArrayView, int genMode)
{
if (!fullArrayView.doesItExist())
if (!fullArrayView.doesColumnExist())
{
return;
}
@@ -265,7 +265,7 @@ public class FullToColumnTransformer
}
}
private static void iterateAndConvert(IDhClientLevel level, int blockX, int blockZ, int genMode, ColumnArrayView column, SingleFullArrayView data)
private static void iterateAndConvert(IDhClientLevel level, int blockX, int blockZ, int genMode, ColumnArrayView column, SingleFullDataAccessor data)
{
FullDataPointIdMap mapping = data.getMapping();
boolean isVoid = true;
@@ -1,6 +1,6 @@
package com.seibel.lod.core.dataObjects.transformers;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataView;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataAccessor;
import com.seibel.lod.core.util.FullDataPointUtil;
import com.seibel.lod.core.dependencyInjection.SingletonInjector;
import com.seibel.lod.core.util.LodUtil;
@@ -12,10 +12,10 @@ import it.unimi.dsi.fastutil.longs.LongArrayList;
public class LodDataBuilder {
private static final IBlockStateWrapper AIR = SingletonInjector.INSTANCE.get(IWrapperFactory.class).getAirBlockStateWrapper();
public static ChunkSizedFullDataView createChunkData(IChunkWrapper chunkWrapper) {
public static ChunkSizedFullDataAccessor createChunkData(IChunkWrapper chunkWrapper) {
if (!canGenerateLodFromChunk(chunkWrapper)) return null;
ChunkSizedFullDataView chunkData = new ChunkSizedFullDataView(chunkWrapper.getChunkPos());
ChunkSizedFullDataAccessor chunkData = new ChunkSizedFullDataAccessor(chunkWrapper.getChunkPos());
for (int x=0; x<16; x++) {
for (int z=0; z<16; z++) {
@@ -1,7 +1,7 @@
package com.seibel.lod.core.file.fullDatafile;
import com.google.common.collect.HashMultimap;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataView;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataAccessor;
import com.seibel.lod.core.dataObjects.fullData.sources.*;
import com.seibel.lod.core.dataObjects.fullData.sources.CompleteFullDataSource;
import com.seibel.lod.core.util.FileUtil;
@@ -273,7 +273,7 @@ public class FullDataFileHandler implements IFullDataSourceProvider
/** This call is concurrent. I.e. it supports being called by multiple threads at the same time. */
@Override
public void write(DhSectionPos sectionPos, ChunkSizedFullDataView chunkDataView)
public void write(DhSectionPos sectionPos, ChunkSizedFullDataAccessor chunkDataView)
{
DhLodPos chunkPos = chunkDataView.getLodPos();
LodUtil.assertTrue(chunkPos.overlapsExactly(sectionPos.getSectionBBoxPos()), "Chunk "+chunkPos+" does not overlap section "+sectionPos);
@@ -281,7 +281,7 @@ public class FullDataFileHandler implements IFullDataSourceProvider
chunkPos = chunkPos.convertToDetailLevel((byte) this.minDetailLevel);
this.writeChunkDataToMetaFile(new DhSectionPos(chunkPos.detailLevel, chunkPos.x, chunkPos.z), chunkDataView);
}
private void writeChunkDataToMetaFile(DhSectionPos sectionPos, ChunkSizedFullDataView chunkData)
private void writeChunkDataToMetaFile(DhSectionPos sectionPos, ChunkSizedFullDataAccessor chunkData)
{
FullDataMetaFile metaFile = this.files.get(sectionPos);
if (metaFile != null)
@@ -9,9 +9,9 @@ import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataAccessor;
import com.seibel.lod.core.dataObjects.fullData.sources.IFullDataSource;
import com.seibel.lod.core.dataObjects.fullData.loader.AbstractFullDataSourceLoader;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataView;
import com.seibel.lod.core.dependencyInjection.SingletonInjector;
import com.seibel.lod.core.file.metaData.BaseMetaData;
import com.seibel.lod.core.pos.DhLodPos;
@@ -47,7 +47,7 @@ public class FullDataMetaFile extends AbstractMetaDataContainerFile
//TODO: use ConcurrentAppendSingleSwapContainer<LodDataSource> instead of below:
private static class GuardedMultiAppendQueue {
ReentrantReadWriteLock appendLock = new ReentrantReadWriteLock();
ConcurrentLinkedQueue<ChunkSizedFullDataView> queue = new ConcurrentLinkedQueue<>();
ConcurrentLinkedQueue<ChunkSizedFullDataAccessor> queue = new ConcurrentLinkedQueue<>();
}
// ===Concurrent Write stuff===
@@ -146,7 +146,7 @@ public class FullDataMetaFile extends AbstractMetaDataContainerFile
// }
// }
public void addToWriteQueue(ChunkSizedFullDataView chunkDataSource)
public void addToWriteQueue(ChunkSizedFullDataAccessor chunkDataSource)
{
debugCheck();
DhLodPos chunkLodPos = new DhLodPos(LodUtil.CHUNK_DETAIL_LEVEL, chunkDataSource.pos.x, chunkDataSource.pos.z);
@@ -430,7 +430,7 @@ public class FullDataMetaFile extends AbstractMetaDataContainerFile
{
this.swapWriteQueue();
int count = this._backQueue.queue.size();
for (ChunkSizedFullDataView chunk : this._backQueue.queue)
for (ChunkSizedFullDataAccessor chunk : this._backQueue.queue)
{
fullDataSource.update(chunk);
}
@@ -1,8 +1,8 @@
package com.seibel.lod.core.file.fullDatafile;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataAccessor;
import com.seibel.lod.core.dataObjects.fullData.sources.IFullDataSource;
import com.seibel.lod.core.dataObjects.fullData.sources.IIncompleteFullDataSource;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataView;
import com.seibel.lod.core.dataObjects.fullData.sources.SparseFullDataSource;
import com.seibel.lod.core.dataObjects.fullData.sources.SpottyFullDataSource;
import com.seibel.lod.core.generation.tasks.IWorldGenTaskTracker;
@@ -218,7 +218,7 @@ public class GeneratedFullDataFileHandler extends FullDataFileHandler
public boolean isMemoryAddressValid() { return this.targetFullDataSourceRef.get() != null; }
@Override
public Consumer<ChunkSizedFullDataView> getOnGenTaskCompleteConsumer()
public Consumer<ChunkSizedFullDataAccessor> getOnGenTaskCompleteConsumer()
{
if (this.loadedTargetFullDataSource == null)
{
@@ -1,7 +1,7 @@
package com.seibel.lod.core.file.fullDatafile;
import com.seibel.lod.core.dataObjects.fullData.sources.IFullDataSource;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataView;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataAccessor;
import com.seibel.lod.core.file.metaData.BaseMetaData;
import com.seibel.lod.core.pos.DhSectionPos;
@@ -17,7 +17,7 @@ public interface IFullDataSourceProvider extends AutoCloseable
void addScannedFile(Collection<File> detectedFiles);
CompletableFuture<IFullDataSource> read(DhSectionPos pos);
void write(DhSectionPos sectionPos, ChunkSizedFullDataView chunkData);
void write(DhSectionPos sectionPos, ChunkSizedFullDataAccessor chunkData);
CompletableFuture<Void> flushAndSave();
//long getCacheVersion(DhSectionPos sectionPos);
@@ -1,7 +1,7 @@
package com.seibel.lod.core.file.renderfile;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataAccessor;
import com.seibel.lod.core.dataObjects.render.ColumnRenderSource;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataView;
import com.seibel.lod.core.pos.DhSectionPos;
import java.io.File;
@@ -18,7 +18,7 @@ public interface ILodRenderSourceProvider extends AutoCloseable
{
CompletableFuture<ColumnRenderSource> readAsync(DhSectionPos pos);
void addScannedFile(Collection<File> detectedFiles);
void writeChunkDataToFile(DhSectionPos sectionPos, ChunkSizedFullDataView chunkData);
void writeChunkDataToFile(DhSectionPos sectionPos, ChunkSizedFullDataAccessor chunkData);
CompletableFuture<Void> flushAndSaveAsync();
/** Returns true if the data was refreshed, false otherwise */
@@ -1,8 +1,8 @@
package com.seibel.lod.core.file.renderfile;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataAccessor;
import com.seibel.lod.core.dataObjects.render.ColumnRenderLoader;
import com.seibel.lod.core.dataObjects.render.ColumnRenderSource;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataView;
import com.seibel.lod.core.file.metaData.BaseMetaData;
import com.seibel.lod.core.level.IDhClientLevel;
import com.seibel.lod.core.level.IDhLevel;
@@ -77,7 +77,7 @@ public class RenderMetaDataFile extends AbstractMetaDataContainerFile
// FIXME: This can cause concurrent modification of LodRenderSource.
// Not sure if it will cause issues or not.
public void updateChunkIfNeeded(ChunkSizedFullDataView chunkDataView, IDhClientLevel level)
public void updateChunkIfNeeded(ChunkSizedFullDataAccessor chunkDataView, IDhClientLevel level)
{
DhLodPos chunkPos = chunkDataView.getLodPos();
LodUtil.assertTrue(this.pos.getSectionBBoxPos().overlapsExactly(chunkPos), "Chunk pos {} doesn't overlap with section {}", chunkPos, pos);
@@ -1,13 +1,12 @@
package com.seibel.lod.core.file.renderfile;
import com.google.common.collect.HashMultimap;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataAccessor;
import com.seibel.lod.core.dataObjects.fullData.sources.IFullDataSource;
import com.seibel.lod.core.dataObjects.render.ColumnRenderSource;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataView;
import com.seibel.lod.core.dataObjects.transformers.DataRenderTransformer;
import com.seibel.lod.core.file.fullDatafile.IFullDataSourceProvider;
import com.seibel.lod.core.level.IDhClientLevel;
import com.seibel.lod.core.pos.DhLodPos;
import com.seibel.lod.core.pos.DhSectionPos;
import com.seibel.lod.core.util.FileUtil;
import com.seibel.lod.core.util.ThreadUtil;
@@ -214,12 +213,12 @@ public class RenderSourceFileHandler implements ILodRenderSourceProvider
* TODO why is there fullData handling in the render file handler?
*/
@Override
public void writeChunkDataToFile(DhSectionPos sectionPos, ChunkSizedFullDataView chunkDataView)
public void writeChunkDataToFile(DhSectionPos sectionPos, ChunkSizedFullDataAccessor chunkDataView)
{
this.writeChunkDataToFileRecursively(sectionPos,chunkDataView);
this.fullDataSourceProvider.write(sectionPos, chunkDataView);
}
private void writeChunkDataToFileRecursively(DhSectionPos sectPos, ChunkSizedFullDataView chunkDataView)
private void writeChunkDataToFileRecursively(DhSectionPos sectPos, ChunkSizedFullDataAccessor chunkDataView)
{
if (!sectPos.getSectionBBoxPos().overlapsExactly(chunkDataView.getLodPos()))
{
@@ -2,9 +2,9 @@ package com.seibel.lod.core.file.subDimMatching;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.dataObjects.fullData.sources.IFullDataSource;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataView;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataAccessor;
import com.seibel.lod.core.util.FullDataPointUtil;
import com.seibel.lod.core.dataObjects.fullData.accessor.SingleFullArrayView;
import com.seibel.lod.core.dataObjects.fullData.accessor.SingleFullDataAccessor;
import com.seibel.lod.core.dataObjects.transformers.LodDataBuilder;
import com.seibel.lod.core.dependencyInjection.SingletonInjector;
import com.seibel.lod.core.file.fullDatafile.FullDataFileHandler;
@@ -165,7 +165,7 @@ public class SubDimensionLevelMatcher implements AutoCloseable
LOGGER.info("Player block pos in dimension: [" + playerData.playerBlockPos.getX() + "," + playerData.playerBlockPos.getY() + "," + playerData.playerBlockPos.getZ() + "]");
// new chunk data
ChunkSizedFullDataView newChunkSizedFullDataView = LodDataBuilder.createChunkData(newlyLoadedChunk);
ChunkSizedFullDataAccessor newChunkSizedFullDataView = LodDataBuilder.createChunkData(newlyLoadedChunk);
long[][][] newChunkData = new long[LodUtil.CHUNK_WIDTH][LodUtil.CHUNK_WIDTH][];
if (newChunkSizedFullDataView != null)
{
@@ -233,7 +233,7 @@ public class SubDimensionLevelMatcher implements AutoCloseable
{
for (int z = 0; z < LodUtil.CHUNK_WIDTH; z++)
{
SingleFullArrayView singleDataColumn = lodDataSource.tryGet(x, z);
SingleFullDataAccessor singleDataColumn = lodDataSource.tryGet(x, z);
if (singleDataColumn != null)
{
long[] rawSingleColumn = singleDataColumn.getRaw();
@@ -3,7 +3,7 @@ package com.seibel.lod.core.generation;
import com.seibel.lod.api.enums.worldGeneration.EDhApiDistantGeneratorMode;
import com.seibel.lod.api.interfaces.override.worldGenerator.IDhApiWorldGenerator;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataView;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataAccessor;
import com.seibel.lod.core.dataObjects.transformers.LodDataBuilder;
import com.seibel.lod.core.dependencyInjection.SingletonInjector;
import com.seibel.lod.core.generation.tasks.*;
@@ -500,7 +500,7 @@ public class WorldGenerationQueue implements Closeable
private static CompletableFuture<Void> startGenerationEvent(IDhApiWorldGenerator worldGenerator,
DhChunkPos chunkPosMin,
byte granularity, byte targetDataDetail,
Consumer<ChunkSizedFullDataView> generationCompleteConsumer)
Consumer<ChunkSizedFullDataAccessor> generationCompleteConsumer)
{
EDhApiDistantGeneratorMode generatorMode = Config.Client.WorldGenerator.distantGeneratorMode.get();
return worldGenerator.generateChunks(chunkPosMin.x, chunkPosMin.z, granularity, targetDataDetail, generatorMode, (objectArray) ->
@@ -1,6 +1,6 @@
package com.seibel.lod.core.generation.tasks;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataView;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataAccessor;
import java.util.function.Consumer;
@@ -13,6 +13,6 @@ public interface IWorldGenTaskTracker
/** Returns true if the task hasn't been garbage collected. */
boolean isMemoryAddressValid();
Consumer<ChunkSizedFullDataView> getOnGenTaskCompleteConsumer();
Consumer<ChunkSizedFullDataAccessor> getOnGenTaskCompleteConsumer();
}
@@ -1,6 +1,6 @@
package com.seibel.lod.core.generation.tasks;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataView;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataAccessor;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;
@@ -52,6 +52,6 @@ public class SplitWorldGenTaskTracker implements IWorldGenTaskTracker
public boolean isMemoryAddressValid() { return this.isValid; }
@Override
public Consumer<ChunkSizedFullDataView> getOnGenTaskCompleteConsumer() { return this.parentTracker.getOnGenTaskCompleteConsumer(); }
public Consumer<ChunkSizedFullDataAccessor> getOnGenTaskCompleteConsumer() { return this.parentTracker.getOnGenTaskCompleteConsumer(); }
}
@@ -1,6 +1,6 @@
package com.seibel.lod.core.generation.tasks;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataView;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataAccessor;
import com.seibel.lod.core.pos.DhLodPos;
import java.util.Iterator;
@@ -28,13 +28,13 @@ public final class WorldGenTaskGroup
public void onGenerationComplete(ChunkSizedFullDataView chunkSizedFullDataView)
public void onGenerationComplete(ChunkSizedFullDataAccessor chunkSizedFullDataView)
{
Iterator<WorldGenTask> tasks = this.worldGenTasks.iterator();
while (tasks.hasNext())
{
WorldGenTask task = tasks.next();
Consumer<ChunkSizedFullDataView> onGenTaskCompleteConsumer = task.taskTracker.getOnGenTaskCompleteConsumer();
Consumer<ChunkSizedFullDataAccessor> onGenTaskCompleteConsumer = task.taskTracker.getOnGenTaskCompleteConsumer();
if (onGenTaskCompleteConsumer == null)
{
tasks.remove();
@@ -1,7 +1,7 @@
package com.seibel.lod.core.level;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataView;
import com.seibel.lod.core.dataObjects.fullData.accessor.ChunkSizedFullDataAccessor;
import com.seibel.lod.core.dataObjects.fullData.sources.CompleteFullDataSource;
import com.seibel.lod.core.dataObjects.transformers.ChunkToLodBuilder;
import com.seibel.lod.core.dependencyInjection.SingletonInjector;
@@ -172,13 +172,13 @@ public abstract class AbstractDhClientLevel implements IDhClientLevel
@Override
public void updateChunkAsync(IChunkWrapper chunk)
{
CompletableFuture<ChunkSizedFullDataView> future = this.chunkToLodBuilder.tryGenerateData(chunk);
CompletableFuture<ChunkSizedFullDataAccessor> future = this.chunkToLodBuilder.tryGenerateData(chunk);
if (future != null)
{
future.thenAccept(this::saveWrites);
}
}
private void saveWrites(ChunkSizedFullDataView data)
private void saveWrites(ChunkSizedFullDataAccessor data)
{
ClientRenderState ClientRenderState = this.ClientRenderStateRef.get();
DhLodPos pos = data.getLodPos().convertToDetailLevel(CompleteFullDataSource.SECTION_SIZE_OFFSET);