Fixed first chunks lighting concurrency problem

This commit is contained in:
MihailRis 2022-03-06 03:01:08 +03:00 committed by GitHub
parent 07e2fe8b3b
commit 35f8ebe79c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -61,16 +61,24 @@ bool ChunksController::loadVisible(WorldFiles* worldFiles){
if (chunk != nullptr)
return false;
static int _totalLoaded = 0;
ChunksLoader* freeLoader = nullptr;
for (int i = 0; i < LOADERS_COUNT; i++){
ChunksLoader* loader = loaders[i];
if (loader->isBusy())
if (loader->isBusy()){
// Use only one loader at start to prevent near chunks lighting artifacts
if (_totalLoaded < 4){
break;
}
continue;
}
freeLoader = loader;
break;
}
if (freeLoader == nullptr)
return false;
_totalLoaded++;
chunk = new Chunk(nearX+ox,nearY+oy,nearZ+oz);
if (worldFiles->getChunk(chunk->x, chunk->z, (char*)chunk->voxels))
chunk->loaded = true;