Improve quick brush creation workflow
This commit is contained in:
1 parent
f09d35e54e
commit
48b1448c57
9 files changed
+701
-61
No files matched your search
@@ -274,6 +274,34 @@ pub fn spawn_with_history(world: &mut World, mut snapshot: EditorEntitySnapshot)
|
||||
entity
|
||||
}
|
||||
|
||||
pub fn spawn_many_with_history(
|
||||
world: &mut World,
|
||||
snapshots: impl IntoIterator<Item = EditorEntitySnapshot>,
|
||||
) -> Vec<Entity> {
|
||||
let mut snapshots: Vec<EditorEntitySnapshot> = snapshots.into_iter().collect();
|
||||
if snapshots.is_empty() {
|
||||
return Vec::new();
|
||||
}
|
||||
let mut sibling_index = next_sibling_index(world, None);
|
||||
for snapshot in &mut snapshots {
|
||||
snapshot.hierarchy_sibling_index = sibling_index;
|
||||
sibling_index += 1;
|
||||
}
|
||||
let entities: Vec<Entity> = snapshots
|
||||
.iter()
|
||||
.map(|snapshot| spawn_snapshot(world, snapshot))
|
||||
.collect();
|
||||
push_history(
|
||||
world,
|
||||
EditorCommand::SpawnMany {
|
||||
snapshots,
|
||||
entities: entities.clone(),
|
||||
},
|
||||
);
|
||||
select_many(world, &entities);
|
||||
entities
|
||||
}
|
||||
|
||||
pub fn delete_entities_with_history(world: &mut World, entities: &[Entity]) {
|
||||
let mut deleted = Vec::new();
|
||||
for entity in entities {
|
||||
@@ -752,6 +780,12 @@ fn undo_command(world: &mut World, command: &mut EditorCommand) {
|
||||
despawn_entity(world, entity.take());
|
||||
clear_selection(world);
|
||||
}
|
||||
EditorCommand::SpawnMany { entities, .. } => {
|
||||
for entity in std::mem::take(entities) {
|
||||
despawn_entity(world, Some(entity));
|
||||
}
|
||||
clear_selection(world);
|
||||
}
|
||||
EditorCommand::Despawn { snapshot, entity } => {
|
||||
let spawned = spawn_snapshot(world, snapshot);
|
||||
*entity = Some(spawned);
|
||||
@@ -847,6 +881,17 @@ fn redo_command(world: &mut World, command: &mut EditorCommand) {
|
||||
*entity = Some(spawned);
|
||||
select_one(world, spawned);
|
||||
}
|
||||
EditorCommand::SpawnMany {
|
||||
snapshots,
|
||||
entities,
|
||||
} => {
|
||||
let spawned: Vec<Entity> = snapshots
|
||||
.iter()
|
||||
.map(|snapshot| spawn_snapshot(world, snapshot))
|
||||
.collect();
|
||||
*entities = spawned.clone();
|
||||
select_many(world, &spawned);
|
||||
}
|
||||
EditorCommand::Despawn { entity, .. } => {
|
||||
despawn_entity(world, entity.take());
|
||||
clear_selection(world);
|
||||
|
||||
Reference in new issue
Block a user