Skip to content

Commit

Permalink
Make sure the remaining chunks are notified of the changed world ligh…
Browse files Browse the repository at this point in the history
…ts when adding / removing chunks.
  • Loading branch information
Relintai committed Feb 10, 2025
1 parent 583298d commit 954ca26
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions modules/terraman/world/terrain_world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,14 @@ void TerrainWorld::chunk_add(Ref<TerrainChunk> chunk, const int x, const int z)
chunk->enter_tree();
}

for (int i = 0; i < chunk->light_get_count(); ++i) {
Ref<TerrainLight> light = chunk->light_get_index(i);

if (light.is_valid()) {
world_light_added(light);
}
}

if (has_method("_chunk_added")) {
call("_chunk_added", chunk);
}
Expand Down Expand Up @@ -335,6 +343,14 @@ Ref<TerrainChunk> TerrainWorld::chunk_remove(const int x, const int z) {
chunk->cancel_build();
}

for (int i = 0; i < chunk->light_get_count(); ++i) {
Ref<TerrainLight> light = chunk->light_get_index(i);

if (light.is_valid()) {
world_light_removed(light);
}
}

//never remove from this here
//_generating.erase(chunk);

Expand All @@ -358,6 +374,14 @@ Ref<TerrainChunk> TerrainWorld::chunk_remove_index(const int index) {
chunk->cancel_build();
}

for (int i = 0; i < chunk->light_get_count(); ++i) {
Ref<TerrainLight> light = chunk->light_get_index(i);

if (light.is_valid()) {
world_light_removed(light);
}
}

//never remove from this here
//_generating.erase(chunk);

Expand Down Expand Up @@ -396,6 +420,8 @@ void TerrainWorld::chunks_clear() {
}
}

// Ignoring lights here should be fine

//never remove from this here
//_generating.clear();
}
Expand Down Expand Up @@ -487,6 +513,14 @@ void TerrainWorld::chunks_set(const Vector<Variant> &chunks) {
chunk->cancel_build();
}

for (int j = 0; j < chunk->light_get_count(); ++j) {
Ref<TerrainLight> light = chunk->light_get_index(j);

if (light.is_valid()) {
world_light_removed(light);
}
}

//never remove from this here
//_generating.erase(chunk);

Expand Down

0 comments on commit 954ca26

Please sign in to comment.