From 8591a061687f1e21469c7ef92cfc2aebbceda5ac Mon Sep 17 00:00:00 2001 From: David Meza Date: Wed, 7 Oct 2026 21:05:16 -0300 Subject: [PATCH] fix(hierarchy): right-click Duplicate copies every component The hierarchy context-menu Duplicate spawned only a Name and a default Transform, so the "copy" had no mesh, collider or gameplay components and sat at the origin (on top of nothing, or hidden inside the original). It now deep-clones through clone_and_spawn, the same path the Ctrl+D shortcut uses (renzora_gizmo::shortcuts::duplicate_entities), so both produce the same object. Validated in a running editor: duplicating a mesh + static body + box collider + custom reflected components entity from the menu now yields the same component set as Ctrl+D (53 components, previously 4). Assisted-by: Claude Opus 5.5 (claude-opus-5-5) --- RELEASE_NOTES.md | 3 +++ .../src/native/context_menu.rs | 17 +++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 57cf261d3..895f3c9bb 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,5 +1,8 @@ # Renzora Engine `r1-alpha8` +## 2026-10-07 21:03 +- fix(hierarchy): Duplicate in the hierarchy right-click menu copies every component, like Ctrl+D, instead of making an empty entity at the origin + ## 2026-09-18 16:27 - fix(game-ui): an `expand` canvas previewed over the viewport lays out like the shipped game, so edge-anchored UI reaches the edge - fix(game-ui): a canvas root no longer keeps a preview scale that was saved into a scene, which shrank the UI in an exported game diff --git a/crates/renzora_hierarchy/src/native/context_menu.rs b/crates/renzora_hierarchy/src/native/context_menu.rs index 40ee283c3..57b1be68c 100644 --- a/crates/renzora_hierarchy/src/native/context_menu.rs +++ b/crates/renzora_hierarchy/src/native/context_menu.rs @@ -316,16 +316,21 @@ fn add_child(world: &mut World, target: Entity) { } } +/// Deep-clones `target` through Bevy's `clone_and_spawn`, the same path the +/// Ctrl+D shortcut uses (`renzora_gizmo::shortcuts::duplicate_entities`), so +/// the menu and keyboard produce the same object. This used to spawn only a +/// `Name` and a default `Transform`: the "copy" had no mesh, collider or +/// gameplay components and sat at the origin. fn duplicate(world: &mut World, target: Entity) { - let parent = world.get::(target).map(|c| c.parent()); + let Ok(mut src) = world.get_entity_mut(target) else { + return; + }; + let new_entity = src.clone_and_spawn(); let name = world - .get::(target) + .get::(new_entity) .map(|n| format!("{} (Copy)", n.as_str())) .unwrap_or_else(|| "Entity (Copy)".to_string()); - let new_entity = world.spawn((Name::new(name), Transform::default())).id(); - if let Some(p) = parent { - world.entity_mut(new_entity).set_parent_in_place(p); - } + world.entity_mut(new_entity).insert(Name::new(name)); if let Some(sel) = world.get_resource::() { sel.set(Some(new_entity)); }