Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/game/StarWorldClient.cpp6
-rw-r--r--source/game/StarWorldClient.hpp1
2 files changed, 6 insertions, 1 deletions
diff --git a/source/game/StarWorldClient.cpp b/source/game/StarWorldClient.cpp
index efc2eb7..82c09ae 100644
--- a/source/game/StarWorldClient.cpp
+++ b/source/game/StarWorldClient.cpp
@@ -90,6 +90,7 @@ WorldClient::WorldClient(PlayerPtr mainPlayer, LuaRootPtr luaRoot) {
m_altMusicActive = false;
m_stopLightingThread = false;
+ m_pendingLightReady = false;
clearWorld();
}
@@ -461,6 +462,7 @@ void WorldClient::render(WorldRenderData& renderData, unsigned bufferTiles) {
m_pendingLights = std::move(renderLightSources);
m_pendingParticleLights = std::move(m_particles->lightSources());
m_pendingLightRange = window.padded(1);
+ m_pendingLightReady = true;
} //Kae: Padded by one to fix light spread issues at the edges of the frame.
if (m_asyncLighting)
@@ -1667,7 +1669,9 @@ void WorldClient::lightingTileGather() {
void WorldClient::lightingCalc() {
MutexLocker prepLocker(m_lightMapPrepMutex);
-
+ if (!m_pendingLightReady.load())
+ return;
+ m_pendingLightReady = false;
RectI lightRange = m_pendingLightRange;
List<LightSource> lights = std::move(m_pendingLights);
List<std::pair<Vec2F, Vec3F>> particleLights = std::move(m_pendingParticleLights);
diff --git a/source/game/StarWorldClient.hpp b/source/game/StarWorldClient.hpp
index 502a928..3c8728d 100644
--- a/source/game/StarWorldClient.hpp
+++ b/source/game/StarWorldClient.hpp
@@ -285,6 +285,7 @@ private:
List<LightSource> m_pendingLights;
List<std::pair<Vec2F, Vec3F>> m_pendingParticleLights;
RectI m_pendingLightRange;
+ atomic<bool> m_pendingLightReady;
Vec2I m_lightMinPosition;
List<PreviewTile> m_previewTiles;