light works again, changed the region_fast option, fixed a indexout of buond, added a TODO for the future for better memery use

This commit is contained in:
Leonardo
2021-09-23 16:02:32 +02:00
parent 6c1c04bb5f
commit 5bbdd22b58
4 changed files with 41 additions and 23 deletions
@@ -235,7 +235,7 @@ public class LodBufferBuilder
int maxVerticalData = 1;
if (LodConfig.CLIENT.worldGenerator.lodQualityMode.get() == VerticalQuality.MULTI_LOD)
{
maxVerticalData = DetailDistanceUtil.getMaxVerticalData(LodUtil.BLOCK_DETAIL_LEVEL);
maxVerticalData = 256;
}
// create adjData's arrays
@@ -322,15 +322,17 @@ public class LodBuilder
yAbs = height - 1;
// We search light on above air block
depth = determineBottomPointFrom(chunk, config, xRel, zRel, yAbs, blockPos);
blockPos.set(xAbs, yAbs, zAbs);
light = getLightValue(chunk, blockPos, hasCeiling, hasSkyLight, topBlock);
if (hasCeiling && topBlock)
{
yAbs = depth;
blockPos.set(xAbs, yAbs, zAbs);
light = getLightValue(chunk, blockPos, hasCeiling, hasSkyLight, topBlock);
color = generateLodColor(chunk, config, xRel, yAbs, zRel, blockPos);
blockPos.set(xAbs, yAbs - 1, zAbs);
} else
{
blockPos.set(xAbs, yAbs, zAbs);
light = getLightValue(chunk, blockPos, hasCeiling, hasSkyLight, topBlock);
color = generateLodColor(chunk, config, xRel, yAbs, zRel, blockPos);
blockPos.set(xAbs, yAbs + 1, zAbs);
}
@@ -595,7 +597,8 @@ public class LodBuilder
IWorld world = mc.getClientWorld();
int blockBrightness = world.getBrightness(LightType.BLOCK, blockPos);
//int blockBrightness = world.getBrightness(LightType.BLOCK, blockPos);
int blockBrightness = chunk.getLightEmission(blockPos);
if (hasCeiling && topBlock)
blockPos.set(blockPos.getX(), blockPos.getY() - 1, blockPos.getZ());
@@ -626,8 +629,7 @@ public class LodBuilder
}
}
}
BlockState blockState = chunk.getBlockState(blockPos);
blockLight = blockState.getLightValue(chunk, blockPos);
blockLight = world.getBrightness(LightType.BLOCK, blockPos);
blockLight = LodUtil.clamp(0, blockLight + blockBrightness, 15);
return blockLight + (skyLight << 4);
@@ -854,6 +854,16 @@ public class LodDimension
{
/*return regions[x][z].getMinMemoryNeeded(template);*/
/*TODO add memory use calculated with the following cases
switch (LodConfig.CLIENT.graphics.detailDropOff.get())
{
default:
case BY_BLOCK:
break;
case BY_REGION_FANCY:
break;
case BY_REGION_FAST:
}*/
int minDistance = LevelPosUtil.minDistance(LodUtil.REGION_DETAIL_LEVEL, x, z, halfWidth, halfWidth);
int detail = DetailDistanceUtil.getTreeCutDetailFromDistance(minDistance);
int levelToGen = DetailDistanceUtil.getLodDrawDetail(detail);
@@ -95,7 +95,7 @@ public class LodRegion
{
posX = LevelPosUtil.getRegionModule(detailLevel, posX);
posZ = LevelPosUtil.getRegionModule(detailLevel, posZ);
// For some reason the dataContainer can contain null entries
if (this.dataContainer[detailLevel] == null)
{
@@ -104,9 +104,9 @@ public class LodRegion
else
this.dataContainer[detailLevel] = new VerticalLevelContainer(detailLevel);
}
this.dataContainer[detailLevel].addData(data, posX, posZ, verticalIndex);
return true;
}
@@ -240,14 +240,16 @@ public class LodRegion
byte supposedLevel;
int maxDistance;
boolean stopNow = false;
int minDistance;
int childLevel;
switch (LodConfig.CLIENT.graphics.detailDropOff.get())
{
default:
case BY_BLOCK:
maxDistance = LevelPosUtil.maxDistance(detailLevel, posX, posZ, playerPosX, playerPosZ, regionPosX, regionPosZ);
supposedLevel = DetailDistanceUtil.getLodDrawDetail(DetailDistanceUtil.getDrawDetailFromDistance(maxDistance));
int minDistance = LevelPosUtil.minDistance(detailLevel, posX, posZ, playerPosX, playerPosZ, regionPosX, regionPosZ);
int childLevel = DetailDistanceUtil.getLodDrawDetail(DetailDistanceUtil.getDrawDetailFromDistance(minDistance));
minDistance = LevelPosUtil.minDistance(detailLevel, posX, posZ, playerPosX, playerPosZ, regionPosX, regionPosZ);
childLevel = DetailDistanceUtil.getLodDrawDetail(DetailDistanceUtil.getDrawDetailFromDistance(minDistance));
stopNow = detailLevel == childLevel - 1;
break;
@@ -255,28 +257,32 @@ public class LodRegion
supposedLevel = minDetailLevel;
break;
case BY_REGION_FAST:
int playerRegionX = LevelPosUtil.getRegion(LodUtil.BLOCK_DETAIL_LEVEL,playerPosX);
int playerRegionZ = LevelPosUtil.getRegion(LodUtil.BLOCK_DETAIL_LEVEL,playerPosZ);
if(playerRegionX == regionPosX && playerRegionZ == regionPosZ)
supposedLevel = minDetailLevel;
else
int playerRegionX = LevelPosUtil.getRegion(LodUtil.BLOCK_DETAIL_LEVEL, playerPosX);
int playerRegionZ = LevelPosUtil.getRegion(LodUtil.BLOCK_DETAIL_LEVEL, playerPosZ);
if (playerRegionX == regionPosX && playerRegionZ == regionPosZ)
{
maxDistance = LevelPosUtil.maxDistance(LodUtil.REGION_DETAIL_LEVEL, regionPosX, regionPosZ, playerRegionX*512 + 256, playerRegionZ*512 + 256);
maxDistance = LevelPosUtil.maxDistance(detailLevel, posX, posZ, playerPosX, playerPosZ, regionPosX, regionPosZ);
supposedLevel = DetailDistanceUtil.getLodDrawDetail(DetailDistanceUtil.getDrawDetailFromDistance(maxDistance));
minDistance = LevelPosUtil.minDistance(detailLevel, posX, posZ, playerPosX, playerPosZ, regionPosX, regionPosZ);
childLevel = DetailDistanceUtil.getLodDrawDetail(DetailDistanceUtil.getDrawDetailFromDistance(minDistance));
stopNow = detailLevel == childLevel - 1;
} else
{
maxDistance = LevelPosUtil.maxDistance(LodUtil.REGION_DETAIL_LEVEL, regionPosX, regionPosZ, playerRegionX * 512 + 256, playerRegionZ * 512 + 256);
supposedLevel = DetailDistanceUtil.getLodDrawDetail(DetailDistanceUtil.getDrawDetailFromDistance(maxDistance));
}
break;
}
if(stopNow){
if (stopNow)
{
posToRender.addPosToRender(detailLevel,
posX + regionPosX * size,
posZ + regionPosZ * size);
}
else if (supposedLevel > detailLevel)
} else if (supposedLevel > detailLevel)
{
return;
}
else if (supposedLevel == detailLevel)
} else if (supposedLevel == detailLevel)
{
posToRender.addPosToRender(detailLevel,
posX + regionPosX * size,
@@ -306,7 +312,7 @@ public class LodRegion
//If all the four children exist we go deeper
if(!requireCorrectDetailLevel)
if (!requireCorrectDetailLevel)
{
if (childrenCount == 4)
{