From 067008bb90f4d71269ddd56d3cb9c3b095dd2eaf Mon Sep 17 00:00:00 2001 From: Relintai Date: Thu, 12 Aug 2021 20:24:39 +0200 Subject: [PATCH] Fix moving PropInstanceMerger even when it's parent is moved. --- prop_instance_merger.cpp | 14 +++++++++++--- prop_instance_merger.h | 2 ++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/prop_instance_merger.cpp b/prop_instance_merger.cpp index 8bfc015..5357335 100644 --- a/prop_instance_merger.cpp +++ b/prop_instance_merger.cpp @@ -804,24 +804,32 @@ void PropInstanceMerger::_notification(int p_what) { break; } case NOTIFICATION_TRANSFORM_CHANGED: { + Transform new_transform = get_global_transform(); + + if (new_transform == _last_transform) { + break; + } + + _last_transform = new_transform; + VisualServer *vs = VisualServer::get_singleton(); for (int i = 0; i < _meshes.size(); ++i) { RID mir = _meshes[i].mesh_instance; if (mir != RID()) { - vs->instance_set_transform(mir, get_transform()); + vs->instance_set_transform(mir, new_transform); } } if (_debug_mesh_instance != RID()) { - vs->instance_set_transform(_debug_mesh_instance, get_transform()); + vs->instance_set_transform(_debug_mesh_instance, new_transform); } for (int i = 0; i < _colliders.size(); ++i) { const ColliderBody &c = _colliders[i]; - PhysicsServer::get_singleton()->body_set_shape_transform(c.body, 0, get_transform() * c.transform); + PhysicsServer::get_singleton()->body_set_shape_transform(c.body, 0, new_transform * c.transform); } break; diff --git a/prop_instance_merger.h b/prop_instance_merger.h index b52d5bb..17e2ff5 100644 --- a/prop_instance_merger.h +++ b/prop_instance_merger.h @@ -148,6 +148,8 @@ private: int _lod_level; + Transform _last_transform; + Ref _job; Vector> _materials;