Remove SingleColumnFullDataAccessor and IFullDataAccessor

This commit is contained in:
James Seibel
2024-03-16 19:16:50 -05:00
parent c081b6c57c
commit 031bf754e8
11 changed files with 59 additions and 410 deletions
@@ -27,7 +27,6 @@ import com.seibel.distanthorizons.api.interfaces.data.IDhApiTerrainDataRepo;
import com.seibel.distanthorizons.api.objects.math.DhApiVec3i;
import com.seibel.distanthorizons.core.api.internal.SharedApi;
import com.seibel.distanthorizons.core.dataObjects.fullData.FullDataPointIdMap;
import com.seibel.distanthorizons.core.dataObjects.fullData.accessor.SingleColumnFullDataAccessor;
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.NewFullDataSource;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import com.seibel.distanthorizons.core.level.IDhLevel;
@@ -221,10 +220,10 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
{
// attempt to get the LOD data from the data source
FullDataPointIdMap mapping = dataSource.getMapping();
SingleColumnFullDataAccessor dataColumn = dataSource.get(relativePos.x, relativePos.z);
long[] dataColumn = dataSource.get(relativePos.x, relativePos.z);
if (dataColumn != null)
{
int dataColumnIndexCount = dataColumn.getSingleLength();
int dataColumnIndexCount = dataColumn.length;
DhApiTerrainDataPoint[] returnArray = new DhApiTerrainDataPoint[dataColumnIndexCount];
long dataPoint;
@@ -235,7 +234,7 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
// search for a datapoint that contains the block y position
for (int i = 0; i < dataColumnIndexCount; i++)
{
dataPoint = dataColumn.getSingle(i);
dataPoint = dataColumn[i];
if (!getSpecificYCoordinate)
{
@@ -20,7 +20,6 @@
package com.seibel.distanthorizons.core.dataObjects.fullData.accessor;
import com.seibel.distanthorizons.core.dataObjects.fullData.FullDataPointIdMap;
import com.seibel.distanthorizons.core.util.FullDataPointUtil;
import com.seibel.distanthorizons.core.util.LodUtil;
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.CompleteFullDataSource;
@@ -30,8 +29,8 @@ import com.seibel.distanthorizons.core.dataObjects.fullData.sources.CompleteFull
*
* @see CompleteFullDataSource
*/
@Deprecated
public class FullDataArrayAccessor implements IFullDataAccessor
@Deprecated // TODO merge into FullDataSourceV1
public class FullDataArrayAccessor
{
protected final FullDataPointIdMap mapping;
@@ -82,92 +81,14 @@ public class FullDataArrayAccessor implements IFullDataAccessor
//=========//
// methods //
//=========//
@Override
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(FullDataArrayAccessor target)
{
if (target.width != this.width)
{
throw new IllegalArgumentException("Target view must have same size as this view");
}
if (target.mapping.equals(this.mapping))
{
for (int x = 0; x < this.width; x++)
{
System.arraycopy(this.dataArrays, this.offset + x * this.dataWidth,
target.dataArrays, target.offset + x * target.dataWidth, this.width);
}
}
else
{
int[] remappedIds = target.mapping.mergeAndReturnRemappedEntityIds(this.mapping);
for (int x = 0; x < this.width; x++)
{
for (int z = 0; z < this.width; z++)
{
long[] currentData = this.dataArrays[this.offset + x * this.dataWidth + z];
// may be null if no data exists for this column yet
if (currentData != null)
{
long[] newData = new long[currentData.length]; // TODO what to do if null?
for (int dataPointIndex = 0; dataPointIndex < newData.length; dataPointIndex++)
{
newData[dataPointIndex] = FullDataPointUtil.remap(remappedIds, currentData[dataPointIndex]);
}
target.dataArrays[target.offset + x * target.dataWidth + z] = newData;
}
}
}
}
}
/**
* Takes a higher detail {@link FullDataArrayAccessor}'s and converts the data to a lower detail level.
*
* @param incomingFullDataAccessor must be larger than this {@link FullDataArrayAccessor} and its width must a power of two larger (example: this.width = 4, other.width = 8)
*/
public void downsampleFrom(FullDataArrayAccessor incomingFullDataAccessor)
{
// validate that the incoming data isn't smaller than this accessor
LodUtil.assertTrue(incomingFullDataAccessor.width >= this.width && incomingFullDataAccessor.width % this.width == 0);
int dataPointsPerWidthUnit = incomingFullDataAccessor.width / this.width;
for (int xOffset = 0; xOffset < this.width; xOffset++)
{
for (int zOffset = 0; zOffset < this.width; zOffset++)
{
FullDataArrayAccessor subView = incomingFullDataAccessor.subView(dataPointsPerWidthUnit,
xOffset * dataPointsPerWidthUnit,
zOffset * dataPointsPerWidthUnit);
SingleColumnFullDataAccessor column = this.get(xOffset, zOffset);
column.downsampleFrom(subView);
}
}
}
//=========//
// getters //
//=========//
@Override
public FullDataPointIdMap getMapping() { return this.mapping; }
@Override
public SingleColumnFullDataAccessor get(int index) { return this.get(index / this.width, index % this.width); }
@Override
public SingleColumnFullDataAccessor get(int relativeX, int relativeZ)
public long[] get(int index) { return this.get(index / this.width, index % this.width); }
public long[] get(int relativeX, int relativeZ)
{
int dataArrayIndex = (relativeX * this.width) + relativeZ + this.offset;
if (dataArrayIndex >= this.dataArrays.length)
@@ -179,10 +100,7 @@ public class FullDataArrayAccessor implements IFullDataAccessor
"dataArrays.length: [" + this.dataArrays.length + "] dataArrayIndex: [" + dataArrayIndex + "].");
}
return new SingleColumnFullDataAccessor(this.mapping, this.dataArrays, dataArrayIndex);
return this.dataArrays[dataArrayIndex];
}
@Override
public int width() { return this.width; }
}
@@ -1,77 +0,0 @@
/*
* This file is part of the Distant Horizons mod
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2023 James Seibel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.core.dataObjects.fullData.accessor;
import com.seibel.distanthorizons.core.dataObjects.fullData.FullDataPointIdMap;
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.CompleteFullDataSource;
import com.seibel.distanthorizons.core.util.LodUtil;
import com.seibel.distanthorizons.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 CompleteFullDataSource}'s.
*
* @see FullDataArrayAccessor
* @see FullDataPointUtil
*/
@Deprecated
public interface IFullDataAccessor
{
FullDataPointIdMap getMapping();
/** generally used for iterating through the whole data set */
SingleColumnFullDataAccessor get(int index);
SingleColumnFullDataAccessor 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<SingleColumnFullDataAccessor> iterator()
{
return new Iterator<SingleColumnFullDataAccessor>()
{
private int index = 0;
private final int size = width() * width();
@Override
public boolean hasNext() { return this.index < this.size; }
@Override
public SingleColumnFullDataAccessor next()
{
LodUtil.assertTrue(this.hasNext(), "No more data to iterate!");
return get(this.index++);
}
};
}
}
@@ -1,182 +0,0 @@
/*
* This file is part of the Distant Horizons mod
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2023 James Seibel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.core.dataObjects.fullData.accessor;
import com.seibel.distanthorizons.core.dataObjects.fullData.FullDataPointIdMap;
import com.seibel.distanthorizons.core.util.FullDataPointUtil;
import com.seibel.distanthorizons.core.util.LodUtil;
/**
* Represents a single column of Full LOD data.
*
* @see FullDataPointUtil
*/
public class SingleColumnFullDataAccessor 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 SingleColumnFullDataAccessor#dataArrays} is used by this accessor */
private final int dataArrayIndex;
private final FullDataPointIdMap mapping;
//=============//
// constructor //
//=============//
public SingleColumnFullDataAccessor(FullDataPointIdMap mapping, long[][] dataArrays, int dataArrayIndex)
{
this.dataArrays = dataArrays;
this.dataArrayIndex = dataArrayIndex;
this.mapping = mapping;
LodUtil.assertTrue(this.dataArrayIndex < this.dataArrays.length, "dataArrays.length [" + this.dataArrays.length + "] is less than the dataArrayIndex [" + this.dataArrayIndex + "].");
}
//=========//
// methods //
//=========//
/** @return true if any data exists in this column. */
public boolean doesColumnExist()
{
long[] dataColumn = this.dataArrays[this.dataArrayIndex];
return dataColumn != null && dataColumn.length != 0;
}
@Override
public FullDataPointIdMap getMapping() { return this.mapping; }
@Override
public SingleColumnFullDataAccessor get(int index)
{
if (index != 0)
{
throw new IllegalArgumentException("Only contains 1 column of full data!");
}
return this;
}
@Override
public SingleColumnFullDataAccessor get(int relativeX, int relativeZ)
{
if (relativeX != 0 || relativeZ != 0)
{
throw new IllegalArgumentException("Only contains 1 column of full data!");
}
return this;
}
/** @return the entire array of raw full data points. */
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 fullDataPoint) { this.dataArrays[this.dataArrayIndex][yIndex] = fullDataPoint; }
public void setNew(long[] newArray) { this.dataArrays[this.dataArrayIndex] = newArray; }
/** @return how many data points are in this column */
public int getSingleLength()
{
long[] singleDataArray = this.dataArrays[this.dataArrayIndex];
return singleDataArray != null ? singleDataArray.length : 0;
}
@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 SingleColumnFullDataAccessor!");
}
return this;
}
/** WARNING: This may potentially share the underlying array objects! */
public void shadowCopyTo(SingleColumnFullDataAccessor 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;
}
}
/** Copies both ID data and mapping data. */
public void deepCopyTo(SingleColumnFullDataAccessor target)
{
if (target.mapping.equals(this.mapping))
{
System.arraycopy(this.dataArrays[this.dataArrayIndex], 0, target.dataArrays[target.dataArrayIndex], 0, this.dataArrays[this.dataArrayIndex].length);
}
else
{
int[] remappedEntryIds = target.mapping.mergeAndReturnRemappedEntityIds(this.mapping);
long[] sourceData = this.dataArrays[this.dataArrayIndex];
// FIXME sourceData.length != 0 may not be a good solution and may end up breaking issues down the line, but fixes exceptions being fired here
if (sourceData != null && sourceData.length != 0)
{
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;
}
}
}
/**
* Replaces this column's data with data from the input {@link IFullDataAccessor}. <br>
* This is used to convert higher detail LOD data to lower detail LOD data.
*/
public void downsampleFrom(IFullDataAccessor source)
{
//TODO: average the data instead of just picking the first column
SingleColumnFullDataAccessor firstColumn = source.get(0);
firstColumn.deepCopyTo(this);
}
}
@@ -21,7 +21,6 @@ package com.seibel.distanthorizons.core.dataObjects.fullData.sources;
import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiWorldGenerationStep;
import com.seibel.distanthorizons.core.dataObjects.fullData.accessor.FullDataArrayAccessor;
import com.seibel.distanthorizons.core.dataObjects.fullData.accessor.SingleColumnFullDataAccessor;
import com.seibel.distanthorizons.core.file.IDataSource;
import com.seibel.distanthorizons.core.level.IDhLevel;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
@@ -42,7 +41,7 @@ import java.util.Arrays;
/**
* This data source contains every datapoint over its given {@link DhSectionPos}.
*
* @see FullDataPointUtil
* @see FullDataPointUtil // FullDataSourceV1
*/
public class CompleteFullDataSource extends FullDataArrayAccessor implements IDataSource<IDhLevel>
{
@@ -246,7 +245,7 @@ public class CompleteFullDataSource extends FullDataArrayAccessor implements IDa
{
for (int z = 0; z < this.width; z++)
{
outputStream.writeInt(this.get(x, z).getSingleLength());
outputStream.writeInt(this.get(x, z).length);
}
}
@@ -258,11 +257,10 @@ public class CompleteFullDataSource extends FullDataArrayAccessor implements IDa
{
for (int z = 0; z < this.width; z++)
{
SingleColumnFullDataAccessor columnAccessor = this.get(x, z);
if (columnAccessor.doesColumnExist())
long[] dataColumn = this.get(x, z);
if (dataColumn != null)
{
long[] dataPointArray = columnAccessor.getRaw();
for (long dataPoint : dataPointArray)
for (long dataPoint : dataColumn)
{
outputStream.writeLong(dataPoint);
}
@@ -21,7 +21,6 @@ package com.seibel.distanthorizons.core.dataObjects.fullData.sources;
import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiWorldGenerationStep;
import com.seibel.distanthorizons.core.dataObjects.fullData.FullDataPointIdMap;
import com.seibel.distanthorizons.core.dataObjects.fullData.accessor.SingleColumnFullDataAccessor;
import com.seibel.distanthorizons.core.dataObjects.transformers.LodDataBuilder;
import com.seibel.distanthorizons.core.file.IDataSource;
import com.seibel.distanthorizons.core.file.fullDatafile.NewFullDataFileHandler;
@@ -147,16 +146,12 @@ public class NewFullDataSource implements IDataSource<IDhLevel>
{
for (int z = 0; z < WIDTH; z++)
{
SingleColumnFullDataAccessor accessor = legacyData.get(x, z);
if (accessor.doesColumnExist())
long[] dataColumn = legacyData.get(x, z);
if (dataColumn != null && dataColumn.length != 0)
{
int index = relativePosToIndex(x, z);
dataPoints[index] = accessor.getRaw();
// reverse the array so index 0 is the lowest,
// this is necessary for later logic
// source: https://stackoverflow.com/questions/2137755/how-do-i-reverse-an-int-array-in-java
long[] dataColumn = dataPoints[index];
for(int i = 0; i < dataColumn.length / 2; i++)
{
long temp = dataColumn[i];
@@ -164,6 +159,9 @@ public class NewFullDataSource implements IDataSource<IDhLevel>
dataColumn[dataColumn.length - i - 1] = temp;
}
int index = relativePosToIndex(x, z);
dataPoints[index] = dataColumn;
// convert the data point format
boolean columnHasNonAirBlock = false;
@@ -212,27 +210,24 @@ public class NewFullDataSource implements IDataSource<IDhLevel>
{
for (int z = 0; z < WIDTH; z++)
{
SingleColumnFullDataAccessor legacyAccessor = legacyData.get(x, z);
if (legacyAccessor.doesColumnExist())
long[] legacyDataColumn = legacyData.get(x, z);
if (legacyDataColumn != null && legacyDataColumn.length != 0)
{
SingleColumnFullDataAccessor newAccessor = newFullDataSource.get(x, z);
long[] newDataColumn = newFullDataSource.get(x, z);
if (newAccessor == null)
if (newDataColumn == null)
{
LodUtil.assertNotReach("Accessor column mismatch");
}
else if (legacyAccessor.getRaw().length != newAccessor.getRaw().length)
else if (legacyDataColumn.length != newDataColumn.length)
{
LodUtil.assertNotReach("Accessor column length mismatch");
}
else
{
long[] legacyRaw = legacyAccessor.getRaw();
long[] newRaw = newAccessor.getRaw();
for (int i = 0; i < legacyRaw.length; i++)
for (int i = 0; i < legacyDataColumn.length; i++)
{
if (legacyRaw[i] != newRaw[i])
if (legacyDataColumn[i] != newDataColumn[i])
{
LodUtil.assertNotReach("Data mismatch");
}
@@ -253,7 +248,7 @@ public class NewFullDataSource implements IDataSource<IDhLevel>
// data //
//======//
public SingleColumnFullDataAccessor get(int relX, int relZ) { return new SingleColumnFullDataAccessor(this.mapping, this.dataPoints, relativePosToIndex(relX, relZ)); }
public long[] get(int relX, int relZ) throws IndexOutOfBoundsException { return this.dataPoints[relativePosToIndex(relX, relZ)]; }
@Override
public boolean update(NewFullDataSource inputDataSource, @Nullable IDhLevel level) { return this.update(inputDataSource); }
@@ -20,7 +20,6 @@
package com.seibel.distanthorizons.core.dataObjects.render;
import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiWorldGenerationStep;
import com.seibel.distanthorizons.core.dataObjects.fullData.accessor.SingleColumnFullDataAccessor;
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.NewFullDataSource;
import com.seibel.distanthorizons.core.dataObjects.transformers.FullDataToRenderDataTransformer;
import com.seibel.distanthorizons.core.file.IDataSource;
@@ -318,14 +317,15 @@ public class ColumnRenderSource implements IDataSource<IDhClientLevel>
ColumnArrayView columnArrayView = this.getVerticalDataPointView(x, z);
int columnHash = columnArrayView.getDataHash();
SingleColumnFullDataAccessor fullArrayView = inputFullDataSource.get(x, z);
long[] dataColumn = inputFullDataSource.get(x, z);
EDhApiWorldGenerationStep worldGenStep = inputFullDataSource.getWorldGenStepAtRelativePos(x, z);
if (fullArrayView != null && worldGenStep != EDhApiWorldGenerationStep.EMPTY)
if (dataColumn != null && worldGenStep != EDhApiWorldGenerationStep.EMPTY)
{
FullDataToRenderDataTransformer.convertColumnData(level,
FullDataToRenderDataTransformer.convertColumnData(
level, inputFullDataSource.getMapping(),
minBlockPos.x + x,
minBlockPos.z + z,
columnArrayView, fullArrayView);
columnArrayView, dataColumn);
dataChanged |= columnHash != columnArrayView.getDataHash();
this.fillDebugFlag(x, z, 1, 1, ColumnRenderSource.DebugSourceFlag.DIRECT);
@@ -22,7 +22,6 @@ package com.seibel.distanthorizons.core.dataObjects.transformers;
import com.seibel.distanthorizons.api.enums.config.EBlocksToAvoid;
import com.seibel.distanthorizons.core.config.Config;
import com.seibel.distanthorizons.core.dataObjects.fullData.FullDataPointIdMap;
import com.seibel.distanthorizons.core.dataObjects.fullData.accessor.SingleColumnFullDataAccessor;
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.NewFullDataSource;
import com.seibel.distanthorizons.core.dataObjects.render.ColumnRenderSource;
import com.seibel.distanthorizons.core.dataObjects.render.columnViews.ColumnArrayView;
@@ -118,8 +117,8 @@ public class FullDataToRenderDataTransformer
throwIfThreadInterrupted();
ColumnArrayView columnArrayView = columnSource.getVerticalDataPointView(x, z);
SingleColumnFullDataAccessor fullArrayView = fullDataSource.get(x, z);
convertColumnData(level, baseX + x, baseZ + z, columnArrayView, fullArrayView);
long[] dataColumn = fullDataSource.get(x, z);
convertColumnData(level, fullDataSource.getMapping(), baseX + x, baseZ + z, columnArrayView, dataColumn);
}
}
@@ -157,14 +156,14 @@ public class FullDataToRenderDataTransformer
// TODO what does this mean?
private static void iterateAndConvert(IDhClientLevel level,
private static void iterateAndConvert(
IDhClientLevel level, FullDataPointIdMap fullDataMapping,
int blockX, int blockZ,
ColumnArrayView column, SingleColumnFullDataAccessor data)
ColumnArrayView renderColumnData, long[] fullColumnData)
{
boolean avoidSolidBlocks = (Config.Client.Advanced.Graphics.Quality.blocksToIgnore.get() == EBlocksToAvoid.NON_COLLIDING);
boolean colorBelowWithAvoidedBlocks = Config.Client.Advanced.Graphics.Quality.tintWithAvoidedBlocks.get();
FullDataPointIdMap fullDataMapping = data.getMapping();
HashSet<IBlockStateWrapper> blockStatesToIgnore = WRAPPER_FACTORY.getRendererIgnoredBlocks(level.getLevelWrapper());
boolean isVoid = true;
@@ -172,9 +171,9 @@ public class FullDataToRenderDataTransformer
int columnOffset = 0;
// goes from the top down
for (int i = 0; i < data.getSingleLength(); i++)
for (int i = 0; i < fullColumnData.length; i++)
{
long fullData = data.getSingle(i);
long fullData = fullColumnData[i];
int bottomY = FullDataPointUtil.getBottomY(fullData);
int blockHeight = FullDataPointUtil.getHeight(fullData);
int id = FullDataPointUtil.getId(fullData);
@@ -259,40 +258,35 @@ public class FullDataToRenderDataTransformer
// add the block
isVoid = false;
long columnData = RenderDataPointUtil.createDataPoint(bottomY + blockHeight, bottomY, color, skyLight, blockLight, block.getIrisBlockMaterialId());
column.set(columnOffset, columnData);
renderColumnData.set(columnOffset, columnData);
columnOffset++;
}
if (isVoid)
{
column.set(0, RenderDataPointUtil.createVoidDataPoint());
renderColumnData.set(0, RenderDataPointUtil.createVoidDataPoint());
}
}
// TODO what does this mean?
public static void convertColumnData(IDhClientLevel level, int blockX, int blockZ, ColumnArrayView columnArrayView, SingleColumnFullDataAccessor fullArrayView)
public static void convertColumnData(IDhClientLevel level, FullDataPointIdMap fullDataMapping, int blockX, int blockZ, ColumnArrayView columnArrayView, long[] fullDataColumn)
{
if (fullArrayView == null || !fullArrayView.doesColumnExist())
{
return;
}
int dataTotalLength = fullArrayView.getSingleLength();
if (dataTotalLength == 0)
if (fullDataColumn == null || fullDataColumn.length == 0)
{
return;
}
int dataTotalLength = fullDataColumn.length;
if (dataTotalLength > columnArrayView.verticalSize())
{
ColumnArrayView totalColumnData = new ColumnArrayView(new long[dataTotalLength], dataTotalLength, 0, dataTotalLength);
iterateAndConvert(level, blockX, blockZ, totalColumnData, fullArrayView);
iterateAndConvert(level, fullDataMapping, blockX, blockZ, totalColumnData, fullDataColumn);
columnArrayView.changeVerticalSizeFrom(totalColumnData);
}
else
{
iterateAndConvert(level, blockX, blockZ, columnArrayView, fullArrayView); //Directly use the arrayView since it fits.
iterateAndConvert(level, fullDataMapping, blockX, blockZ, columnArrayView, fullDataColumn); //Directly use the arrayView since it fits.
}
}
@@ -21,7 +21,6 @@ package com.seibel.distanthorizons.core.file.subDimMatching;
import com.seibel.distanthorizons.core.config.Config;
import com.seibel.distanthorizons.core.dataObjects.fullData.FullDataPointIdMap;
import com.seibel.distanthorizons.core.dataObjects.fullData.accessor.SingleColumnFullDataAccessor;
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.CompleteFullDataSource;
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.NewFullDataSource;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
@@ -234,8 +233,8 @@ public class SubDimensionLevelMatcher implements AutoCloseable
{
for (int z = 0; z < CompleteFullDataSource.WIDTH; z++)
{
SingleColumnFullDataAccessor newColumn = newDataSource.get(x, z);
SingleColumnFullDataAccessor testColumn = testFullDataSource.get(x, z);
long[] newColumn = newDataSource.get(x, z);
long[] testColumn = testFullDataSource.get(x, z);
if (newColumn != null && testColumn != null)
{
@@ -245,11 +244,11 @@ public class SubDimensionLevelMatcher implements AutoCloseable
FullDataPointIdMap testDataMap = testFullDataSource.getMapping();
// use min to prevent going out of bounds
int minColumnIndex = Math.min(newColumn.getSingleLength(), testColumn.getSingleLength());
int minColumnIndex = Math.min(newColumn.length, testColumn.length);
for (int i = 0; i < minColumnIndex; i++)
{
long newDataPoint = newColumn.getSingle(i);
long testDataPoint = testColumn.getSingle(i);
long newDataPoint = newColumn[i];
long testDataPoint = testColumn[i];
int newId = FullDataPointUtil.getId(newDataPoint);
int testId = FullDataPointUtil.getId(testDataPoint);
@@ -298,7 +297,7 @@ public class SubDimensionLevelMatcher implements AutoCloseable
else if (newColumn != null)
{
// missing test column
totalDataPointCount += newColumn.getSingleLength();
totalDataPointCount += newColumn.length;
}
else
{
@@ -19,7 +19,6 @@
package com.seibel.distanthorizons.core.level;
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.CompleteFullDataSource;
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.NewFullDataSource;
import com.seibel.distanthorizons.core.file.fullDatafile.NewFullDataFileHandler;
import com.seibel.distanthorizons.core.file.structure.AbstractSaveStructure;
@@ -154,10 +154,16 @@ public class DhSectionPos
// getters //
//=========//
/** @return the corner with the smallest X and Z coordinate */
/**
* @deprecated use DhSectionPos instead
* @return the corner with the smallest X and Z coordinate
*/
@Deprecated
public DhLodPos getMinCornerLodPos() { return this.getMinCornerLodPos((byte) (this.detailLevel - 1)); }
/** @return the corner with the smallest X and Z coordinate */
/**
* @deprecated use DhSectionPos instead
* @return the corner with the smallest X and Z coordinate
*/
@Deprecated
public DhLodPos getMinCornerLodPos(byte returnDetailLevel)
{