batch 2: fixing chunk rendering & frustum culling; rewrote most of it, but now it works. next step is to fix the "highlight" effect & add the optimizations i wrote on optifromhell.txt

This commit is contained in:
JuiceyDev
2026-03-27 00:36:18 +01:00
committed by Tropical
parent fbb7b304c8
commit 09e8a8f981
6 changed files with 69 additions and 69 deletions

View File

@@ -856,6 +856,10 @@ int LevelRenderer::renderChunks(int from, int to, int layer, double alpha) {
if ((globalChunkFlags[pClipChunk->globalIdx] & emptyFlag) == emptyFlag)
continue; // Check that this particular layer isn't empty
glPushMatrix();
glTranslatef((float)pClipChunk->chunk->x, (float)pClipChunk->chunk->y,
(float)pClipChunk->chunk->z);
// List can be calculated directly from the chunk's global idex
int list = pClipChunk->globalIdx * 2 + layer;
list += chunkLists;
@@ -863,6 +867,8 @@ int LevelRenderer::renderChunks(int from, int to, int layer, double alpha) {
if (RenderManager.CBuffCall(list, first)) {
first = false;
}
glPopMatrix();
count++;
}
@@ -2248,9 +2254,13 @@ bool LevelRenderer::updateDirtyChunks() {
// int64_t startTime = System::currentTimeMillis();
// app.DebugPrintf("Rebuilding permaChunk %d\n", index);
Tesselator::getInstance()->offset(-permaChunk[index].x,
-permaChunk[index].y,
-permaChunk[index].z);
permaChunk[index].rebuild();
Tesselator::getInstance()->offset(0, 0, 0);
if (index != 0)
s_rebuildCompleteEvents->Set(
index - 1); // MGH - this rebuild happening on the main
@@ -2303,7 +2313,10 @@ bool LevelRenderer::updateDirtyChunks() {
// static int64_t totalTime = 0;
// static int64_t countTime = 0;
// int64_t startTime = System::currentTimeMillis();
Tesselator::getInstance()->offset(
-permaChunk[index].x, -permaChunk[index].y, -permaChunk[index].z);
permaChunk.rebuild();
Tesselator::getInstance()->offset(0, 0, 0);
// int64_t endTime = System::currentTimeMillis();
// totalTime += (endTime - startTime);
// countTime++;
@@ -4039,10 +4052,12 @@ int LevelRenderer::rebuildChunkThreadProc(void* lpParam) {
while (true) {
s_activationEventA[index]->WaitForSignal(INFINITE);
Tesselator* t = Tesselator::getInstance();
Tesselator::getInstance()->offset(
-permaChunk[index].x, -permaChunk[index].y, -permaChunk[index].z);
// app.DebugPrintf("Rebuilding permaChunk %d\n", index + 1);
permaChunk[index + 1].rebuild();
Tesselator::getInstance()->offset(0, 0, 0);
// Inform the producer thread that we are done with this chunk
s_rebuildCompleteEvents->Set(index);
}