Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multi-edit: Fix bugs: transformation matrix is not updated when T/R/S is changed during edit of armed parameter. #165

Merged
merged 18 commits into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
64b832a
Hides handles for T/R/S if more than one nodes are selected.
seagetch Dec 28, 2022
34b3194
multiselect-edit: Multiple part can be deformed at once (WIP)
seagetch Jan 2, 2023
daac083
multiselect-edit: Fix node selection handling for 'arm parameter'.
seagetch Jan 3, 2023
063ac9e
multiselect-edit: Adjust Path deformer to ignore Translation / Rotati…
seagetch Jan 3, 2023
3fe84dd
multiselect-edit: Grouping deformation of several parts into one when…
seagetch Jan 3, 2023
4681259
multiselect-edit: update path deformer when parameter is changed.
seagetch Jan 4, 2023
c2a194b
Merge branch 'main' of https://github.com/Inochi2D/inochi-creator int…
seagetch Jan 5, 2023
e6f698e
multi-edit: implemented Path Deformation for non-Drawable Node Object.
seagetch Jan 10, 2023
1e8be41
Merge branch 'main' of https://github.com/Inochi2D/inochi-creator int…
seagetch Jan 11, 2023
40ab3af
multi-edit: fixed crash bug, and some fix for undos.
seagetch Jan 12, 2023
8ef55da
multi-edit: Revised Undos.
seagetch Jan 14, 2023
61ed1a5
multi-edit: fix wrong undo history management for MeshEditor.
seagetch Jan 17, 2023
8b9bb42
Removed debug print.
seagetch Jan 17, 2023
812759c
Merge branch 'main' of https://github.com/Inochi2D/inochi-creator int…
seagetch Jan 17, 2023
d8ce97c
multi-edit: force reset undo when adjustPathTransformation is called.
seagetch Jan 17, 2023
5c81053
multi-edit: Fix bugs that transformation matrix is not updated when T…
seagetch Jan 19, 2023
c5a42f0
Merge branch 'main' of https://github.com/Inochi2D/inochi-creator int…
seagetch Jan 19, 2023
da8f9db
Deleted some unused codes.
seagetch Jan 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions source/creator/panels/inspector.d
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
module creator.panels.inspector;
import creator.viewport.vertex;
import creator.viewport.model.deform;
import creator.core;
import creator.panels;
import creator.widgets;
Expand Down Expand Up @@ -1154,6 +1155,12 @@ void incInspectorDeformFloatDragVal(string name, string paramName, float adjustS
} else {
incActionPush(action);
}

if (auto editor = incViewportModelDeformGetEditor()) {
if (auto e = editor.getEditorFor(node)) {
e.adjustPathTransform();
}
}
}
}

Expand Down Expand Up @@ -1297,6 +1304,12 @@ void incInspectorDeformSetValue(Node node, Parameter param, string paramName, ve
} else {
incActionPush(action);
}

if (auto editor = incViewportModelDeformGetEditor()) {
if (auto e = editor.getEditorFor(node)) {
e.adjustPathTransform();
}
}
}

void incInspectorDeformTRS(Node node, Parameter param, vec2u cursor) {
Expand Down
12 changes: 8 additions & 4 deletions source/creator/viewport/common/mesheditor.d
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,6 @@ public:
mousePos = incInputGetMousePosition();
if (deformOnly) {
vec4 pIn = vec4(-mousePos.x, -mousePos.y, 0, 1);
// mat4 tr = target.transform.matrix().inverse();
mat4 tr = transform.inverse();
vec4 pOut = tr * pIn;
mousePos = vec2(pOut.x, pOut.y);
Expand Down Expand Up @@ -894,7 +893,7 @@ public:

override
void removeVertexAt(vec2 vertex) {
mesh.removeVertexAt(vertex); // mirror(axis, mousePos)
mesh.removeVertexAt(vertex);
}

override
Expand Down Expand Up @@ -1111,7 +1110,12 @@ public:

override
void adjustPathTransform() {
mat4 trans = (target? target.transform.matrix: transform).inverse * transform;
ref CatmullSpline doAdjust(ref CatmullSpline p) {
for (int i; i < p.points.length; i++) {
p.points[i].position = (trans * vec4(p.points[i].position, 0, 1)).xy;
}
p.update();
remapPathTarget(p, mat4.identity);
return p;
}
Expand All @@ -1120,6 +1124,8 @@ public:
path.target = doAdjust(path.target);
path = doAdjust(path);
}
lastMousePos = (trans * vec4(lastMousePos, 0, 1)).xy;
transform = this.target.transform.matrix;
forceResetAction();
}

Expand Down Expand Up @@ -1148,7 +1154,6 @@ public:
override
void setTarget(Node target) {
super.setTarget(target);
// transform = (target && target.parent()) ? target.parent().transform.matrix : mat4.identity;
transform = target? target.transform.matrix : mat4.identity;
refreshMesh();
}
Expand Down Expand Up @@ -1391,7 +1396,6 @@ public:

if (vtxAtMouse !is null && !isSelecting) {
MeshVertex*[] one = [vtxAtMouse];
// mesh.drawPointSubset(one, vec4(1, 1, 1, 0.3), trans, 15);
}

if (isSelecting) {
Expand Down
13 changes: 0 additions & 13 deletions source/creator/viewport/model/deform.d
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,6 @@ void incViewportNodeDeformNotifyParamValueChanged() {
e.adjustPathTransform();
}
}
/*
foreach (d; drawables) {
if (Drawable drawable = cast(Drawable)d) {
DeformationParameterBinding deform = cast(DeformationParameterBinding)param.getBinding(drawable, "deform");
if (deform) {
auto binding = deform.getValue(param.findClosestKeypoint());
auto e = editor.getEditorFor(drawable);
e.applyOffsets(binding.vertexOffsets);
e.adjustPathTransform();
}
}
}
*/
} else {
editor = null;
}
Expand Down
6 changes: 6 additions & 0 deletions source/creator/viewport/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import creator.core.input;
import creator.actions;
import creator.viewport;
import creator.viewport.model;
import creator.viewport.model.deform;
import creator.viewport.vertex;
import creator.viewport.anim;
import creator.viewport.test;
Expand Down Expand Up @@ -339,6 +340,11 @@ void incViewportTransformHandle() {
param.addBinding(b);
status.actions["Add"]= new ParameterBindingAddAction(param, b);
}
if (auto editor = incViewportModelDeformGetEditor()) {
if (auto e = editor.getEditorFor(node)) {
e.adjustPathTransform();
}
}
// Push action
if (paramName !in status.actions)
status.actions[paramName] = new ParameterBindingValueChangeAction!(float)(b.getName(), b, index.x, index.y);
Expand Down