Skip to content

Commit

Permalink
fixed copy-move of hierarchy of entities
Browse files Browse the repository at this point in the history
  • Loading branch information
nem0 committed Nov 18, 2024
1 parent daaf11a commit bfbb4c9
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/editor/world_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2471,7 +2471,8 @@ struct WorldEditorImpl final : WorldEditor
}

void gatherHierarchy(EntityRef e, Array<EntityRef>& entities) {
entities.push(e);
if (entities.indexOf(e) < 0) entities.push(e);

for (EntityRef child : m_world->childrenOf(e)) {
if (entities.indexOf(child) < 0) {
gatherHierarchy(child, entities);
Expand Down Expand Up @@ -2920,7 +2921,18 @@ struct WorldEditorImpl final : WorldEditor
}
}
}
fastRemoveDuplicates(m_selected_entities);
if (!m_selected_entities.empty()) {
const EntityRef first = m_selected_entities[0];
fastRemoveDuplicates(m_selected_entities);
// fastRemoveDuplicates changed order of the entities, but we need
// to keep the first entity, because it's used for the transform gizmo
for (u32 i = 0, c = m_selected_entities.size(); i < c; ++i) {
if (m_selected_entities[i] == first) {
swap(m_selected_entities[i], m_selected_entities[0]);
break;
}
}
}
m_entity_selection_changed.invoke();
}

Expand Down

0 comments on commit bfbb4c9

Please sign in to comment.