Repository: godotengine/godot (language: cpp)

Issue:
Errors when undoing collision generation for meshes
### Tested versions

Reproducible in 4.3.stable, and 4.4.dev5

### System information

Godot v4.3.stable - Windows 10.0.22631 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1660 SUPER (NVIDIA; 32.0.15.6636) - Intel(R) Core(TM) i7-10700F CPU @ 2.90GHz (16 Threads)

### Issue description

When generating collision shapes for multiple meshes that have different parents, using the `Sibling` placement option, the undo operation is created incorrectly, leading to errors on undo, and only one of the generated collision shapes is deleted.

![Image](https://github.com/user-attachments/assets/4ae11604-28ae-4ce4-92d1-45582616c592)


### Steps to reproduce

See above.

### Minimal reproduction project (MRP)

N/A. See above.


Discussion / hints:

Fix patch:
diff --git a/editor/plugins/mesh_instance_3d_editor_plugin.cpp b/editor/plugins/mesh_instance_3d_editor_plugin.cpp
index 515e6b44529f..63a98db70f08 100644
--- a/editor/plugins/mesh_instance_3d_editor_plugin.cpp
+++ b/editor/plugins/mesh_instance_3d_editor_plugin.cpp
@@ -188,12 +188,12 @@ void MeshInstance3DEditor::_create_collision_shape() {
 				CollisionShape3D *cshape = memnew(CollisionShape3D);
 				cshape->set_shape(shape);
 				cshape->set_name("CollisionShape3D");
-				cshape->set_transform(node->get_transform());
+				cshape->set_transform(instance->get_transform());
 				ur->add_do_method(E, "add_sibling", cshape, true);
 				ur->add_do_method(cshape, "set_owner", owner);
 				ur->add_do_method(Node3DEditor::get_singleton(), SceneStringName(_request_gizmo), cshape);
 				ur->add_do_reference(cshape);
-				ur->add_undo_method(node->get_parent(), "remove_child", cshape);
+				ur->add_undo_method(instance->get_parent(), "remove_child", cshape);
 			}
 		}
 	}


Test patch: