diff --git a/core/src/main/java/com/seibel/lod/core/datatype/column/accessor/IColumnDatatype.java b/core/src/main/java/com/seibel/lod/core/datatype/column/accessor/IColumnDatatype.java deleted file mode 100644 index 7ba6036e6..000000000 --- a/core/src/main/java/com/seibel/lod/core/datatype/column/accessor/IColumnDatatype.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.seibel.lod.core.datatype.column.accessor; - -public interface IColumnDatatype -{ - byte getDetailOffset(); - - default int getDataSize() - { - return 1 << getDetailOffset(); - } - - /** Returns how many LODs could be contained by this object. */ - int getMaxLodCount(); - - long getRoughRamUsageInBytes(); - - int getVerticalSize(); - - boolean doesDataPointExist(int posX, int posZ); - - /** Returns the datapoint for the given relative coordinates and vertical index */ - long getDataPoint(int posX, int posZ, int verticalIndex); - /** - * Returns the top datapoint for the given relative coordinates
- * Returns the empty datapoint if no data is present. - */ - default long getFirstDataPoint(int posX, int posZ) { return getDataPoint(posX, posZ, 0); } - - /** Returns every datapoint in the vertical slice at the given position as an array */ - long[] getVerticalDataPointArray(int posX, int posZ); - /** Returns every datapoint in the vertical slice at the given position as a ColumnArrayView */ - ColumnArrayView getVerticalDataPointView(int posX, int posZ); - - /** Returns a QuadView that covers this whole object */ - ColumnQuadView getFullQuadView(); - /** Returns a QuadView over the give coordinate range */ - ColumnQuadView getQuadViewOverRange(int quadX, int quadZ, int quadXSize, int quadZSize); - - /** clears the datapoint stored at the relative position */ - void clearDataPoint(int posX, int posZ); - - /** - * adds/sets the given datapoint at the relative position and vertical index - * @return true if the datapoint was added/set - */ - boolean setDataPoint(long data, int posX, int posZ, int verticalIndex); - - /** - * This methods will add the data in the given position if certain condition are satisfied - * @param overwriteDataWithSameGenerationMode if false old data will only be overwritten if it was generated with a lower priority than the newData - * @return true if the newData was successfully added, false otherwise - */ - boolean copyVerticalData(IColumnDataView newData, int posX, int posZ, boolean overwriteDataWithSameGenerationMode); - - void generateData(IColumnDatatype lowerDataContainer, int posX, int posZ); - -} diff --git a/core/src/main/java/com/seibel/lod/core/datatype/render/ColumnRenderLoader.java b/core/src/main/java/com/seibel/lod/core/datatype/render/ColumnRenderLoader.java index 1184c03fd..d72d77cb8 100644 --- a/core/src/main/java/com/seibel/lod/core/datatype/render/ColumnRenderLoader.java +++ b/core/src/main/java/com/seibel/lod/core/datatype/render/ColumnRenderLoader.java @@ -31,7 +31,7 @@ public class ColumnRenderLoader extends AbstractRenderSourceLoader public ColumnRenderLoader() { - super(ColumnRenderSource.class, ColumnRenderSource.TYPE_ID, new byte[]{ ColumnRenderSource.LATEST_VERSION }, ColumnRenderSource.SECTION_SIZE_OFFSET); + super(ColumnRenderSource.class, ColumnRenderSource.TYPE_ID, new byte[]{ ColumnRenderSource.DATA_FORMAT_VERSION }, ColumnRenderSource.SECTION_SIZE_OFFSET); } diff --git a/core/src/main/java/com/seibel/lod/core/datatype/render/ColumnRenderSource.java b/core/src/main/java/com/seibel/lod/core/datatype/render/ColumnRenderSource.java index 704a25cfb..c42188f5a 100644 --- a/core/src/main/java/com/seibel/lod/core/datatype/render/ColumnRenderSource.java +++ b/core/src/main/java/com/seibel/lod/core/datatype/render/ColumnRenderSource.java @@ -14,6 +14,7 @@ import com.seibel.lod.core.logging.DhLoggerBuilder; import com.seibel.lod.core.level.IDhLevel; import com.seibel.lod.core.render.LodQuadTree; import com.seibel.lod.core.render.LodRenderSection; +import com.seibel.lod.core.util.BitShiftUtil; import com.seibel.lod.core.util.ColorUtil; import com.seibel.lod.core.util.RenderDataPointUtil; import com.seibel.lod.core.util.objects.Reference; @@ -30,17 +31,17 @@ import java.util.concurrent.atomic.AtomicReference; * @author Leetom * @version 2022-2-7 */ -public class ColumnRenderSource implements IColumnDatatype +public class ColumnRenderSource { private static final Logger LOGGER = DhLoggerBuilder.getLogger(); public static final boolean DO_SAFETY_CHECKS = ModInfo.IS_DEV_BUILD; - public static final byte SECTION_SIZE_OFFSET = 6; - public static final int SECTION_SIZE = 1 << SECTION_SIZE_OFFSET; - public static final byte LATEST_VERSION = 1; + public static final byte SECTION_SIZE_OFFSET = DhSectionPos.SECTION_MINIMUM_DETAIL_LEVEL; + public static final int SECTION_SIZE = BitShiftUtil.powerOfTwo(SECTION_SIZE_OFFSET); + public static final byte DATA_FORMAT_VERSION = 1; public static final long TYPE_ID = "ColumnRenderSource".hashCode(); - public static final int AIR_LODS_SIZE = 16; - public static final int AIR_SECTION_SIZE = SECTION_SIZE / AIR_LODS_SIZE; + public static final int AIR_LOD_SIZE = 16; + public static final int AIR_SECTION_SIZE = SECTION_SIZE / AIR_LOD_SIZE; /** * This is the byte put between different sections in the binary save file. @@ -65,7 +66,7 @@ public class ColumnRenderSource implements IColumnDatatype private IDhClientLevel level = null; //FIXME: hack to pass level into tryBuildBuffer - //FIXME: Temp Hack + //FIXME: Temp Hack to prevent swapping buffers too quickly private long lastNs = -1; /** 10 sec */ private static final long SWAP_TIMEOUT = 10_000000000L; @@ -126,23 +127,20 @@ public class ColumnRenderSource implements IColumnDatatype // datapoint manipulation // //========================// - @Override public void clearDataPoint(int posX, int posZ) { for (int verticalIndex = 0; verticalIndex < this.verticalDataCount; verticalIndex++) { - this.dataContainer[posX * SECTION_SIZE * this.verticalDataCount + posZ * this.verticalDataCount + verticalIndex] = ColumnFormatUtil.EMPTY_DATA; + this.dataContainer[posX * SECTION_SIZE * this.verticalDataCount + posZ * this.verticalDataCount + verticalIndex] = RenderDataPointUtil.EMPTY_DATA; } } - @Override public boolean setDataPoint(long data, int posX, int posZ, int verticalIndex) { this.dataContainer[posX * SECTION_SIZE * this.verticalDataCount + posZ * this.verticalDataCount + verticalIndex] = data; return true; } - @Override public boolean copyVerticalData(IColumnDataView newData, int posX, int posZ, boolean overwriteDataWithSameGenerationMode) { if (DO_SAFETY_CHECKS) @@ -178,13 +176,9 @@ public class ColumnRenderSource implements IColumnDatatype } - - // TODO: - - @Override + public long getFirstDataPoint(int posX, int posZ) { return getDataPoint(posX, posZ, 0); } public long getDataPoint(int posX, int posZ, int verticalIndex) { return this.dataContainer[posX * SECTION_SIZE * this.verticalDataCount + posZ * this.verticalDataCount + verticalIndex]; } - @Override public long[] getVerticalDataPointArray(int posX, int posZ) { long[] result = new long[this.verticalDataCount]; @@ -193,7 +187,6 @@ public class ColumnRenderSource implements IColumnDatatype return result; } - @Override public ColumnArrayView getVerticalDataPointView(int posX, int posZ) { return new ColumnArrayView(this.dataContainer, this.verticalDataCount, @@ -201,12 +194,9 @@ public class ColumnRenderSource implements IColumnDatatype this.verticalDataCount); } - @Override public ColumnQuadView getFullQuadView() { return this.getQuadViewOverRange(0, 0, SECTION_SIZE, SECTION_SIZE); } - @Override public ColumnQuadView getQuadViewOverRange(int quadX, int quadZ, int quadXSize, int quadZSize) { return new ColumnQuadView(this.dataContainer, SECTION_SIZE, this.verticalDataCount, quadX, quadZ, quadXSize, quadZSize); } - @Override public int getVerticalSize() { return this.verticalDataCount; } @@ -312,28 +302,24 @@ public class ColumnRenderSource implements IColumnDatatype // data helper methods // //=====================// - @Override - public boolean doesDataPointExist(int posX, int posZ) { return ColumnFormatUtil.doesDataPointExist(this.getFirstDataPoint(posX, posZ)); } + public boolean doesDataPointExist(int posX, int posZ) { return RenderDataPointUtil.doesDataPointExist(this.getFirstDataPoint(posX, posZ)); } - @Override - public void generateData(IColumnDatatype lowerDataContainer, int posX, int posZ) + public void generateData(ColumnRenderSource lowerDataContainer, int posX, int posZ) { ColumnArrayView outputView = this.getVerticalDataPointView(posX, posZ); ColumnQuadView quadView = lowerDataContainer.getQuadViewOverRange(posX * 2, posZ * 2, 2, 2); outputView.mergeMultiDataFrom(quadView); } - @Override public int getMaxLodCount() { return SECTION_SIZE * SECTION_SIZE * this.getVerticalSize(); } - @Override public long getRoughRamUsageInBytes() { return (long) this.dataContainer.length * Long.BYTES; } public DhSectionPos getSectionPos() { return this.sectionPos; } public byte getDataDetail() { return (byte) (this.sectionPos.sectionDetailLevel - SECTION_SIZE_OFFSET); } - @Override + public int getDataSize() { return BitShiftUtil.powerOfTwo(this.getDetailOffset()); } public byte getDetailOffset() { return SECTION_SIZE_OFFSET; } @@ -442,7 +428,7 @@ public class ColumnRenderSource implements IColumnDatatype this.writeData(dos); } - public byte getRenderVersion() { return LATEST_VERSION; } + public byte getRenderVersion() { return DATA_FORMAT_VERSION; } /** Whether this object is still valid. If not, a new one should be created. */ public boolean isValid() { return true; }