diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2022-12-16 13:46:53 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2022-12-16 13:46:53 +0100 |
commit | 49a60b1d1c4d62fec1be89e4878433b6c3220ce0 (patch) | |
tree | 2e1ebbbd6334183899fd3ddb7378554a9f6b6408 /scene/2d/multimesh_instance_2d.cpp | |
parent | df0cf08878c81b510e5d2fcfc8de605607b6a79a (diff) | |
parent | 1e3a861e1a25baa71f1610aeab6ca0fe69d0c509 (diff) |
Merge pull request #70136 from bmolyneaux/multimesh
Queue redraw when MultiMesh instance transform changes
Diffstat (limited to 'scene/2d/multimesh_instance_2d.cpp')
-rw-r--r-- | scene/2d/multimesh_instance_2d.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/scene/2d/multimesh_instance_2d.cpp b/scene/2d/multimesh_instance_2d.cpp index 68d529fd32..fa72fc5b8b 100644 --- a/scene/2d/multimesh_instance_2d.cpp +++ b/scene/2d/multimesh_instance_2d.cpp @@ -30,6 +30,7 @@ #include "multimesh_instance_2d.h" +#include "core/core_string_names.h" #include "scene/scene_string_names.h" void MultiMeshInstance2D::_notification(int p_what) { @@ -60,7 +61,16 @@ void MultiMeshInstance2D::_bind_methods() { } void MultiMeshInstance2D::set_multimesh(const Ref<MultiMesh> &p_multimesh) { + // Cleanup previous connection if any. + if (multimesh.is_valid()) { + multimesh->disconnect(CoreStringNames::get_singleton()->changed, callable_mp((CanvasItem *)this, &CanvasItem::queue_redraw)); + } multimesh = p_multimesh; + + // Connect to the multimesh so the AABB can update when instance transforms are changed. + if (multimesh.is_valid()) { + multimesh->connect(CoreStringNames::get_singleton()->changed, callable_mp((CanvasItem *)this, &CanvasItem::queue_redraw)); + } queue_redraw(); } |