Fixed first chunks lighting concurrency problem
This commit is contained in:
@@ -61,16 +61,24 @@ bool ChunksController::loadVisible(WorldFiles* worldFiles){
|
|||||||
if (chunk != nullptr)
|
if (chunk != nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
static int _totalLoaded = 0;
|
||||||
|
|
||||||
ChunksLoader* freeLoader = nullptr;
|
ChunksLoader* freeLoader = nullptr;
|
||||||
for (int i = 0; i < LOADERS_COUNT; i++){
|
for (int i = 0; i < LOADERS_COUNT; i++){
|
||||||
ChunksLoader* loader = loaders[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;
|
continue;
|
||||||
|
}
|
||||||
freeLoader = loader;
|
freeLoader = loader;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (freeLoader == nullptr)
|
if (freeLoader == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
_totalLoaded++;
|
||||||
chunk = new Chunk(nearX+ox,nearY+oy,nearZ+oz);
|
chunk = new Chunk(nearX+ox,nearY+oy,nearZ+oz);
|
||||||
if (worldFiles->getChunk(chunk->x, chunk->z, (char*)chunk->voxels))
|
if (worldFiles->getChunk(chunk->x, chunk->z, (char*)chunk->voxels))
|
||||||
chunk->loaded = true;
|
chunk->loaded = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user