mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 03:21:49 +00:00
Reference counting for Chunk | changed ChunksLoader
This commit is contained in:
parent
bc9d29cf68
commit
4651ab776b
4 changed files with 18 additions and 12 deletions
|
|
@ -17,30 +17,24 @@ void ChunksLoader::_thread(){
|
|||
continue;
|
||||
}
|
||||
Chunk* chunk = current;
|
||||
//std::cout << "LOADER: received chunk " << chunk->x << " " << chunk->y << " " << chunk->z << std::endl;
|
||||
chunk->incref();
|
||||
|
||||
chunks._setOffset(chunk->x-1, chunk->y-1, chunk->z-1);
|
||||
|
||||
if (!chunk->generated){
|
||||
WorldGenerator::generate(chunk->voxels, chunk->x, chunk->y, chunk->z);
|
||||
//std::cout << "LOADER: generated chunk" << std::endl;
|
||||
}
|
||||
|
||||
/*for (int i = 0; i < 27; i++){
|
||||
Chunk* other = closes[i];
|
||||
if (other == nullptr)
|
||||
continue;
|
||||
chunks.putChunk(other);
|
||||
}*/
|
||||
chunks.putChunk(chunk);
|
||||
lighting.onChunkLoaded(chunk->x, chunk->y, chunk->z, true);
|
||||
chunks.clear(false);
|
||||
for (int i = 0; i < 27; i++){
|
||||
Chunk* other = closes[i];
|
||||
delete other;
|
||||
//delete other;
|
||||
}
|
||||
chunk->ready = true;
|
||||
current = nullptr;
|
||||
chunk->decref();
|
||||
//std::cout << "LOADER: success" << std::endl;
|
||||
}
|
||||
}
|
||||
|
|
@ -58,7 +52,7 @@ void ChunksLoader::perform(Chunk* chunk, const Chunk** cs){
|
|||
if (other == nullptr)
|
||||
closes[i] = nullptr;
|
||||
else
|
||||
closes[i] = other->clone();
|
||||
closes[i] = (Chunk*)other;//->clone();
|
||||
}
|
||||
current = chunk;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue