public sealed class EditMeshCommandOne undoable edit to one mesh, at whichever of the two granularities it needs.
Remarks
Doc 24's D3, and it is one command type with two shapes rather than two types. A position change — a gizmo drag on selected vertices — records the before and after positions of the elements it touched, and merges with the drag before it. A topology change — extrude, bevel, boolean, loop cut — records the whole mesh, before and after.
⚠ The second looks wasteful and is the only honest answer. A boolean has no inverse to record; a bevel with three segments touches every table in the structure; and an "undo" implemented as an inverse operation is a second implementation of every tool, which will disagree with the first. A blockout mesh is a few thousand vertices — tens of kilobytes — and CommandStack.Capacity defaults to 256, so the worst case is a few megabytes of history for a mesh nobody has that big.
⚠ State the bound rather than discovering it. A designer who spends an hour on one mesh generates the deep history this is measured against, and Capacity is settable for exactly that. A budget in bytes rather than in entries is the change to make if it is ever hit — recorded here so that it is a decision rather than a surprise.
⚠ The mesh is replaced on undo, not mutated back. The document holds a reference and so does everything drawing it, so putting the recorded object back is what makes a redo of a topology change exact — and it is why the recorded meshes are deep copies rather than the live one. A command that stored a reference where it needed a copy is precisely what Vixen.Editor.Core's randomised do/undo/redo suite exists to catch.
Fields and properties (2)
public string NameWhat this is called in the undo history, as a person would say it.
public bool IsTopologyWhether this one records the whole mesh rather than a handful of positions.
Methods (6)
public static EditMeshCommand Moved(SceneDocument document, Entity entity, ReadOnlySpan<int> positions, ReadOnlySpan<Vector3> was, string name = "Move Vertices")Records a move of some of a mesh's shared positions, already applied.
public static EditMeshCommand Rebuilt(SceneDocument document, Entity entity, EditMesh? was, string name = "Edit Mesh")Records a change that altered the mesh's structure, already applied.
public static EditMeshCommand Removed(SceneDocument document, Entity entity, string name = "Remove Mesh")Records an entity's geometry being taken away, before it is.
public void Do(EditorContext context)Applies the change.
public void Undo(EditorContext context)Puts back exactly what Do changed.
public bool TryMergeWith(IEditorCommand previous, out IEditorCommand? merged)
Used by (10)
- BlockoutBooleanVixen.Editor.Blockout
- BlockoutCreateVixen.Editor.Blockout
- BlockoutCubeGridVixen.Editor.Blockout
- BlockoutGeometryVixen.Editor.Blockout
- BlockoutHandoffVixen.Editor.Blockout
- BlockoutSurfacesVixen.Editor.Blockout
- EditMeshSceneTestsVixen.Editor.SceneView.Tests
- MeshEditVixen.Editor.SceneView
- MeshGizmoTargetVixen.Editor.SceneView
- SceneCloneVixen.Editor.SceneView