diff options
author | Philip Holzmann <Foaly> | 2020-07-02 23:56:12 +0300 |
---|---|---|
committer | Antonio Vazquez <blendergit@gmail.com> | 2020-07-03 00:02:02 +0300 |
commit | a07922159d4abfeaca4db9b3f08b3f85e3a35ca9 (patch) | |
tree | 596ccdafc7462359ed557c6cc13c5a51ab548c22 /source | |
parent | 1278657cc2d8d7f3cd16d61cac34bbaa336d3dcf (diff) |
Fix T78527: GPencil Mirror modifier is inconsistent with Mesh Mirror (redo)
Simply the same code the regular mesh mirror modifier uses.
Differential Revision: https://developer.blender.org/D8188
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c | 61 |
1 files changed, 13 insertions, 48 deletions
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c index 2105eb0304c..c99ca64325c 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c @@ -97,54 +97,19 @@ static void update_mirror_object(Object *ob, bGPDstroke *gps, int axis) { - /* Calculate local matrix transformation. */ - float mat[3][3], inv_mat[3][3]; - BKE_object_to_mat3(ob, mat); - invert_m3_m3(inv_mat, mat); - - int i; - bGPDspoint *pt; - float factor[3] = {1.0f, 1.0f, 1.0f}; - factor[axis] = -1.0f; - - float clear[3] = {0.0f, 0.0f, 0.0f}; - clear[axis] = 1.0f; - - float ob_origin[3]; - float pt_origin[3]; - float half_origin[3]; - float rot_mat[3][3]; - - float eul[3]; - mat4_to_eul(eul, mmd->object->obmat); - mul_v3_fl(eul, 2.0f); - /* Don't apply rotation to current axis. */ - eul[axis] = 0.0f; - eul_to_mat3(rot_mat, eul); - sub_v3_v3v3(ob_origin, ob->obmat[3], mmd->object->obmat[3]); - - /* Only works with current axis. */ - mul_v3_v3(ob_origin, clear); - - /* Invert the origin. */ - mul_v3_v3fl(pt_origin, ob_origin, -2.0f); - mul_v3_v3fl(half_origin, pt_origin, 0.5f); - - for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { - /* Apply any local transformation. */ - mul_m3_v3(mat, &pt->x); - - /* Apply mirror effect. */ - mul_v3_v3(&pt->x, factor); - /* Apply location. */ - add_v3_v3(&pt->x, pt_origin); - /* Apply rotation (around new center). */ - sub_v3_v3(&pt->x, half_origin); - mul_m3_v3(rot_mat, &pt->x); - add_v3_v3(&pt->x, half_origin); - - /* Undo local transformation to avoid double transform in drawing. */ - mul_m3_v3(inv_mat, &pt->x); + float mtx[4][4]; + unit_m4(mtx); + mtx[axis][axis] = -1.0f; + + float tmp[4][4]; + float itmp[4][4]; + invert_m4_m4(tmp, mmd->object->obmat); + mul_m4_m4m4(tmp, tmp, ob->obmat); + invert_m4_m4(itmp, tmp); + mul_m4_series(mtx, itmp, mtx, tmp); + + for (int i = 0; i < gps->totpoints; i++) { + mul_m4_v3(mtx, &gps->points[i].x); } } |