Fixed lights not changing after a map change event. Fixed lights blocking the thread to update the episode.

This commit is contained in:
Axel 2022-04-28 13:01:28 +02:00 committed by Axel1092
parent 139041fd7f
commit 788427fdd5
3 changed files with 9 additions and 2 deletions

View File

@ -247,6 +247,12 @@ void LightManager::SetLightState(LightId id, const LightState& new_state) {
_dirty = true;
}
void LightManager::SetLightStateNoLock(LightId id, const LightState& new_state) {
LightState& state = const_cast<LightState&>(RetrieveLightState(id));
state = new_state;
_lights_changes[id] = state;
}
void LightManager::SetLightGroup(LightId id, LightGroup group) {
std::lock_guard<std::mutex> lock(_mutex);
LightState& state = const_cast<LightState&>(RetrieveLightState(id));
@ -317,7 +323,7 @@ void LightManager::UpdateServerLightsState(bool discard_client) {
void LightManager::ApplyChanges() {
std::lock_guard<std::mutex> lock(_mutex);
for(const auto& it : _lights_changes) {
SetLightState(it.first, it.second);
SetLightStateNoLock(it.first, it.second);
}
}

View File

@ -82,6 +82,7 @@ public:
void SetColor(LightId id, Color color);
void SetIntensity(LightId id, float intensity);
void SetLightState(LightId id, const LightState& new_state);
void SetLightStateNoLock(LightId id, const LightState& new_state);
void SetLightGroup(LightId id, LightGroup group);
void SetDayNightCycle(const bool active);

View File

@ -86,7 +86,7 @@ using namespace std::chrono_literals;
}
} while (!self->_state.compare_exchange(&prev, next));
if(UpdateLights) {
if(UpdateLights || HasMapChanged) {
self->_on_light_update_callbacks.Call(next);
}