diff options
author | Johan Aires Rastén <johan@oljud.se> | 2023-03-04 10:45:43 +0100 |
---|---|---|
committer | Yuri Sizov <yuris@humnom.net> | 2023-03-14 13:59:03 +0100 |
commit | d229ca2f27334856695e7e9230894b408284dfdd (patch) | |
tree | ceb1a0725ba5f70ca0b321a2e0b2856204818474 /scene | |
parent | 89a40d317dd40337db08fbbd3925a4535f623812 (diff) |
Fixed incorrect ERROR message when setting new PrimitiveMesh
If calling set_mesh with a PrimitiveMesh that has pending update, the
_mesh_changed function would be called twice. The first time before
set_base had been called, which could lead to an ERROR message about
trying to set an invalid surface override material.
(cherry picked from commit 007b488a5c23b33c6e0b741b55a482e5229f2b90)
Diffstat (limited to 'scene')
-rw-r--r-- | scene/3d/mesh_instance_3d.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/scene/3d/mesh_instance_3d.cpp b/scene/3d/mesh_instance_3d.cpp index 10a7a4e78b..86301ee53f 100644 --- a/scene/3d/mesh_instance_3d.cpp +++ b/scene/3d/mesh_instance_3d.cpp @@ -117,8 +117,10 @@ void MeshInstance3D::set_mesh(const Ref<Mesh> &p_mesh) { mesh = p_mesh; if (mesh.is_valid()) { - mesh->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &MeshInstance3D::_mesh_changed)); + // If mesh is a PrimitiveMesh, calling get_rid on it can trigger a changed callback + // so do this before connecting _mesh_changed. set_base(mesh->get_rid()); + mesh->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &MeshInstance3D::_mesh_changed)); _mesh_changed(); } else { blend_shape_tracks.clear(); |