UsdLayerManager/openspec/changes/undo-redo-scene-editing/specs/undoable-scene-edits/spec.md

38 lines
2.3 KiB
Markdown

## ADDED Requirements
### Requirement: Prim creation is undoable
The system SHALL push a `CreatePrimCommand` to `CommandHistory` when a prim is created via the scene hierarchy context menu. `Undo()` SHALL remove the created prim from the stage. `Redo()` SHALL re-create the prim with the same path and type.
#### Scenario: Undo removes created prim
- **WHEN** the user creates a Sphere prim and then presses Ctrl+Z
- **THEN** the Sphere prim no longer appears in the scene hierarchy
#### Scenario: Redo re-creates the prim
- **WHEN** the user undoes a prim creation and then presses Ctrl+Y
- **THEN** the Sphere prim reappears at the same path with the same type
### Requirement: Prim deletion is undoable
The system SHALL push a `DeletePrimCommand` to `CommandHistory` when a prim is deleted via the scene hierarchy confirm modal. Before deletion, the command SHALL serialize the prim spec (including all authored opinions on the edit-target layer) to an in-memory string. `Undo()` SHALL restore the serialized spec to the layer.
#### Scenario: Undo restores deleted prim
- **WHEN** the user deletes a prim and then presses Ctrl+Z
- **THEN** the prim reappears in the scene hierarchy with all its authored attributes intact
#### Scenario: Redo re-deletes the prim
- **WHEN** the user undoes a deletion and then presses Ctrl+Y
- **THEN** the prim is deleted again
### Requirement: Add-reference is undoable
The system SHALL push an `AddReferenceCommand` to `CommandHistory` when an external USD file is added as a reference. `Undo()` SHALL remove the reference (and the wrapping Xform prim if it was created by the add-reference operation). `Redo()` SHALL re-add the reference.
#### Scenario: Undo removes added reference
- **WHEN** the user adds a reference to an external file and then presses Ctrl+Z
- **THEN** the reference prim is removed from the scene hierarchy
### Requirement: Replace-reference is undoable
The system SHALL push a `ReplaceReferenceCommand` to `CommandHistory` when an existing reference is replaced via the scene hierarchy. `Undo()` SHALL restore the previous `SdfReference`. `Redo()` SHALL apply the replacement again.
#### Scenario: Undo restores previous reference path
- **WHEN** the user replaces a reference and then presses Ctrl+Z
- **THEN** the prim points back to the original reference file