Skip to content

Commit b248a28

Browse files
committed
More tweaks to TerrainChunk's new scene api.
1 parent 9841d6f commit b248a28

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

modules/terraman/world/terrain_chunk.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -944,12 +944,22 @@ void TerrainChunk::scene_set_node(const int index, const Node *p_node) {
944944
int TerrainChunk::scene_get_count() const {
945945
return _scenes.size();
946946
}
947-
void TerrainChunk::scene_remove(const int index) {
947+
void TerrainChunk::scene_remove(const int index, const bool p_queue_free) {
948948
ERR_FAIL_INDEX(index, _scenes.size());
949949

950+
if (p_queue_free) {
951+
scene_queue_free(index);
952+
}
953+
950954
_scenes.remove(index);
951955
}
952-
void TerrainChunk::scenes_clear() {
956+
void TerrainChunk::scenes_clear(const bool p_queue_free) {
957+
if (p_queue_free) {
958+
for (int i = 0; i < _scenes.size(); ++i) {
959+
scene_queue_free(i);
960+
}
961+
}
962+
953963
_scenes.clear();
954964
}
955965

@@ -2077,8 +2087,8 @@ void TerrainChunk::_bind_methods() {
20772087
ClassDB::bind_method(D_METHOD("scene_set_node", "index", "node"), &TerrainChunk::scene_set_node);
20782088

20792089
ClassDB::bind_method(D_METHOD("scene_get_count"), &TerrainChunk::scene_get_count);
2080-
ClassDB::bind_method(D_METHOD("scene_remove", "index"), &TerrainChunk::scene_remove);
2081-
ClassDB::bind_method(D_METHOD("scenes_clear"), &TerrainChunk::scenes_clear);
2090+
ClassDB::bind_method(D_METHOD("scene_remove", "index", "queue_free"), &TerrainChunk::scene_remove, DEFVAL(true));
2091+
ClassDB::bind_method(D_METHOD("scenes_clear", "queue_free"), &TerrainChunk::scenes_clear, DEFVAL(true));
20822092

20832093
ClassDB::bind_method(D_METHOD("scene_instance", "index"), &TerrainChunk::scene_instance);
20842094
ClassDB::bind_method(D_METHOD("scene_queue_free", "index"), &TerrainChunk::scene_queue_free);

modules/terraman/world/terrain_chunk.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,9 @@ class TerrainChunk : public Resource {
263263
void scene_set_node(const int index, const Node *p_node);
264264

265265
int scene_get_count() const;
266-
void scene_remove(const int index);
267-
void scenes_clear();
266+
267+
void scene_remove(const int index, const bool p_queue_free = true);
268+
void scenes_clear(const bool p_queue_free = true);
268269

269270
void scene_instance(const int index);
270271
void scene_queue_free(const int index);

0 commit comments

Comments
 (0)