[Bf-blender-cvs] [806d4fbc5e4] master: GPencil: Fix mirror modifier rotation around object
Antonioya
noreply at git.blender.org
Wed Jun 5 15:55:35 CEST 2019
Commit: 806d4fbc5e4070209b9aa6942dc345aa1d61f20c
Author: Antonioya
Date: Wed Jun 5 15:54:22 2019 +0200
Branches: master
https://developer.blender.org/rB806d4fbc5e4070209b9aa6942dc345aa1d61f20c
GPencil: Fix mirror modifier rotation around object
Still pending when the original object is rotated or scaled.
===================================================================
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 a3052b4f6b6..058f60a69ac 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c
@@ -78,12 +78,15 @@ static void update_position(Object *ob, MirrorGpencilModifierData *mmd, bGPDstro
float ob_origin[3];
float pt_origin[3];
+ float half_origin[3];
+ float rot_mat[3][3];
if (mmd->object) {
- float inv_mat[4][4];
-
- invert_m4_m4(inv_mat, mmd->object->obmat);
- mul_v3_m4v3(ob_origin, inv_mat, ob->obmat[3]);
+ float eul[3];
+ mat4_to_eul(eul, mmd->object->obmat);
+ mul_v3_fl(eul, 2.0f);
+ eul_to_mat3(rot_mat, eul);
+ sub_v3_v3v3(ob_origin, ob->obmat[3], mmd->object->obmat[3]);
}
else {
copy_v3_v3(ob_origin, ob->obmat[3]);
@@ -93,11 +96,18 @@ static void update_position(Object *ob, MirrorGpencilModifierData *mmd, bGPDstro
mul_v3_v3(ob_origin, clear);
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++) {
mul_v3_v3(&pt->x, factor);
if (mmd->object) {
+ /* 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);
}
}
}
More information about the Bf-blender-cvs
mailing list