mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 02:51:49 +00:00
minor refactor
This commit is contained in:
parent
0c411cf227
commit
40c3ce0cb1
2 changed files with 9 additions and 4 deletions
|
|
@ -90,6 +90,13 @@ void ChunksRenderer::process(std::shared_ptr<Chunk> chunk, BlocksRenderer& rende
|
|||
renderer.build(chunk.get(), level->chunksStorage.get());
|
||||
}
|
||||
|
||||
void ChunksRenderer::enqueueJob(std::shared_ptr<Chunk> job) {
|
||||
jobsMutex.lock();
|
||||
jobs.push(job);
|
||||
jobsMutex.unlock();
|
||||
jobsMutexCondition.notify_one();
|
||||
}
|
||||
|
||||
std::shared_ptr<Mesh> ChunksRenderer::render(std::shared_ptr<Chunk> chunk, bool important) {
|
||||
chunk->setModified(false);
|
||||
|
||||
|
|
@ -106,10 +113,7 @@ std::shared_ptr<Mesh> ChunksRenderer::render(std::shared_ptr<Chunk> chunk, bool
|
|||
}
|
||||
|
||||
inwork[key] = true;
|
||||
jobsMutex.lock();
|
||||
jobs.push(chunk);
|
||||
jobsMutex.unlock();
|
||||
jobsMutexCondition.notify_one();
|
||||
enqueueJob(chunk);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ class ChunksRenderer {
|
|||
const EngineSettings& settings;
|
||||
std::vector<std::unique_lock<std::mutex>> workersBlocked;
|
||||
|
||||
void enqueueJob(std::shared_ptr<Chunk> chunk);
|
||||
void threadLoop(int index);
|
||||
void process(std::shared_ptr<Chunk> chunk, BlocksRenderer& renderer);
|
||||
public:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue