fixed multiple nodes parenting in the world viewer
fixes
@@ -2,7 +2,7 @@ use crate::{
gui::make_image_button_with_tooltip,
load_image,
scene::{
- commands::{graph::LinkNodesCommand, ChangeSelectionCommand},
+ commands::{graph::LinkNodesCommand, ChangeSelectionCommand, CommandGroup, SceneCommand},
EditorScene, Selection,
},
send_sync_message,
@@ -727,13 +727,18 @@ impl WorldViewer {
ui.node(dropped).cast::<SceneItem<Node>>(),
ui.node(target).cast::<SceneItem<Node>>(),
) {
+ if let Selection::Graph(ref selection) = editor_scene.selection {
+ if selection.nodes.contains(&child.entity_handle) {
+ let mut commands = Vec::new();
+
+ for &node_handle in selection.nodes.iter() {
// Make sure we won't create any loops - child must not have parent in its
// descendants.
let mut attach = true;
let graph = &engine.scenes[editor_scene.scene].graph;
let mut p = parent.entity_handle;
while p.is_some() {
- if p == child.entity_handle {
+ if p == node_handle {
attach = false;
break;
}
@@ -741,16 +746,23 @@ impl WorldViewer {
}
if attach {
- self.sender
- .send(Message::do_scene_command(LinkNodesCommand::new(
- child.entity_handle,
+ commands.push(SceneCommand::new(LinkNodesCommand::new(
+ node_handle,
parent.entity_handle,
- )))
+ )));
+ }
+ }
+
+ if !commands.is_empty() {
+ self.sender
+ .send(Message::do_scene_command(CommandGroup::from(commands)))
.unwrap();
}
}
}
}
+ }
+ }
fn map_selection(&self, selection: &Selection, engine: &GameEngine) -> Vec<Handle<UiNode>> {
match selection {
