summaryrefslogtreecommitdiff
path: root/scene/3d
diff options
context:
space:
mode:
authorYuri Rubinsky <chaosus89@gmail.com>2022-05-26 09:12:20 +0300
committerYuri Rubinsky <chaosus89@gmail.com>2022-05-26 09:42:59 +0300
commit8f57d9519eeedac17cae362afdb00bc766069a89 (patch)
tree49b6105fbfe2736eae599ff1063582bfe4c12eff /scene/3d
parent08e540a2ac8067013983ba06b612ac2a29f25dd3 (diff)
Fix errors when materials attached to 3d object are not freed
Diffstat (limited to 'scene/3d')
-rw-r--r--scene/3d/visual_instance_3d.cpp9
-rw-r--r--scene/3d/visual_instance_3d.h1
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);