Clean up ColumnArrayView
This commit is contained in:
+1
-1
@@ -53,7 +53,7 @@ public enum EDhApiVerticalQuality
|
||||
|
||||
|
||||
|
||||
public int calculateMaxVerticalData(byte dataDetail)
|
||||
public int calculateMaxNumberOfVerticalSlicesAtDetailLevel(byte dataDetail)
|
||||
{
|
||||
// for detail levels lower than what the enum defines, use the lowest quality item
|
||||
int index = MathUtil.clamp(0, dataDetail, this.maxVerticalData.length - 1);
|
||||
|
||||
+29
-17
@@ -19,12 +19,12 @@
|
||||
|
||||
package com.seibel.distanthorizons.core.dataObjects.render;
|
||||
|
||||
import com.seibel.distanthorizons.api.enums.config.EDhApiVerticalQuality;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.core.util.objects.pooling.AbstractPhantomArrayList;
|
||||
import com.seibel.distanthorizons.core.util.objects.pooling.PhantomArrayListPool;
|
||||
import com.seibel.distanthorizons.core.pos.DhSectionPos;
|
||||
import com.seibel.distanthorizons.core.dataObjects.render.columnViews.ColumnArrayView;
|
||||
import com.seibel.distanthorizons.core.dataObjects.render.columnViews.ColumnQuadView;
|
||||
import com.seibel.distanthorizons.core.util.RenderDataPointUtil;
|
||||
import it.unimi.dsi.fastutil.longs.LongArrayList;
|
||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||
@@ -45,8 +45,11 @@ public class ColumnRenderSource extends AbstractPhantomArrayList
|
||||
|
||||
|
||||
|
||||
/** will be zero if an empty data source was created */
|
||||
public int verticalDataCount;
|
||||
/**
|
||||
* will be zero if an empty data source was created
|
||||
* @see EDhApiVerticalQuality#calculateMaxNumberOfVerticalSlicesAtDetailLevel(byte)
|
||||
*/
|
||||
public int maxVerticalSliceCount;
|
||||
public long pos;
|
||||
public int yOffset;
|
||||
|
||||
@@ -59,38 +62,42 @@ public class ColumnRenderSource extends AbstractPhantomArrayList
|
||||
//==============//
|
||||
// constructors //
|
||||
//==============//
|
||||
//region
|
||||
|
||||
public static ColumnRenderSource createEmpty(long pos, int maxVerticalSize, int yOffset)
|
||||
{ return new ColumnRenderSource(pos, maxVerticalSize, yOffset); }
|
||||
public static ColumnRenderSource createEmpty(long pos, int maxVertSliceCount, int yOffset)
|
||||
{ return new ColumnRenderSource(pos, maxVertSliceCount, yOffset); }
|
||||
/**
|
||||
* Creates an empty ColumnRenderSource.
|
||||
*
|
||||
* @param pos the relative position of the container
|
||||
* @param maxVerticalSize the maximum vertical size of the container
|
||||
* @param maxVertSliceCount the maximum vertical size of the container
|
||||
*/
|
||||
private ColumnRenderSource(long pos, int maxVerticalSize, int yOffset)
|
||||
private ColumnRenderSource(long pos, int maxVertSliceCount, int yOffset)
|
||||
{
|
||||
super(ARRAY_LIST_POOL, 0, 0, 1, 0);
|
||||
|
||||
this.pos = pos;
|
||||
this.yOffset = yOffset;
|
||||
|
||||
this.verticalDataCount = maxVerticalSize;
|
||||
this.maxVerticalSliceCount = maxVertSliceCount;
|
||||
|
||||
this.renderDataContainer = this.pooledArraysCheckout.getLongArray(0, WIDTH * WIDTH * this.verticalDataCount);
|
||||
this.renderDataContainer = this.pooledArraysCheckout.getLongArray(0, WIDTH * WIDTH * this.maxVerticalSliceCount);
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
//========================//
|
||||
// datapoint manipulation //
|
||||
//========================//
|
||||
//region
|
||||
|
||||
public long getDataPoint(int posX, int posZ, int verticalIndex) { return this.renderDataContainer.getLong(posX * WIDTH * this.verticalDataCount + posZ * this.verticalDataCount + verticalIndex); }
|
||||
public long getDataPoint(int posX, int posZ, int verticalIndex) { return this.renderDataContainer.getLong(posX * WIDTH * this.maxVerticalSliceCount + posZ * this.maxVerticalSliceCount + verticalIndex); }
|
||||
|
||||
public ColumnArrayView getVerticalDataPointView(int posX, int posZ)
|
||||
{
|
||||
int offset = posX * WIDTH * this.verticalDataCount + posZ * this.verticalDataCount;
|
||||
int offset = posX * WIDTH * this.maxVerticalSliceCount + posZ * this.maxVerticalSliceCount;
|
||||
|
||||
// don't allow returning views that are outside this render source's bounds
|
||||
if (offset >= this.renderDataContainer.size())
|
||||
@@ -103,18 +110,18 @@ public class ColumnRenderSource extends AbstractPhantomArrayList
|
||||
return null;
|
||||
}
|
||||
|
||||
return new ColumnArrayView(this.renderDataContainer, this.verticalDataCount,
|
||||
offset, this.verticalDataCount);
|
||||
return new ColumnArrayView(this.renderDataContainer, this.maxVerticalSliceCount,
|
||||
offset, this.maxVerticalSliceCount);
|
||||
}
|
||||
|
||||
public ColumnQuadView getFullQuadView() { return this.getQuadViewOverRange(0, 0, WIDTH, WIDTH); }
|
||||
public ColumnQuadView getQuadViewOverRange(int quadX, int quadZ, int quadXSize, int quadZSize) { return new ColumnQuadView(this.renderDataContainer, WIDTH, this.verticalDataCount, quadX, quadZ, quadXSize, quadZSize); }
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
//=====================//
|
||||
// data helper methods //
|
||||
//=====================//
|
||||
//region
|
||||
|
||||
public Long getPos() { return this.pos; }
|
||||
public Long getKey() { return this.pos; }
|
||||
@@ -152,11 +159,14 @@ public class ColumnRenderSource extends AbstractPhantomArrayList
|
||||
return false;
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
//==============//
|
||||
// base methods //
|
||||
//==============//
|
||||
//region
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
@@ -174,11 +184,11 @@ public class ColumnRenderSource extends AbstractPhantomArrayList
|
||||
{
|
||||
for (int x = 0; x < size; x++)
|
||||
{
|
||||
for (int y = 0; y < this.verticalDataCount; y++)
|
||||
for (int y = 0; y < this.maxVerticalSliceCount; y++)
|
||||
{
|
||||
//Converting the dataToHex
|
||||
stringBuilder.append(Long.toHexString(this.getDataPoint(x, z, y)));
|
||||
if (y != this.verticalDataCount - 1)
|
||||
if (y != this.maxVerticalSliceCount - 1)
|
||||
stringBuilder.append(SUBDATA_DELIMITER);
|
||||
}
|
||||
|
||||
@@ -192,6 +202,8 @@ public class ColumnRenderSource extends AbstractPhantomArrayList
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -283,7 +283,7 @@ public class ColumnBox
|
||||
short yMax = (short) (yMin + ySize);
|
||||
|
||||
|
||||
int adjCount = adjColumnView.size();
|
||||
int adjCount = adjColumnView.size;
|
||||
|
||||
// Start with the entire range at max light
|
||||
segments.add(YSegmentUtil.encode(yMin, yMax, LodUtil.MAX_MC_LIGHT));
|
||||
|
||||
+3
-3
@@ -117,7 +117,7 @@ public class ColumnRenderBufferBuilder
|
||||
// ignore empty/null columns
|
||||
ColumnArrayView columnRenderData = renderSource.getVerticalDataPointView(relX, relZ);
|
||||
if (columnRenderData == null
|
||||
|| columnRenderData.size() == 0
|
||||
|| columnRenderData.size == 0
|
||||
|| !RenderDataPointUtil.doesDataPointExist(columnRenderData.get(0))
|
||||
|| RenderDataPointUtil.hasZeroHeight(columnRenderData.get(0)))
|
||||
{
|
||||
@@ -244,7 +244,7 @@ public class ColumnRenderBufferBuilder
|
||||
// build this render column //
|
||||
//==========================//
|
||||
|
||||
for (int i = 0; i < columnRenderData.size(); i++)
|
||||
for (int i = 0; i < columnRenderData.size; i++)
|
||||
{
|
||||
// can be uncommented to limit which vertical LOD is generated
|
||||
if (Config.Client.Advanced.Debugging.ColumnBuilderDebugging.columnBuilderDebugEnable.get())
|
||||
@@ -267,7 +267,7 @@ public class ColumnRenderBufferBuilder
|
||||
}
|
||||
|
||||
long topDataPoint = (i - 1) >= 0 ? columnRenderData.get(i - 1) : RenderDataPointUtil.EMPTY_DATA;
|
||||
long bottomDataPoint = (i + 1) < columnRenderData.size() ? columnRenderData.get(i + 1) : RenderDataPointUtil.EMPTY_DATA;
|
||||
long bottomDataPoint = (i + 1) < columnRenderData.size ? columnRenderData.get(i + 1) : RenderDataPointUtil.EMPTY_DATA;
|
||||
|
||||
addRenderDataPointToBuilder(
|
||||
clientLevel, phantomArrayCheckout,
|
||||
|
||||
+41
-91
@@ -20,6 +20,7 @@
|
||||
package com.seibel.distanthorizons.core.dataObjects.render.columnViews;
|
||||
|
||||
|
||||
import com.seibel.distanthorizons.api.enums.config.EDhApiVerticalQuality;
|
||||
import com.seibel.distanthorizons.core.dataObjects.render.ColumnRenderSource;
|
||||
import com.seibel.distanthorizons.core.util.RenderDataPointReducingList;
|
||||
import com.seibel.distanthorizons.core.util.RenderDataPointUtil;
|
||||
@@ -28,20 +29,21 @@ import it.unimi.dsi.fastutil.longs.LongArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.ConcurrentModificationException;
|
||||
|
||||
public final class ColumnArrayView implements IColumnDataView
|
||||
public final class ColumnArrayView
|
||||
{
|
||||
public final LongArrayList data;
|
||||
|
||||
/**
|
||||
* How many data points are currently being represented by this view. <br>
|
||||
* Will be equal to or less than {@link ColumnArrayView#verticalSize}.
|
||||
* Will be equal to or less than {@link ColumnArrayView#maxVerticalSliceCount}.
|
||||
*/
|
||||
public final int size;
|
||||
/**
|
||||
* Vertical size in data points. <Br>
|
||||
* Can be 0 if this column was created for an empty data source.
|
||||
* @see EDhApiVerticalQuality#calculateMaxNumberOfVerticalSlicesAtDetailLevel(byte)
|
||||
*/
|
||||
public final int verticalSize;
|
||||
public final int maxVerticalSliceCount;
|
||||
|
||||
/**
|
||||
* Where the relative starting index is in the {@link ColumnArrayView#data} array
|
||||
@@ -54,14 +56,15 @@ public final class ColumnArrayView implements IColumnDataView
|
||||
//=============//
|
||||
// constructor //
|
||||
//=============//
|
||||
//region
|
||||
|
||||
/** @throws IllegalArgumentException if the offset is greater than the data's size */
|
||||
public ColumnArrayView(LongArrayList data, int size, int offset, int verticalSize) throws IllegalArgumentException
|
||||
public ColumnArrayView(LongArrayList data, int size, int offset, int maxVerticalSliceCount) throws IllegalArgumentException
|
||||
{
|
||||
this.data = data;
|
||||
this.size = size;
|
||||
this.offset = offset;
|
||||
this.verticalSize = verticalSize;
|
||||
this.maxVerticalSliceCount = maxVerticalSliceCount;
|
||||
|
||||
if (this.data.size() < this.offset)
|
||||
{
|
||||
@@ -69,13 +72,15 @@ public final class ColumnArrayView implements IColumnDataView
|
||||
}
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
//=====================//
|
||||
// getters and setters //
|
||||
//=====================//
|
||||
//region
|
||||
|
||||
@Override
|
||||
public long get(int index)
|
||||
{
|
||||
try
|
||||
@@ -90,99 +95,59 @@ public final class ColumnArrayView implements IColumnDataView
|
||||
throw new ConcurrentModificationException("Potential concurrent modification detected. Make sure the parent ColumnRenderSource isn't being closed before the ColumnArrayView processing is complete.", e);
|
||||
}
|
||||
}
|
||||
public void set(int index, long value) { data.set(index + offset, value); }
|
||||
public void set(int index, long value) { this.data.set(index + this.offset, value); }
|
||||
|
||||
@Override
|
||||
public int size() { return size; }
|
||||
@Override
|
||||
public int verticalSize() { return verticalSize; }
|
||||
/** can be used to determine sub-view starting indexes */
|
||||
public int subViewCount() { return (this.maxVerticalSliceCount != 0) ? (this.size / this.maxVerticalSliceCount) : 0; }
|
||||
|
||||
@Override
|
||||
public int dataCount() { return (this.verticalSize != 0) ? (this.size / this.verticalSize) : 0; } // TODO what does the divide by mean?
|
||||
|
||||
@Override
|
||||
public ColumnArrayView subView(int dataIndexStart, int dataCount)
|
||||
{ return new ColumnArrayView(data, dataCount * verticalSize, offset + dataIndexStart * verticalSize, verticalSize); }
|
||||
{ return new ColumnArrayView(this.data, dataCount * this.maxVerticalSliceCount, this.offset + dataIndexStart * this.maxVerticalSliceCount, this.maxVerticalSliceCount); }
|
||||
|
||||
public void fill(long value) { Arrays.fill(data.elements(), offset, offset + size, value); }
|
||||
public void fill(long value) { Arrays.fill(this.data.elements(), this.offset, this.offset + this.size, value); }
|
||||
|
||||
public void copyFrom(IColumnDataView source) { copyFrom(source, 0); }
|
||||
public void copyFrom(IColumnDataView source, int outputDataIndexOffset)
|
||||
public void copyFrom(ColumnArrayView source) { this.copyFrom(source, 0); }
|
||||
public void copyFrom(ColumnArrayView source, int outputDataIndexOffset)
|
||||
{
|
||||
if (source.verticalSize() > verticalSize)
|
||||
if (source.maxVerticalSliceCount > this.maxVerticalSliceCount)
|
||||
{
|
||||
throw new IllegalArgumentException("source verticalSize must be <= self's verticalSize to copy");
|
||||
}
|
||||
else if (source.dataCount() + outputDataIndexOffset > dataCount())
|
||||
else if (source.subViewCount() + outputDataIndexOffset > this.subViewCount())
|
||||
{
|
||||
throw new IllegalArgumentException("dataIndexStart + source.dataCount() must be <= self.dataCount() to copy");
|
||||
}
|
||||
else if (source.verticalSize() != verticalSize)
|
||||
else if (source.maxVerticalSliceCount != this.maxVerticalSliceCount)
|
||||
{
|
||||
for (int i = 0; i < source.dataCount(); i++)
|
||||
for (int i = 0; i < source.subViewCount(); i++)
|
||||
{
|
||||
int outputOffset = offset + outputDataIndexOffset * verticalSize + i * verticalSize;
|
||||
source.subView(i, 1).copyTo(data.elements(), outputOffset, source.verticalSize());
|
||||
Arrays.fill(data.elements(), outputOffset + source.verticalSize(),
|
||||
outputOffset + verticalSize, 0);
|
||||
int outputOffset = this.offset + (outputDataIndexOffset * this.maxVerticalSliceCount) + (i * this.maxVerticalSliceCount);
|
||||
source.subView(i, 1).copyTo(this.data.elements(), outputOffset, source.maxVerticalSliceCount);
|
||||
Arrays.fill(this.data.elements(), outputOffset + source.maxVerticalSliceCount,
|
||||
outputOffset + this.maxVerticalSliceCount, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
source.copyTo(data.elements(), offset + outputDataIndexOffset * verticalSize, source.size());
|
||||
source.copyTo(this.data.elements(), this.offset + outputDataIndexOffset * this.maxVerticalSliceCount, source.size);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyTo(long[] target, int offset, int size) { System.arraycopy(data.elements(), this.offset, target, offset, size); }
|
||||
public void copyTo(long[] target, int offset, int size) { System.arraycopy(this.data.elements(), this.offset, target, offset, size); }
|
||||
|
||||
public boolean mergeWith(ColumnArrayView source, boolean override)
|
||||
public void changeVerticalSizeFrom(ColumnArrayView source)
|
||||
{
|
||||
if (size != source.size)
|
||||
{
|
||||
throw new IllegalArgumentException("Cannot merge views of different sizes");
|
||||
}
|
||||
if (verticalSize != source.verticalSize)
|
||||
{
|
||||
throw new IllegalArgumentException("Cannot merge views of different vertical sizes");
|
||||
}
|
||||
boolean anyChange = false;
|
||||
for (int o = 0; o < (source.size() * verticalSize); o += verticalSize)
|
||||
{
|
||||
if (override)
|
||||
{
|
||||
if (RenderDataPointUtil.compareDatapointPriority(source.get(o), get(o)) >= 0)
|
||||
{
|
||||
anyChange = true;
|
||||
System.arraycopy(source.data, source.offset + o, data, offset + o, verticalSize);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (RenderDataPointUtil.compareDatapointPriority(source.get(o), get(o)) > 0)
|
||||
{
|
||||
anyChange = true;
|
||||
System.arraycopy(source.data, source.offset + o, data, offset + o, verticalSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
return anyChange;
|
||||
}
|
||||
|
||||
public void changeVerticalSizeFrom(IColumnDataView source)
|
||||
{
|
||||
if (this.dataCount() != source.dataCount())
|
||||
if (this.subViewCount() != source.subViewCount())
|
||||
{
|
||||
throw new IllegalArgumentException("Cannot copy and resize to views with different dataCounts");
|
||||
}
|
||||
|
||||
if (this.verticalSize >= source.verticalSize())
|
||||
if (this.maxVerticalSliceCount >= source.maxVerticalSliceCount)
|
||||
{
|
||||
this.copyFrom(source);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < this.dataCount(); i++)
|
||||
for (int i = 0; i < this.subViewCount(); i++)
|
||||
{
|
||||
mergeMultiData(source.subView(i, 1), this.subView(i, 1));
|
||||
}
|
||||
@@ -194,9 +159,9 @@ public final class ColumnArrayView implements IColumnDataView
|
||||
* @param sourceData one or more columns of data
|
||||
* @param output one column of space for the result to be written to
|
||||
*/
|
||||
private static void mergeMultiData(IColumnDataView sourceData, ColumnArrayView output)
|
||||
private static void mergeMultiData(ColumnArrayView sourceData, ColumnArrayView output)
|
||||
{
|
||||
int target = output.verticalSize();
|
||||
int target = output.maxVerticalSliceCount;
|
||||
if (target <= 0)
|
||||
{
|
||||
// I expect this to never be the case,
|
||||
@@ -207,7 +172,7 @@ public final class ColumnArrayView implements IColumnDataView
|
||||
else if (target == 1)
|
||||
{
|
||||
output.set(0, RenderDataPointReducingList.reduceToOne(sourceData));
|
||||
for (int index = 1, size = output.size(); index < size; index++)
|
||||
for (int index = 1, size = output.size; index < size; index++)
|
||||
{
|
||||
output.set(index, RenderDataPointUtil.EMPTY_DATA);
|
||||
}
|
||||
@@ -216,24 +181,27 @@ public final class ColumnArrayView implements IColumnDataView
|
||||
{
|
||||
try (RenderDataPointReducingList list = new RenderDataPointReducingList(sourceData))
|
||||
{
|
||||
list.reduce(output.verticalSize());
|
||||
list.reduce(output.maxVerticalSliceCount);
|
||||
list.copyTo(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
//================//
|
||||
// base overrides //
|
||||
//================//
|
||||
//region
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("S:").append(this.size);
|
||||
sb.append(" V:").append(this.verticalSize);
|
||||
sb.append(" V:").append(this.maxVerticalSliceCount);
|
||||
sb.append(" O:").append(this.offset);
|
||||
|
||||
sb.append(" [");
|
||||
@@ -250,25 +218,7 @@ public final class ColumnArrayView implements IColumnDataView
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
public int getDataHash() { return arrayHash(this.data, this.offset, this.size); }
|
||||
private static int arrayHash(LongArrayList a, int offset, int length)
|
||||
{
|
||||
if (a == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int result = 1;
|
||||
int end = offset + length;
|
||||
for (int i = offset; i < end; i++)
|
||||
{
|
||||
long element = a.getLong(i);
|
||||
int elementHash = (int) (element ^ (element >>> 32));
|
||||
result = 31 * result + elementHash;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
|
||||
-143
@@ -1,143 +0,0 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod
|
||||
* licensed under the GNU LGPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020 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.render.columnViews;
|
||||
|
||||
import it.unimi.dsi.fastutil.longs.LongArrayList;
|
||||
|
||||
public class ColumnQuadView implements IColumnDataView
|
||||
{
|
||||
private final LongArrayList data;
|
||||
private final int perColumnOffset; // per column (of columns of data) offset in longs
|
||||
private final int xSize; // x size in datapoints
|
||||
private final int zSize; // x size in datapoints
|
||||
private final int offset; // offset in longs
|
||||
private final int vertSize; // vertical size in longs
|
||||
|
||||
public ColumnQuadView(LongArrayList data, int dataZWidth, int dataVertSize, int viewXOffset, int viewZOffset, int xSize, int zSize)
|
||||
{
|
||||
if (viewXOffset + xSize > (data.size() / (dataZWidth * dataVertSize)) || viewZOffset + zSize > dataZWidth)
|
||||
{
|
||||
throw new IllegalArgumentException("View is out of bounds");
|
||||
}
|
||||
|
||||
this.data = data;
|
||||
this.xSize = xSize;
|
||||
this.zSize = zSize;
|
||||
this.vertSize = dataVertSize;
|
||||
this.perColumnOffset = dataZWidth * dataVertSize;
|
||||
this.offset = viewXOffset * perColumnOffset + viewZOffset * dataVertSize;
|
||||
}
|
||||
private ColumnQuadView(LongArrayList data, int perColumnOffset, int offset, int vertSize, int xSize, int zSize)
|
||||
{
|
||||
this.data = data;
|
||||
this.perColumnOffset = perColumnOffset;
|
||||
this.offset = offset;
|
||||
this.vertSize = vertSize;
|
||||
this.xSize = xSize;
|
||||
this.zSize = zSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long get(int index)
|
||||
{
|
||||
int x = index / perColumnOffset;
|
||||
int z = (index % perColumnOffset) / vertSize;
|
||||
int v = index % vertSize;
|
||||
return get(x, z, v);
|
||||
}
|
||||
|
||||
public long get(int x, int z, int v)
|
||||
{
|
||||
return data.getLong(offset + x * perColumnOffset + z * vertSize + v);
|
||||
}
|
||||
|
||||
public long set(int x, int z, int v, long value)
|
||||
{
|
||||
return data.set(offset + x * perColumnOffset + z * vertSize + v, value);
|
||||
}
|
||||
|
||||
public ColumnArrayView get(int x, int z)
|
||||
{
|
||||
return new ColumnArrayView(data, vertSize, offset + x * perColumnOffset + z * vertSize, vertSize);
|
||||
}
|
||||
|
||||
public ColumnArrayView getRow(int x)
|
||||
{
|
||||
return new ColumnArrayView(data, zSize * vertSize, offset + x * perColumnOffset, vertSize);
|
||||
}
|
||||
|
||||
public void set(int x, int z, IColumnDataView singleColumn)
|
||||
{
|
||||
if (singleColumn.verticalSize() != vertSize) throw new IllegalArgumentException("Vertical size of singleColumn must be equal to vertSize");
|
||||
if (singleColumn.dataCount() != 1) throw new IllegalArgumentException("SingleColumn must contain exactly one data point");
|
||||
singleColumn.copyTo(data.elements(), offset + x * perColumnOffset + z * vertSize, singleColumn.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size()
|
||||
{
|
||||
return xSize * zSize * vertSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int verticalSize()
|
||||
{
|
||||
return vertSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int dataCount()
|
||||
{
|
||||
return xSize * zSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IColumnDataView subView(int dataIndexStart, int dataCount)
|
||||
{
|
||||
if (dataCount != 1) throw new UnsupportedOperationException("Fixme: subView for QUadView only support one data point!");
|
||||
int x = dataIndexStart / xSize;
|
||||
int z = dataIndexStart % xSize;
|
||||
return new ColumnArrayView(data, vertSize * dataCount, offset + x * perColumnOffset + z * vertSize, vertSize);
|
||||
}
|
||||
|
||||
public ColumnQuadView subView(int xOffset, int zOffset, int xSize, int zSize)
|
||||
{
|
||||
if (xOffset + xSize > this.xSize || zOffset + zSize > this.zSize) throw new IllegalArgumentException("SubView is out of bounds");
|
||||
return new ColumnQuadView(data, perColumnOffset, offset + xOffset * perColumnOffset + zOffset * vertSize, vertSize, xSize, zSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyTo(long[] target, int offset, int size)
|
||||
{
|
||||
if (size != this.size() && size > zSize * vertSize) throw new UnsupportedOperationException("Not supported yet");
|
||||
if (size <= xSize * vertSize)
|
||||
{
|
||||
System.arraycopy(data, this.offset, target, offset, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int x = 0; x < xSize; x++)
|
||||
{
|
||||
System.arraycopy(data, this.offset + x * perColumnOffset, target, offset + x * xSize * vertSize, xSize * vertSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
-59
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod
|
||||
* licensed under the GNU LGPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020 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.render.columnViews;
|
||||
|
||||
import it.unimi.dsi.fastutil.longs.LongIterator;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
public interface IColumnDataView
|
||||
{
|
||||
long get(int index);
|
||||
|
||||
// FIXME probably horizontal size in blocks?
|
||||
int size();
|
||||
|
||||
default LongIterator iterator()
|
||||
{
|
||||
return new LongIterator()
|
||||
{
|
||||
private int index = 0;
|
||||
private final int size = IColumnDataView.this.size();
|
||||
|
||||
@Override
|
||||
public boolean hasNext() { return this.index < this.size; }
|
||||
|
||||
@Override
|
||||
public long nextLong() { return IColumnDataView.this.get(this.index++); }
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
// FIXME measured in blocks?
|
||||
int verticalSize();
|
||||
|
||||
// FIXME how many datapoints in this LOD?
|
||||
int dataCount();
|
||||
|
||||
IColumnDataView subView(int dataIndexStart, int dataCount);
|
||||
|
||||
void copyTo(long[] target, int offset, int count);
|
||||
|
||||
}
|
||||
+3
-3
@@ -108,11 +108,11 @@ public class FullDataToRenderDataTransformer
|
||||
final long pos = fullDataSource.getPos();
|
||||
final byte dataDetail = fullDataSource.getDataDetailLevel();
|
||||
|
||||
final int vertSize = Config.Client.Advanced.Graphics.Quality.verticalQuality.get().calculateMaxVerticalData(fullDataSource.getDataDetailLevel());
|
||||
final int maxVertSliceCount = Config.Client.Advanced.Graphics.Quality.verticalQuality.get().calculateMaxNumberOfVerticalSlicesAtDetailLevel(fullDataSource.getDataDetailLevel());
|
||||
|
||||
|
||||
|
||||
final ColumnRenderSource columnSource = ColumnRenderSource.createEmpty(pos, vertSize, levelWrapper.getMinHeight());
|
||||
final ColumnRenderSource columnSource = ColumnRenderSource.createEmpty(pos, maxVertSliceCount, levelWrapper.getMinHeight());
|
||||
if (fullDataSource.isEmpty)
|
||||
{
|
||||
return columnSource;
|
||||
@@ -155,7 +155,7 @@ public class FullDataToRenderDataTransformer
|
||||
}
|
||||
|
||||
int fullDataLength = fullDataColumn.size();
|
||||
if (fullDataLength <= columnArrayView.verticalSize())
|
||||
if (fullDataLength <= columnArrayView.maxVerticalSliceCount)
|
||||
{
|
||||
// Directly use the arrayView since it fits.
|
||||
setRenderColumnView(levelWrapper, fullDataSource, blockX, blockZ, columnArrayView, fullDataColumn);
|
||||
|
||||
+5
-6
@@ -21,7 +21,6 @@ package com.seibel.distanthorizons.core.util;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.seibel.distanthorizons.core.dataObjects.render.columnViews.ColumnArrayView;
|
||||
import com.seibel.distanthorizons.core.dataObjects.render.columnViews.IColumnDataView;
|
||||
import com.seibel.distanthorizons.core.util.objects.pooling.AbstractPhantomArrayList;
|
||||
import com.seibel.distanthorizons.core.util.objects.pooling.PhantomArrayListPool;
|
||||
import com.seibel.distanthorizons.core.util.LodUtil.AssertFailureException;
|
||||
@@ -121,11 +120,11 @@ public class RenderDataPointReducingList extends AbstractPhantomArrayList
|
||||
// constructor //
|
||||
//=============//
|
||||
|
||||
public RenderDataPointReducingList(IColumnDataView view)
|
||||
public RenderDataPointReducingList(ColumnArrayView view)
|
||||
{
|
||||
super(ARRAY_LIST_POOL, 0, 1, 2, 0);
|
||||
|
||||
int size = view.size();
|
||||
int size = view.size;
|
||||
if (size == 0)
|
||||
{
|
||||
this.setLowest(NULL);
|
||||
@@ -834,9 +833,9 @@ public class RenderDataPointReducingList extends AbstractPhantomArrayList
|
||||
*
|
||||
* @implNote this method does not allocate any objects.
|
||||
*/
|
||||
public static long reduceToOne(IColumnDataView view)
|
||||
public static long reduceToOne(ColumnArrayView view)
|
||||
{
|
||||
int size = view.size();
|
||||
int size = view.size;
|
||||
if (size <= 0)
|
||||
{
|
||||
return RenderDataPointUtil.EMPTY_DATA;
|
||||
@@ -902,7 +901,7 @@ public class RenderDataPointReducingList extends AbstractPhantomArrayList
|
||||
view.set(writeIndex++, RenderDataPointUtil.EMPTY_DATA);
|
||||
}
|
||||
|
||||
for (int size = view.size(); writeIndex < size; writeIndex++)
|
||||
for (int size = view.size; writeIndex < size; writeIndex++)
|
||||
{
|
||||
view.set(writeIndex, RenderDataPointUtil.EMPTY_DATA);
|
||||
}
|
||||
|
||||
@@ -20,9 +20,6 @@
|
||||
package com.seibel.distanthorizons.core.util;
|
||||
|
||||
import com.seibel.distanthorizons.api.enums.rendering.EDhApiBlockMaterial;
|
||||
import com.seibel.distanthorizons.core.level.AbstractDhLevel;
|
||||
import com.seibel.distanthorizons.core.dataObjects.render.columnViews.ColumnArrayView;
|
||||
import com.seibel.distanthorizons.core.dataObjects.render.columnViews.IColumnDataView;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||
|
||||
Reference in New Issue
Block a user