Skip to content

Commit

Permalink
Enhance undo impl2 (#63)
Browse files Browse the repository at this point in the history
* Added license comment.

* Enhance undo/redo for path deformation and drawable editing.

* - remember and undo "isSet" flags for undo/redo of DeformationParameterBinding.
- Undo work well with path deformation across different keypoints.
  • Loading branch information
seagetch authored Aug 10, 2022
1 parent 0629f5b commit 27f6b46
Show file tree
Hide file tree
Showing 5 changed files with 354 additions and 145 deletions.
91 changes: 91 additions & 0 deletions source/creator/actions/drawable.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
Copyright © 2020,2022 Inochi2D Project
Distributed under the 2-Clause BSD License, see LICENSE file.
*/
module creator.actions.drawable;
import creator.core.actionstack;
import creator.actions;
import creator;
import inochi2d;
import std.format;
import i18n;

/**
Action to add parameter to active puppet.
*/
class DrawableChangeAction : GroupAction, LazyBoundAction {
private:
void copy(ref MeshData src, ref MeshData dst) {
dst.vertices = src.vertices.dup;
dst.uvs = src.uvs.dup;
dst.indices = src.indices.dup;
dst.origin = src.origin;
}
public:
Drawable self;
string name;

MeshData oldMesh;
MeshData newMesh;

this(string name, Drawable self) {
super();
this.name = name;
this.self = self;
copy(self.getMesh(), oldMesh);
}

override
void updateNewState() {
copy(self.getMesh(), newMesh);
}

void addBinding(Parameter param, ParameterBinding binding) {
addAction(new ParameterBindingRemoveAction(param, binding));
}

/**
Rollback
*/
override
void rollback() {
self.rebuffer(oldMesh);
super.rollback();
}

/**
Redo
*/
override
void redo() {
self.rebuffer(newMesh);
super.redo();
}

/**
Describe the action
*/
override
string describe() {
return _("Changed drawable mesh of %s").format(self.name);
}

/**
Describe the action
*/
override
string describeUndo() {
return _("Drawable %s was changed").format(self.name);
}

/**
Gets name of this action
*/
override
string getName() {
return this.stringof;
}

override bool merge(Action other) { return false; }
override bool canMerge(Action other) { return false; }
}
126 changes: 0 additions & 126 deletions source/creator/actions/mesh.d

This file was deleted.

Loading

0 comments on commit 27f6b46

Please sign in to comment.