Group brush clip history edits

This commit is contained in:
Rbanh committed 2026-06-06 14:19:35 -04:00
1 parent 48b1448c57
commit 1b9fbebda1
3 files changed
+75 -9

No files matched your search

+52
View File
@@ -499,6 +499,36 @@ pub fn set_brush_with_history(world: &mut World, entity: Entity, new: BrushDesc)
push_history(world, EditorCommand::SetBrush { entity, old, new });
}
pub fn set_brush_transform_with_history(
world: &mut World,
entity: Entity,
new_transform: Transform,
new_brush: BrushDesc,
) {
if !is_level_object(world, entity) {
return;
}
let old_transform = world.get::<Transform>(entity).copied().unwrap_or_default();
let old_brush = world.get::<BrushDesc>(entity).cloned();
if old_transform == new_transform && old_brush.as_ref() == Some(&new_brush) {
return;
}
if let Ok(mut entity_mut) = world.get_entity_mut(entity) {
entity_mut.insert(new_transform);
entity_mut.insert(new_brush.clone());
}
push_history(
world,
EditorCommand::SetBrushTransform {
entity,
old_transform,
new_transform,
old_brush,
new_brush,
},
);
}
pub fn set_static_mesh_renderer_with_history(
world: &mut World,
entity: Entity,
@@ -834,6 +864,17 @@ fn undo_command(world: &mut World, command: &mut EditorCommand) {
EditorCommand::SetBrush { entity, old, .. } => {
apply_brush(world, *entity, old);
}
EditorCommand::SetBrushTransform {
entity,
old_transform,
old_brush,
..
} => {
if let Some(mut transform) = world.get_mut::<Transform>(*entity) {
*transform = *old_transform;
}
apply_brush(world, *entity, old_brush);
}
EditorCommand::SetStaticMeshRenderer { entity, old, .. } => {
apply_static_mesh_renderer(world, *entity, old);
}
@@ -962,6 +1003,17 @@ fn redo_command(world: &mut World, command: &mut EditorCommand) {
entity_mut.insert(new.clone());
}
}
EditorCommand::SetBrushTransform {
entity,
new_transform,
new_brush,
..
} => {
if let Ok(mut entity_mut) = world.get_entity_mut(*entity) {
entity_mut.insert(*new_transform);
entity_mut.insert(new_brush.clone());
}
}
EditorCommand::SetStaticMeshRenderer { entity, new, .. } => {
if let Ok(mut entity_mut) = world.get_entity_mut(*entity) {
entity_mut.insert(new.clone());