diff --git a/modules/terraman/world/terrain_chunk.cpp b/modules/terraman/world/terrain_chunk.cpp index 76a73a49c..2d203d7ef 100644 --- a/modules/terraman/world/terrain_chunk.cpp +++ b/modules/terraman/world/terrain_chunk.cpp @@ -1250,6 +1250,9 @@ void TerrainChunk::_exit_tree() { if (_library.is_valid() && _library->supports_caching()) { if (material_cache_key_has()) { _library->material_cache_unref(material_cache_key_get()); + + material_cache_key_set(0); + material_cache_key_has_set(false); } } }