[Bf-blender-cvs] [a07922159d4] master: Fix T78527: GPencil Mirror modifier is inconsistent with Mesh Mirror (redo)

Philip Holzmann noreply at git.blender.org
Thu Jul 2 23:02:14 CEST 2020


Commit: a07922159d4abfeaca4db9b3f08b3f85e3a35ca9
Author: Philip Holzmann
Date:   Thu Jul 2 22:56:12 2020 +0200
Branches: master
https://developer.blender.org/rBa07922159d4abfeaca4db9b3f08b3f85e3a35ca9

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

===================================================================

M	source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c

===================================================================

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);
   }
 }



More information about the Bf-blender-cvs mailing list