Fix compiling, forgot to move some QuadTree objects

This commit is contained in:
James Seibel
2025-01-10 22:16:11 -06:00
parent 3c1d9f3e3f
commit 14c6707ff9
2 changed files with 15 additions and 12 deletions
@@ -85,7 +85,7 @@ public class LodQuadTree extends QuadTree<LodRenderSection> implements IDebugRen
/** don't let two threads load the same position at the same time */
protected static final KeyedLockContainer<Long> RENDER_LOAD_LOCK_CONTAINER = new KeyedLockContainer<>();
protected final KeyedLockContainer<Long> renderLoadLockContainer = new KeyedLockContainer<>();
/**
* caching is done at the QuadTree level to prevent caching LODs for different levels.
@@ -116,7 +116,7 @@ public class LodQuadTree extends QuadTree<LodRenderSection> implements IDebugRen
ColumnRenderSource renderSource = removalNotification.getValue();
if (renderSource != null)
{
ReentrantLock lock = RENDER_LOAD_LOCK_CONTAINER.getLockForPos(renderSource.getPos());
ReentrantLock lock = renderLoadLockContainer.getLockForPos(renderSource.getPos());
try
{
lock.lock();
@@ -246,7 +246,7 @@ public class LodQuadTree extends QuadTree<LodRenderSection> implements IDebugRen
long rootPos = rootPosIterator.nextLong();
if (this.getNode(rootPos) == null)
{
this.setValue(rootPos, new LodRenderSection(rootPos, this, this.cachedRenderSourceByPos, this.level, this.fullDataSourceProvider));
this.setValue(rootPos, new LodRenderSection(rootPos, this, this.level, this.fullDataSourceProvider, this.cachedRenderSourceByPos, this.renderLoadLockContainer));
}
QuadNode<LodRenderSection> rootNode = this.getNode(rootPos);
@@ -285,7 +285,7 @@ public class LodQuadTree extends QuadTree<LodRenderSection> implements IDebugRen
// create the node
if (quadNode == null && this.isSectionPosInBounds(sectionPos)) // the position bounds should only fail when at the edge of the user's render distance
{
rootNode.setValue(sectionPos, new LodRenderSection(sectionPos, this, this.cachedRenderSourceByPos, this.level, this.fullDataSourceProvider));
rootNode.setValue(sectionPos, new LodRenderSection(sectionPos, this, this.level, this.fullDataSourceProvider, this.cachedRenderSourceByPos, this.renderLoadLockContainer));
quadNode = rootNode.getNode(sectionPos);
}
if (quadNode == null)
@@ -298,7 +298,7 @@ public class LodQuadTree extends QuadTree<LodRenderSection> implements IDebugRen
LodRenderSection renderSection = quadNode.value;
if (renderSection == null)
{
renderSection = new LodRenderSection(sectionPos, this, this.cachedRenderSourceByPos, this.level, this.fullDataSourceProvider);
renderSection = new LodRenderSection(sectionPos, this, this.level, this.fullDataSourceProvider, this.cachedRenderSourceByPos, this.renderLoadLockContainer);
quadNode.setValue(sectionPos, renderSection);
}
@@ -21,9 +21,6 @@ package com.seibel.distanthorizons.core.render;
import com.google.common.base.Suppliers;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.RemovalCause;
import com.google.common.cache.RemovalNotification;
import com.seibel.distanthorizons.core.config.Config;
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2;
import com.seibel.distanthorizons.core.dataObjects.render.ColumnRenderSource;
@@ -74,6 +71,7 @@ public class LodRenderSection implements IDebugRenderable, AutoCloseable
private final FullDataSourceProviderV2 fullDataSourceProvider;
private final LodQuadTree quadTree;
private final Cache<Long, ColumnRenderSource> cachedRenderSourceByPos;
private final KeyedLockContainer<Long> renderLoadLockContainer;
@@ -115,11 +113,16 @@ public class LodRenderSection implements IDebugRenderable, AutoCloseable
// constructor //
//=============//
public LodRenderSection(long pos, LodQuadTree quadTree, Cache<Long, ColumnRenderSource> cachedRenderSourceByPos, IDhClientLevel level, FullDataSourceProviderV2 fullDataSourceProvider)
public LodRenderSection(
long pos,
LodQuadTree quadTree,
IDhClientLevel level, FullDataSourceProviderV2 fullDataSourceProvider,
Cache<Long, ColumnRenderSource> cachedRenderSourceByPos, KeyedLockContainer<Long> renderLoadLockContainer)
{
this.pos = pos;
this.quadTree = quadTree;
this.cachedRenderSourceByPos = cachedRenderSourceByPos;
this.renderLoadLockContainer = renderLoadLockContainer;
this.level = level;
this.fullDataSourceProvider = fullDataSourceProvider;
@@ -238,14 +241,14 @@ public class LodRenderSection implements IDebugRenderable, AutoCloseable
@Nullable
private ColumnRenderSource getRenderSourceForPos(long pos)
{
ReentrantLock lock = RENDER_LOAD_LOCK_CONTAINER.getLockForPos(pos);
ReentrantLock lock = this.renderLoadLockContainer.getLockForPos(pos);
try
{
// we don't want multiple threads attempting to load the same position at the same time
lock.lock();
// use the cached data if possible
ColumnRenderSource renderSource = CACHED_RENDER_SOURCE_BY_POS.getIfPresent(pos);
ColumnRenderSource renderSource = this.cachedRenderSourceByPos.getIfPresent(pos);
if (renderSource != null)
{
return renderSource;
@@ -257,7 +260,7 @@ public class LodRenderSection implements IDebugRenderable, AutoCloseable
// only add valid data to the cache (to prevent null pointers)
if (renderSource != null)
{
CACHED_RENDER_SOURCE_BY_POS.put(pos, renderSource);
this.cachedRenderSourceByPos.put(pos, renderSource);
}
}