Group brush clip history edits
This commit is contained in:
1 parent
48b1448c57
commit
1b9fbebda1
3 files changed
+75
-9
No files matched your search
@@ -112,6 +112,13 @@ pub enum EditorCommand {
|
||||
old: Option<BrushDesc>,
|
||||
new: BrushDesc,
|
||||
},
|
||||
SetBrushTransform {
|
||||
entity: Entity,
|
||||
old_transform: Transform,
|
||||
new_transform: Transform,
|
||||
old_brush: Option<BrushDesc>,
|
||||
new_brush: BrushDesc,
|
||||
},
|
||||
SetStaticMeshRenderer {
|
||||
entity: Entity,
|
||||
old: Option<StaticMeshRenderer>,
|
||||
@@ -177,6 +184,7 @@ impl EditorCommand {
|
||||
EditorCommand::SetCollider { .. } => "Set Collider",
|
||||
EditorCommand::SetPrimitive { .. } => "Set Primitive",
|
||||
EditorCommand::SetBrush { .. } => "Set Brush",
|
||||
EditorCommand::SetBrushTransform { .. } => "Clip Brush",
|
||||
EditorCommand::SetStaticMeshRenderer { .. } => "Set Static Mesh Renderer",
|
||||
EditorCommand::SetPostProcessVolume { .. } => "Set Post Process Volume",
|
||||
EditorCommand::SetTransformGroup { .. } => "Move Selection",
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in new issue
Block a user