added chunk flickering patch from the other repo

This commit is contained in:
LAX1DUDE 2022-04-29 23:43:05 -07:00
parent 32f1489ed9
commit 5c1f65c894
3 changed files with 41 additions and 25 deletions

1
.gitignore vendored
View File

@ -10,4 +10,5 @@ bin
/lwjgl-rundir/lwjgl_saves /lwjgl-rundir/lwjgl_saves
/lwjgl-rundir/filesystem /lwjgl-rundir/filesystem
/lwjgl-rundir/texturepacks /lwjgl-rundir/texturepacks
/lwjgl-rundir/downloads
/lwjgl-rundir/options.txt /lwjgl-rundir/options.txt

View File

@ -185,17 +185,17 @@ public class RenderGlobal implements IWorldAccess {
for (int j1 = 0; j1 < renderChunksWide; j1++) { for (int j1 = 0; j1 < renderChunksWide; j1++) {
for (int k1 = 0; k1 < renderChunksTall; k1++) { for (int k1 = 0; k1 < renderChunksTall; k1++) {
for (int l1 = 0; l1 < renderChunksDeep; l1++) { for (int l1 = 0; l1 < renderChunksDeep; l1++) {
worldRenderers[(l1 * renderChunksTall + k1) * renderChunksWide + j1] = new WorldRenderer(worldObj, int idx = (l1 * renderChunksTall + k1) * renderChunksWide + j1;
worldRenderers[idx] = new WorldRenderer(worldObj,
tileEntities, j1 * 16, k1 * 16, l1 * 16, 16, renderListBase + k); tileEntities, j1 * 16, k1 * 16, l1 * 16, 16, renderListBase + k);
worldRenderers[(l1 * renderChunksTall + k1) * renderChunksWide worldRenderers[idx].isWaitingOnOcclusionQuery = false;
+ j1].isWaitingOnOcclusionQuery = false; worldRenderers[idx].isVisible = 100;
worldRenderers[(l1 * renderChunksTall + k1) * renderChunksWide + j1].isVisible = true; worldRenderers[idx].isNowVisible = true;
worldRenderers[(l1 * renderChunksTall + k1) * renderChunksWide + j1].isInFrustum = true; worldRenderers[idx].isInFrustum = true;
worldRenderers[(l1 * renderChunksTall + k1) * renderChunksWide + j1].chunkIndex = l++; worldRenderers[idx].chunkIndex = l++;
worldRenderers[(l1 * renderChunksTall + k1) * renderChunksWide + j1].markDirty(); worldRenderers[idx].markDirty();
sortedWorldRenderers[(l1 * renderChunksTall + k1) * renderChunksWide sortedWorldRenderers[idx] = worldRenderers[idx];
+ j1] = worldRenderers[(l1 * renderChunksTall + k1) * renderChunksWide + j1]; worldRenderersToUpdate.add(worldRenderers[idx]);
worldRenderersToUpdate.add(worldRenderers[(l1 * renderChunksTall + k1) * renderChunksWide + j1]);
k += 2; k += 2;
} }
@ -391,7 +391,9 @@ public class RenderGlobal implements IWorldAccess {
fz = fz >> 4; fz = fz >> 4;
long queryRate = 50l; long queryRate = 50l;
long stallRate = 150l; long stallRateVisible = 50l;
long stallRate = 500l;
int cooldownRate = 10;
long ct = System.currentTimeMillis(); long ct = System.currentTimeMillis();
if(i == 0) { if(i == 0) {
@ -401,14 +403,25 @@ public class RenderGlobal implements IWorldAccess {
int ccy = c.chunkY - fy; int ccy = c.chunkY - fy;
int ccz = c.chunkZ - fz; int ccz = c.chunkZ - fz;
if((ccx < 2 && ccx > -2 && ccy < 2 && ccy > -2 && ccz < 2 && ccz > -2) || glOcclusionQuery[c.chunkIndex] == -1) { if((ccx < 2 && ccx > -2 && ccy < 2 && ccy > -2 && ccz < 2 && ccz > -2) || glOcclusionQuery[c.chunkIndex] == -1) {
c.isVisible = true; c.isNowVisible = true;
c.isVisible = cooldownRate;
}else if(!c.canRender() && c.isInFrustum) { }else if(!c.canRender() && c.isInFrustum) {
if(occlusionQueryAvailable[c.chunkIndex] && EaglerAdapter.glGetQueryResultAvailable(glOcclusionQuery[c.chunkIndex])) { if(occlusionQueryAvailable[c.chunkIndex]) {
c.isVisible = EaglerAdapter.glGetQueryResult(glOcclusionQuery[c.chunkIndex]); if(EaglerAdapter.glGetQueryResultAvailable(glOcclusionQuery[c.chunkIndex])) {
occlusionQueryAvailable[c.chunkIndex] = false; if(EaglerAdapter.glGetQueryResult(glOcclusionQuery[c.chunkIndex])) {
occlusionQueryStalled[c.chunkIndex] = 0l; c.isNowVisible = true;
}else if(occlusionQueryStalled[c.chunkIndex] != 0l && ct - occlusionQueryStalled[c.chunkIndex] > stallRate) { c.isVisible = cooldownRate;
c.isVisible = true; }else {
if(c.isVisible <= 0) {
c.isNowVisible = false;
}
}
occlusionQueryAvailable[c.chunkIndex] = false;
occlusionQueryStalled[c.chunkIndex] = 0l;
}else if(occlusionQueryStalled[c.chunkIndex] != 0l && ct - occlusionQueryStalled[c.chunkIndex] > stallRateVisible) {
c.isNowVisible = true;
c.isVisible = cooldownRate;
}
} }
} }
} }
@ -451,6 +464,9 @@ public class RenderGlobal implements IWorldAccess {
EaglerAdapter.glEndQuery(); EaglerAdapter.glEndQuery();
} }
} }
if(c.isVisible > 0) {
--c.isVisible;
}
} }
EaglerAdapter.glEndOcclusionBB(); EaglerAdapter.glEndOcclusionBB();
EaglerAdapter.glColorMask(true, true, true, true); EaglerAdapter.glColorMask(true, true, true, true);
@ -471,14 +487,14 @@ public class RenderGlobal implements IWorldAccess {
field_1416_Q++; field_1416_Q++;
} else if (!sortedWorldRenderers[i1].isInFrustum) { } else if (!sortedWorldRenderers[i1].isInFrustum) {
field_1419_N++; field_1419_N++;
} else if (field_1436_w && !sortedWorldRenderers[i1].isVisible) { } else if (field_1436_w && !sortedWorldRenderers[i1].isNowVisible) {
field_1418_O++; field_1418_O++;
} else { } else {
field_1417_P++; field_1417_P++;
} }
} }
if (sortedWorldRenderers[i1].skipRenderPass[k] || !sortedWorldRenderers[i1].isInFrustum if (sortedWorldRenderers[i1].skipRenderPass[k] || !sortedWorldRenderers[i1].isInFrustum
|| !sortedWorldRenderers[i1].isVisible) { || !sortedWorldRenderers[i1].isNowVisible) {
continue; continue;
} }
int j1 = sortedWorldRenderers[i1].getGLCallListForPass(k); int j1 = sortedWorldRenderers[i1].getGLCallListForPass(k);

View File

@ -15,7 +15,8 @@ public class WorldRenderer {
glRenderList = -1; glRenderList = -1;
isInFrustum = false; isInFrustum = false;
skipRenderPass = new boolean[2]; skipRenderPass = new boolean[2];
isVisible = true; isVisible = 0;
isNowVisible = true;
isInitialized = false; isInitialized = false;
tileEntityRenderers = new ArrayList(); tileEntityRenderers = new ArrayList();
worldObj = world; worldObj = world;
@ -51,9 +52,6 @@ public class WorldRenderer {
float f = 6F; float f = 6F;
renderBoundingBox = AxisAlignedBB.getBoundingBox((float) i - f, (float) j - f, (float) k - f, renderBoundingBox = AxisAlignedBB.getBoundingBox((float) i - f, (float) j - f, (float) k - f,
(float) (i + sizeWidth) + f, (float) (j + sizeHeight) + f, (float) (k + sizeDepth) + f); (float) (i + sizeWidth) + f, (float) (j + sizeHeight) + f, (float) (k + sizeDepth) + f);
//RenderItem.renderAABB(AxisAlignedBB.getBoundingBoxFromPool((float) field_1752_l - f,
// (float) field_1751_m - f, (float) field_1750_n - f, (float) (field_1752_l + sizeWidth) + f,
// (float) (field_1751_m + sizeHeight) + f, (float) (field_1750_n + sizeDepth) + f));
markDirty(); markDirty();
return; return;
} }
@ -228,7 +226,8 @@ public class WorldRenderer {
public boolean needsUpdate; public boolean needsUpdate;
public AxisAlignedBB renderBoundingBox; public AxisAlignedBB renderBoundingBox;
public int chunkIndex; public int chunkIndex;
public boolean isVisible; public int isVisible;
public boolean isNowVisible;
public boolean isWaitingOnOcclusionQuery; public boolean isWaitingOnOcclusionQuery;
public int field_1732_z; public int field_1732_z;
public boolean field_1747_A; public boolean field_1747_A;