Fix N-sized world gen causing holes when moving

This commit is contained in:
James Seibel
2024-10-12 09:53:40 -05:00
parent fd86826325
commit 633ee7f0f9
2 changed files with 49 additions and 13 deletions
@@ -343,7 +343,11 @@ public class LodQuadTree extends QuadTree<LodRenderSection> implements IDebugRen
// prepare this section for rendering
if (!renderSection.gpuUploadInProgress() && renderSection.renderBuffer == null)
if (!renderSection.gpuUploadInProgress()
&& renderSection.renderBuffer == null
// this check is specifically for N-sized world generators where the higher quality
// data source may not exist yet
&& renderSection.getFullDataSourceExists())
{
nodesNeedingLoading.add(renderSection);
}
@@ -417,20 +421,25 @@ public class LodQuadTree extends QuadTree<LodRenderSection> implements IDebugRen
{
// the section only needs to be updated if a buffer is currently present
LodRenderSection renderSection = this.getValue(pos);
if (renderSection != null
&& renderSection.canRender())
if (renderSection != null)
{
if (!renderSection.gpuUploadInProgress())
// this data source may now exist
renderSection.updateFullDataSourceExists();
if (renderSection.canRender())
{
renderSection.uploadRenderDataToGpuAsync();
}
else
{
// if a section is already loading we need to wait to trigger it again
// if we don't trigger it again the LOD will be out of date
// and may be invisible/missing
positionsToRequeue.add(pos);
break;
if (!renderSection.gpuUploadInProgress())
{
renderSection.uploadRenderDataToGpuAsync();
}
else
{
// if a section is already loading we need to wait to trigger it again
// if we don't trigger it again the LOD will be out of date
// and may be invisible/missing
positionsToRequeue.add(pos);
break;
}
}
}
}
@@ -716,4 +725,6 @@ public class LodQuadTree extends QuadTree<LodRenderSection> implements IDebugRen
LOGGER.info("Finished shutting down " + LodQuadTree.class.getSimpleName());
}
}
@@ -104,6 +104,9 @@ public class LodRenderSection implements IDebugRenderable, AutoCloseable
/** should be an empty array if no positions need to be generated */
private LongArrayList missingGenerationPos = null;
private boolean checkedIfFullDataSourceExists = false;
private boolean fullDataSourceExists = false;
//=============//
@@ -429,6 +432,28 @@ public class LodRenderSection implements IDebugRenderable, AutoCloseable
//=================================//
public boolean isFullyGenerated() { return this.missingPositionsCalculated && this.missingGenerationPos.isEmpty(); }
/** Returns true if an LOD exists, regardless of what data is in it */
public boolean getFullDataSourceExists()
{
if (!this.checkedIfFullDataSourceExists)
{
this.fullDataSourceExists = this.fullDataSourceProvider.repo.existsWithKey(this.pos);
this.checkedIfFullDataSourceExists = true;
}
return this.fullDataSourceExists;
}
public void updateFullDataSourceExists()
{
// we don't have any ability to remove LODs so we only
// need to check if an LOD was previously missing
if (!this.fullDataSourceExists)
{
this.checkedIfFullDataSourceExists = false;
this.getFullDataSourceExists();
}
}
public boolean missingPositionsCalculated() { return this.missingPositionsCalculated; }
public int ungeneratedPositionCount() { return (this.missingGenerationPos != null) ? this.missingGenerationPos.size() : 0; }