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:
authorAntonio Vazquez <blendergit@gmail.com>2020-02-07 18:35:26 +0300
committerAntonio Vazquez <blendergit@gmail.com>2020-02-07 18:36:23 +0300
commit677e027f2069dac18891db931c860542cbcb4bbe (patch)
tree59bc9d61b89e97bf30a2f82c5ed1f2d03c83a6dd /source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c
parentfaf08954d572c84d42de074effbca02fee3b27df (diff)
Fix T73625: GPencil array offset wrong whe use Scale or Rotation
This is not 100% a bug but a design change. The old method used the object origin as pivot point for Scale a nd Rotation, so when you moved the stroke in edit mode, the whole array ittems where offset because the pivot point distance changed. Now, before applying scale and rotation, the stroke is moved to object origin to keep the offset when scale or rotate, so these transformations are done in stroke local space.
Diffstat (limited to 'source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c')
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c
index bb70b548675..e258fbdccd1 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c
@@ -228,24 +228,34 @@ static void generate_geometry(GpencilModifierData *md,
for (gps = gpf->strokes.first, idx = 0; gps; gps = gps->next, idx++) {
/* check if stroke can be duplicated */
if (valid_strokes[idx]) {
- /* Duplicate stroke */
- bGPDstroke *gps_dst = MEM_dupallocN(gps);
- gps_dst->points = MEM_dupallocN(gps->points);
- if (gps->dvert) {
- gps_dst->dvert = MEM_dupallocN(gps->dvert);
- BKE_gpencil_stroke_weights_duplicate(gps, gps_dst);
+ /* Calculate original stroke center (only first loop). */
+ float r_min[3], r_max[3], center[3];
+ if (x == 1) {
+ INIT_MINMAX(r_min, r_max);
+ BKE_gpencil_stroke_minmax(gps, false, r_min, r_max);
+ add_v3_v3v3(center, r_min, r_max);
+ mul_v3_fl(center, 0.5f);
+ sub_v3_v3v3(center, center, ob->obmat[3]);
}
- gps_dst->triangles = MEM_dupallocN(gps->triangles);
+
+ /* Duplicate stroke */
+ bGPDstroke *gps_dst = BKE_gpencil_stroke_duplicate(gps);
/* Move points */
for (int i = 0; i < gps->totpoints; i++) {
bGPDspoint *pt = &gps_dst->points[i];
+ /* Apply object local transform (Rot/Scale). */
if (mmd->object) {
- /* apply local changes (rot/scale) */
mul_m4_v3(mat, &pt->x);
}
- /* global changes */
- mul_m4_v3(current_offset, &pt->x);
+ /* Translate to object origin. */
+ float fpt[3];
+ sub_v3_v3v3(fpt, &pt->x, center);
+ /* Global Rotate and scale. */
+ mul_mat3_m4_v3(current_offset, fpt);
+ /* Global translate. */
+ add_v3_v3(fpt, center);
+ add_v3_v3v3(&pt->x, fpt, current_offset[3]);
}
/* if replace material, use new one */