Fixed the repeating region bug
This commit is contained in:
@@ -370,21 +370,21 @@ public class LodQuadTreeDimension
|
|||||||
* Returns null if the LodChunk doesn't exist or
|
* Returns null if the LodChunk doesn't exist or
|
||||||
* is outside the loaded area.
|
* is outside the loaded area.
|
||||||
*/
|
*/
|
||||||
public LodQuadTreeNode getLodFromCoordinates(int chunkPosX, int chunkPosZ, int detailLevel)
|
public LodQuadTreeNode getLodFromCoordinates(int posX, int posZ, int detailLevel)
|
||||||
{
|
{
|
||||||
if (detailLevel > LodQuadTreeNode.REGION_LEVEL)
|
if (detailLevel > LodQuadTreeNode.REGION_LEVEL)
|
||||||
throw new IllegalArgumentException("getLodFromCoordinates given a level of \"" + detailLevel + "\" when \"" + LodQuadTreeNode.REGION_LEVEL + "\" is the max.");
|
throw new IllegalArgumentException("getLodFromCoordinates given a level of \"" + detailLevel + "\" when \"" + LodQuadTreeNode.REGION_LEVEL + "\" is the max.");
|
||||||
|
|
||||||
RegionPos regionPos = LodUtil.convertChunkPosToRegionPos(new ChunkPos(chunkPosX, chunkPosZ));
|
int regionPosX = Math.floorDiv(posX, (int) Math.pow(2,LodQuadTreeNode.REGION_LEVEL - detailLevel));
|
||||||
LodQuadTree region = getRegion(regionPos.x, regionPos.z);
|
int regionPosZ = Math.floorDiv(posZ, (int) Math.pow(2,LodQuadTreeNode.REGION_LEVEL - detailLevel));
|
||||||
|
LodQuadTree region = getRegion(regionPosX, regionPosZ);
|
||||||
|
|
||||||
if(region == null)
|
if(region == null)
|
||||||
{
|
{
|
||||||
//System.out.println("THIS CASE");
|
//System.out.println("THIS CASE");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
return region.getNodeAtChunkPos(posX, posZ, detailLevel);
|
||||||
return region.getNodeAtChunkPos(chunkPosX, chunkPosZ, detailLevel);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
RegionPos pos = LodUtil.convertChunkPosToRegionPos(new ChunkPos(chunkX, chunkZ));
|
RegionPos pos = LodUtil.convertChunkPosToRegionPos(new ChunkPos(chunkX, chunkZ));
|
||||||
|
|||||||
Reference in New Issue
Block a user