Skip to content

Commit a8099db

Browse files
authored
Merge pull request #84 from hotstreams/fix/light-removal
fix light removal
2 parents 4f2e740 + 3a91a69 commit a8099db

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

src/limitless/lighting/light_container.cpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,22 @@ Light& LightContainer::add(const Light& light) {
8787

8888
void LightContainer::update() {
8989
// check if there were an update to lights
90-
bool changed {};
91-
for (auto& [id, light]: lights) {
92-
// if changed since last update
93-
if (light.isChanged()) {
94-
// update corresponding internal presentation
95-
internal_lights.at(id).update(light);
90+
bool changed = false;
91+
92+
auto it = lights.begin();
93+
while (it != lights.end()) {
94+
auto& [id, light] = *it;
95+
if (light.isRemoved()) {
96+
internal_lights.erase(id);
97+
it = lights.erase(it);
9698
changed = true;
99+
100+
} else {
101+
if (light.isChanged()) {
102+
internal_lights.at(id).update(light);
103+
changed = true;
104+
}
105+
++it;
97106
}
98107
}
99108

0 commit comments

Comments
 (0)