Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2016-02-26 15:11:37 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2016-02-26 15:32:47 +0300
commitb594b25dadce40d03d4a47470cedcadf6d0a0a76 (patch)
treefe04ba2c35d63f1a498e8027a4c52843187c26de
parent9c474b187aaf866f2d4214246a5556f947a231a7 (diff)
Fix: "Twist" GP Sculpt brush in 2D Editors was unusable... now mostly usable, if still slightly offsetv2.77-rc1
-rw-r--r--source/blender/editors/gpencil/gpencil_brush.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c
index 3aa50d3edb9..efbb117ebe2 100644
--- a/source/blender/editors/gpencil/gpencil_brush.c
+++ b/source/blender/editors/gpencil/gpencil_brush.c
@@ -606,24 +606,32 @@ static bool gp_brush_twist_apply(tGP_BrushEditData *gso, bGPDstroke *gps, int i,
add_v3_v3v3(&pt->x, vec, gso->dvec); /* restore */
}
else {
- float tco[2], rco[2], nco[2];
- float rmat[2][2];
+ const float axis[3] = {0.0f, 0.0f, 1.0f};
+ float vec[3] = {0.0f};
+ float rmat[3][3];
/* Express position of point relative to cursor, ready to rotate */
- tco[0] = (float)(co[0] - gso->mval[0]);
- tco[1] = (float)(co[1] - gso->mval[1]);
+ // XXX: There is still some offset here, but it's close to working as expected...
+ vec[0] = (float)(co[0] - gso->mval[0]);
+ vec[1] = (float)(co[1] - gso->mval[1]);
- /* Rotate point in 2D */
- angle_to_mat2(rmat, angle);
- mul_v2_m2v2(rco, rmat, tco);
+ /* rotate point */
+ axis_angle_normalized_to_mat3(rmat, axis, angle);
+ mul_m3_v3(rmat, vec);
/* Convert back to screen-coordinates */
- nco[0] = rco[0] + (float)gso->mval[0];
- nco[1] = rco[1] + (float)gso->mval[1];
+ vec[0] += (float)gso->mval[0];
+ vec[1] += (float)gso->mval[1];
- /* Use coordinates "as-is" */
- // XXX: v2d scaling/offset?
- copy_v2_v2(&pt->x, nco);
+ /* Map from screen-coordinates to final coordinate space */
+ if (gps->flag & GP_STROKE_2DSPACE) {
+ View2D *v2d = gso->gsc.v2d;
+ UI_view2d_region_to_view(v2d, vec[0], vec[1], &pt->x, &pt->y);
+ }
+ else {
+ // XXX
+ copy_v2_v2(&pt->x, vec);
+ }
}
/* done */