minor render data bugfix
This commit is contained in:
+8
-10
@@ -71,7 +71,7 @@ public class ColumnRenderSource implements IDataSource<IDhClientLevel>
|
||||
public static final int NO_DATA_FLAG_BYTE = 0x00000001;
|
||||
|
||||
|
||||
|
||||
/** will be zero if an empty data source was created */
|
||||
public int verticalDataCount;
|
||||
public final DhSectionPos sectionPos;
|
||||
public final int yOffset;
|
||||
@@ -290,12 +290,12 @@ public class ColumnRenderSource implements IDataSource<IDhClientLevel>
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(NewFullDataSource inputDataSource, IDhClientLevel level)
|
||||
public boolean update(NewFullDataSource inputFullDataSource, IDhClientLevel level)
|
||||
{
|
||||
final String errorMessagePrefix = "Unable to complete update for RenderSource pos: [" + this.sectionPos + "] and pos: [" + inputDataSource.getSectionPos() + "]. Error:";
|
||||
final String errorMessagePrefix = "Unable to complete update for RenderSource pos: [" + this.sectionPos + "] and pos: [" + inputFullDataSource.getSectionPos() + "]. Error:";
|
||||
|
||||
boolean dataChanged = false;
|
||||
if (inputDataSource.getSectionPos().getDetailLevel() == this.sectionPos.getDetailLevel())
|
||||
if (inputFullDataSource.getSectionPos().getDetailLevel() == this.sectionPos.getDetailLevel())
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -307,8 +307,8 @@ public class ColumnRenderSource implements IDataSource<IDhClientLevel>
|
||||
|
||||
|
||||
|
||||
DhBlockPos2D centerBlockPos = inputDataSource.getSectionPos().getCenterBlockPos();
|
||||
int halfBlockWidth = inputDataSource.getSectionPos().getBlockWidth() / 2;
|
||||
DhBlockPos2D centerBlockPos = inputFullDataSource.getSectionPos().getCenterBlockPos();
|
||||
int halfBlockWidth = inputFullDataSource.getSectionPos().getBlockWidth() / 2;
|
||||
DhBlockPos2D minBlockPos = new DhBlockPos2D(centerBlockPos.x - halfBlockWidth, centerBlockPos.z - halfBlockWidth);
|
||||
|
||||
for (int x = 0; x < NewFullDataSource.WIDTH; x++)
|
||||
@@ -318,8 +318,8 @@ public class ColumnRenderSource implements IDataSource<IDhClientLevel>
|
||||
ColumnArrayView columnArrayView = this.getVerticalDataPointView(x, z);
|
||||
int columnHash = columnArrayView.getDataHash();
|
||||
|
||||
SingleColumnFullDataAccessor fullArrayView = inputDataSource.get(x, z);
|
||||
EDhApiWorldGenerationStep worldGenStep = inputDataSource.getWorldGenStepAtRelativePos(x, z);
|
||||
SingleColumnFullDataAccessor fullArrayView = inputFullDataSource.get(x, z);
|
||||
EDhApiWorldGenerationStep worldGenStep = inputFullDataSource.getWorldGenStepAtRelativePos(x, z);
|
||||
if (fullArrayView != null && worldGenStep != EDhApiWorldGenerationStep.EMPTY)
|
||||
{
|
||||
FullDataToRenderDataTransformer.convertColumnData(level,
|
||||
@@ -339,8 +339,6 @@ public class ColumnRenderSource implements IDataSource<IDhClientLevel>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (dataChanged)
|
||||
{
|
||||
this.localVersion.incrementAndGet();
|
||||
|
||||
+7
-5
@@ -29,6 +29,7 @@ public final class ColumnArrayView implements IColumnDataView
|
||||
public final long[] data;
|
||||
public final int size;
|
||||
public final int offset; // offset in longs
|
||||
/** can be 0 if this column was created for an empty data source */
|
||||
public final int vertSize; // vertical size in longs
|
||||
|
||||
|
||||
@@ -55,7 +56,7 @@ public final class ColumnArrayView implements IColumnDataView
|
||||
public int verticalSize() { return vertSize; }
|
||||
|
||||
@Override
|
||||
public int dataCount() { return size / vertSize; }
|
||||
public int dataCount() { return (this.vertSize != 0) ? (this.size / this.vertSize) : 0; }
|
||||
|
||||
@Override
|
||||
public ColumnArrayView subView(int dataIndexStart, int dataCount)
|
||||
@@ -130,17 +131,18 @@ public final class ColumnArrayView implements IColumnDataView
|
||||
|
||||
public void changeVerticalSizeFrom(IColumnDataView source)
|
||||
{
|
||||
if (dataCount() != source.dataCount())
|
||||
if (this.dataCount() != source.dataCount())
|
||||
{
|
||||
throw new IllegalArgumentException("Cannot copy and resize to views with different dataCounts");
|
||||
}
|
||||
if (vertSize >= source.verticalSize())
|
||||
|
||||
if (this.vertSize >= source.verticalSize())
|
||||
{
|
||||
copyFrom(source);
|
||||
this.copyFrom(source);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < dataCount(); i++)
|
||||
for (int i = 0; i < this.dataCount(); i++)
|
||||
{
|
||||
RenderDataPointUtil.mergeMultiData(source.subView(i, 1), subView(i, 1));
|
||||
}
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ public class FullDataToRenderDataTransformer
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else if (MC.getWrappedClientLevel() == null)
|
||||
else if (level == null)
|
||||
{
|
||||
// if the client is no longer loaded in the world, render sources cannot be created
|
||||
return null;
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.core.file.AbstractNewDataSourceHandler;
|
||||
import com.seibel.distanthorizons.core.file.fullDatafile.IFullDataSourceProvider;
|
||||
import com.seibel.distanthorizons.core.file.fullDatafile.NewFullDataFileHandler;
|
||||
import com.seibel.distanthorizons.core.file.renderfile.IRenderSourceProvider;
|
||||
import com.seibel.distanthorizons.core.file.renderfile.RenderSourceFileHandler;
|
||||
import com.seibel.distanthorizons.core.file.structure.AbstractSaveStructure;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
@@ -49,8 +50,12 @@ public class ClientLevelModule implements Closeable, AbstractNewDataSourceHandle
|
||||
{
|
||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
|
||||
private static final IMinecraftClientWrapper MC_CLIENT = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
|
||||
|
||||
private final IDhClientLevel parentClientLevel;
|
||||
|
||||
public final NewFullDataFileHandler fullDataSourceProvider;
|
||||
public final AtomicReference<ClientRenderState> ClientRenderStateRef = new AtomicReference<>();
|
||||
|
||||
public final F3Screen.NestedMessage f3Message;
|
||||
|
||||
|
||||
@@ -64,8 +69,8 @@ public class ClientLevelModule implements Closeable, AbstractNewDataSourceHandle
|
||||
this.parentClientLevel = parentClientLevel;
|
||||
this.f3Message = new F3Screen.NestedMessage(this::f3Log);
|
||||
|
||||
NewFullDataFileHandler fileHandler = this.parentClientLevel.getFullDataProvider();
|
||||
fileHandler.dateSourceUpdateListeners.add(this);
|
||||
this.fullDataSourceProvider = this.parentClientLevel.getFullDataProvider();
|
||||
this.fullDataSourceProvider.dateSourceUpdateListeners.add(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -137,7 +142,7 @@ public class ClientLevelModule implements Closeable, AbstractNewDataSourceHandle
|
||||
/** @return if the {@link ClientRenderState} was successfully swapped */
|
||||
public boolean startRenderer(IClientLevelWrapper clientLevelWrapper)
|
||||
{
|
||||
ClientRenderState ClientRenderState = new ClientRenderState(parentClientLevel, clientLevelWrapper, parentClientLevel.getFullDataProvider(), parentClientLevel.getSaveStructure());
|
||||
ClientRenderState ClientRenderState = new ClientRenderState(this.parentClientLevel, clientLevelWrapper, this.parentClientLevel.getFullDataProvider(), this.parentClientLevel.getSaveStructure());
|
||||
if (!this.ClientRenderStateRef.compareAndSet(null, ClientRenderState))
|
||||
{
|
||||
LOGGER.warn("Failed to start renderer due to concurrency");
|
||||
@@ -208,6 +213,7 @@ public class ClientLevelModule implements Closeable, AbstractNewDataSourceHandle
|
||||
@Override
|
||||
public void OnDataSourceUpdated(NewFullDataSource updatedFullDataSource)
|
||||
{
|
||||
// if rendering also update the render sources
|
||||
ClientRenderState ClientRenderState = this.ClientRenderStateRef.get();
|
||||
if (ClientRenderState != null)
|
||||
{
|
||||
@@ -240,6 +246,8 @@ public class ClientLevelModule implements Closeable, AbstractNewDataSourceHandle
|
||||
}
|
||||
}
|
||||
|
||||
this.fullDataSourceProvider.dateSourceUpdateListeners.remove(this);
|
||||
|
||||
this.f3Message.close();
|
||||
}
|
||||
|
||||
@@ -252,7 +260,7 @@ public class ClientLevelModule implements Closeable, AbstractNewDataSourceHandle
|
||||
/** Returns what should be displayed in Minecraft's F3 debug menu */
|
||||
protected String[] f3Log()
|
||||
{
|
||||
String dimName = parentClientLevel.getClientLevelWrapper().getDimensionType().getDimensionName();
|
||||
String dimName = this.parentClientLevel.getClientLevelWrapper().getDimensionType().getDimensionName();
|
||||
ClientRenderState renderState = this.ClientRenderStateRef.get();
|
||||
if (renderState == null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user