mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-12 06:21:50 +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());
|
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) {
|
std::shared_ptr<Mesh> ChunksRenderer::render(std::shared_ptr<Chunk> chunk, bool important) {
|
||||||
chunk->setModified(false);
|
chunk->setModified(false);
|
||||||
|
|
||||||
|
|
@ -106,10 +113,7 @@ std::shared_ptr<Mesh> ChunksRenderer::render(std::shared_ptr<Chunk> chunk, bool
|
||||||
}
|
}
|
||||||
|
|
||||||
inwork[key] = true;
|
inwork[key] = true;
|
||||||
jobsMutex.lock();
|
enqueueJob(chunk);
|
||||||
jobs.push(chunk);
|
|
||||||
jobsMutex.unlock();
|
|
||||||
jobsMutexCondition.notify_one();
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ class ChunksRenderer {
|
||||||
const EngineSettings& settings;
|
const EngineSettings& settings;
|
||||||
std::vector<std::unique_lock<std::mutex>> workersBlocked;
|
std::vector<std::unique_lock<std::mutex>> workersBlocked;
|
||||||
|
|
||||||
|
void enqueueJob(std::shared_ptr<Chunk> chunk);
|
||||||
void threadLoop(int index);
|
void threadLoop(int index);
|
||||||
void process(std::shared_ptr<Chunk> chunk, BlocksRenderer& renderer);
|
void process(std::shared_ptr<Chunk> chunk, BlocksRenderer& renderer);
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue