Open BertilBraun opened 6 years ago
Light updates are disabled, because I can not find the bug, thats causing the assert.
In the queue of lightupdates sometimes NULL objects get pushed back (maybe the reason).
void FinishLights() { while (!sunRemovalQueue.empty()) { if (&sunRemovalQueue.front() == nullptr) continue; glm::vec3 pos = sunRemovalQueue.front().first; short val = sunRemovalQueue.front().second; Vector2 c = chunkCoord(pos.x, pos.z); Vector2 b = blockCoord(pos.x, pos.z); sunRemovalQueue.pop(); auto TrySetLightValue = [&](float ox, float oy, float oz) { int neighborLevel = getSunlight(b.x + ox, pos.y + oy, b.z + oz); if (neighborLevel != 0 && neighborLevel < val) resetSunlight(pos.x + ox, pos.y + oy, pos.z + oz); else if (neighborLevel >= val) sunLightQueue.emplace(pos.x + ox, pos.y + oy, pos.z + oz); }; TrySetLightValue(-1, 0, 0); TrySetLightValue( 1, 0, 0); TrySetLightValue( 0, -1, 0); TrySetLightValue( 0, 1, 0); TrySetLightValue( 0, 0, -1); TrySetLightValue( 0, 0, 1); } }
void resetSunlight(int x, int y, int z){ sunRemovalQueue.emplace(glm::vec3(x, y, z), getSunlight(x, y, z)); setSunlight(x, y % CHUNK_SIZE, z, 0); }
Light updates are disabled, because I can not find the bug, thats causing the assert.
In the queue of lightupdates sometimes NULL objects get pushed back (maybe the reason).