Fixed hash bug for ChunkPos & incorrect shink causing overdraw issue

This commit is contained in:
tom lee
2022-02-11 13:33:11 +08:00
parent f422df6280
commit 595b8ecbb5
2 changed files with 15 additions and 11 deletions
@@ -375,17 +375,10 @@ public class LodUtil
// if the skipRadius is being used
if (skipRadius != 0)
{
for (int x = centerChunk.getX() - chunkRenderDist; x < centerChunk.getX() + chunkRenderDist; x++)
{
for (int z = centerChunk.getZ() - chunkRenderDist; z < centerChunk.getZ() + chunkRenderDist; z++)
{
if (x <= centerChunk.getX() - skipRadius || x >= centerChunk.getX() + skipRadius
|| z <= centerChunk.getZ() - skipRadius || z >= centerChunk.getZ() + skipRadius)
{
posToSkip.remove(FACTORY.createChunkPos(x, z));
}
}
}
posToSkip.removeIf((pos) -> {
return (pos.getX() < centerChunk.getX() - skipRadius || pos.getX() > centerChunk.getX() + skipRadius
|| pos.getZ() < centerChunk.getZ() - skipRadius || pos.getZ() > centerChunk.getZ() + skipRadius);
});
}
return posToSkip;
}
@@ -50,4 +50,15 @@ public abstract class AbstractChunkPosWrapper
public abstract AbstractBlockPosWrapper getWorldPosition();
@Override
public int hashCode() {
return Long.hashCode(getLong());
}
@Override
public boolean equals(Object obj) {
if (obj == this) return true;
if (!(obj instanceof AbstractChunkPosWrapper)) return false;
return getLong() == ((AbstractChunkPosWrapper)obj).getLong();
}
}