diff options
author | Yuri Rubinsky <chaosus89@gmail.com> | 2022-05-26 22:07:30 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-26 22:07:30 +0300 |
commit | 6b9f6823c4e9b55459f0831d0ec6968b72bd06f9 (patch) | |
tree | 0be0c6c92a9c098810b7fe71dd89b64f59b4300f | |
parent | 2e8862887c07708ea0d4cb015902c3001ea6f495 (diff) | |
parent | 8f57d9519eeedac17cae362afdb00bc766069a89 (diff) |
Merge pull request #61432 from Chaosus/fix_material_free_errors
Fix errors when materials attached to 3d object are not freed
-rw-r--r-- | scene/3d/visual_instance_3d.cpp | 9 | ||||
-rw-r--r-- | scene/3d/visual_instance_3d.h | 1 |
2 files changed, 10 insertions, 0 deletions
diff --git a/scene/3d/visual_instance_3d.cpp b/scene/3d/visual_instance_3d.cpp index 273e01989a..e40c8bfa2b 100644 --- a/scene/3d/visual_instance_3d.cpp +++ b/scene/3d/visual_instance_3d.cpp @@ -496,3 +496,12 @@ void GeometryInstance3D::_bind_methods() { GeometryInstance3D::GeometryInstance3D() { //RS::get_singleton()->instance_geometry_set_baked_light_texture_index(get_instance(),0); } + +GeometryInstance3D::~GeometryInstance3D() { + if (material_overlay.is_valid()) { + set_material_overlay(Ref<Material>()); + } + if (material_override.is_valid()) { + set_material_override(Ref<Material>()); + } +} diff --git a/scene/3d/visual_instance_3d.h b/scene/3d/visual_instance_3d.h index f8fd4378fe..e5f98bd65e 100644 --- a/scene/3d/visual_instance_3d.h +++ b/scene/3d/visual_instance_3d.h @@ -188,6 +188,7 @@ public: TypedArray<String> get_configuration_warnings() const override; GeometryInstance3D(); + virtual ~GeometryInstance3D(); }; VARIANT_ENUM_CAST(GeometryInstance3D::ShadowCastingSetting); |