summaryrefslogtreecommitdiffstats
path: root/src/RendererWorld.cpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-11-06 14:01:19 +0100
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2018-01-13 03:39:33 +0100
commit95c85382030af78854a42d457fbb259e6078402b (patch)
tree9ed941e9ee88cc77ece824c3c7bb872a37ec7d9b /src/RendererWorld.cpp
parentMinor shader optimization (diff)
downloadAltCraft-95c85382030af78854a42d457fbb259e6078402b.tar
AltCraft-95c85382030af78854a42d457fbb259e6078402b.tar.gz
AltCraft-95c85382030af78854a42d457fbb259e6078402b.tar.bz2
AltCraft-95c85382030af78854a42d457fbb259e6078402b.tar.lz
AltCraft-95c85382030af78854a42d457fbb259e6078402b.tar.xz
AltCraft-95c85382030af78854a42d457fbb259e6078402b.tar.zst
AltCraft-95c85382030af78854a42d457fbb259e6078402b.zip
Diffstat (limited to '')
-rw-r--r--src/RendererWorld.cpp29
1 files changed, 14 insertions, 15 deletions
diff --git a/src/RendererWorld.cpp b/src/RendererWorld.cpp
index 0d5a7c7..4f77aca 100644
--- a/src/RendererWorld.cpp
+++ b/src/RendererWorld.cpp
@@ -11,6 +11,7 @@
#include "Shader.hpp"
#include "GameState.hpp"
#include "Section.hpp"
+#include "RendererSectionData.hpp"
void RendererWorld::WorkerFunction(size_t workerId) {
EventListener tasksListener;
@@ -26,9 +27,9 @@ void RendererWorld::WorkerFunction(size_t workerId) {
if (result != sections.end()) {
if (result->second.GetHash() != gs->world.GetSection(result->first).GetHash()) {
sectionsMutex.unlock();
- RendererSectionData data(&gs->world, vec);
+ auto data = std::make_unique<RendererSectionData>(&gs->world, vec);
renderDataMutex.lock();
- renderData.push(data);
+ renderData.push(std::move(data));
renderDataMutex.unlock();
EventAgregator::PushEvent(EventType::NewRenderDataAvailable, NewRenderDataAvailableData{});
sectionsMutex.lock();
@@ -41,9 +42,9 @@ void RendererWorld::WorkerFunction(size_t workerId) {
}
else {
sectionsMutex.unlock();
- RendererSectionData data(&gs->world, vec);
+ auto data = std::make_unique<RendererSectionData>(&gs->world, vec);
renderDataMutex.lock();
- renderData.push(data);
+ renderData.push(std::move(data));
renderDataMutex.unlock();
EventAgregator::PushEvent(EventType::NewRenderDataAvailable, NewRenderDataAvailableData{});
sectionsMutex.lock();
@@ -123,30 +124,28 @@ RendererWorld::RendererWorld(GameState* ptr) {
renderDataMutex.lock();
int i = 0;
while (!renderData.empty() && i++ < 20) {
- auto &data = renderData.front();
+ auto data = std::move(renderData.front());
+ renderData.pop();
isParsingMutex.lock();
- if (isParsing[data.sectionPos] != true)
+ if (isParsing[data->sectionPos] != true)
LOG(WARNING) << "Generated not parsed data";
- isParsing[data.sectionPos] = false;
+ isParsing[data->sectionPos] = false;
isParsingMutex.unlock();
sectionsMutex.lock();
- if (sections.find(data.sectionPos) != sections.end()) {
- if (sections.find(data.sectionPos)->second.GetHash() == data.hash) {
+ if (sections.find(data->sectionPos) != sections.end()) {
+ if (sections.find(data->sectionPos)->second.GetHash() == data->hash) {
LOG(INFO) << "Generated not necesarry RendererData";
sectionsMutex.unlock();
renderData.pop();
continue;
}
- sections.erase(sections.find(data.sectionPos));
+ sections.erase(sections.find(data->sectionPos));
}
- RendererSection renderer(data);
- sections.insert(std::make_pair(data.sectionPos, std::move(renderer)));
+ RendererSection renderer(*data);
+ sections.insert(std::make_pair(data->sectionPos, std::move(renderer)));
sectionsMutex.unlock();
- renderData.pop();
}
- if (renderData.empty())
- std::queue<RendererSectionData>().swap(renderData);
renderDataMutex.unlock();
});