GP: Primitive: Fix jitter
authorCharlie Jolly <mistajolly@gmail.com>
Wed, 19 Dec 2018 12:18:16 +0000 (12:18 +0000)
committerCharlie Jolly <mistajolly@gmail.com>
Wed, 19 Dec 2018 12:18:45 +0000 (12:18 +0000)
Missing vector calculation.

source/blender/editors/gpencil/gpencil_primitive.c

index d856c1859bbef25bd77366465398e420118b00ca..a2f9de3994090e10b2fbc72e216d6ce49cc6d5bf 100644 (file)
@@ -826,12 +826,27 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
                        /* exponential value */
                        const float exfactor = SQUARE(brush->gpencil_settings->draw_jitter + 2.0f);
                        const float fac = p2d->rnd[0] * exfactor * jitter;
                        /* exponential value */
                        const float exfactor = SQUARE(brush->gpencil_settings->draw_jitter + 2.0f);
                        const float fac = p2d->rnd[0] * exfactor * jitter;
+
+                       /* vector */
+                       float mvec[2], svec[2];;
+                       if (i > 0) {
+                               mvec[0] = (p2d->x - (p2d - 1)->x);
+                               mvec[1] = (p2d->y - (p2d - 1)->y);
+                               normalize_v2(mvec);
+                       }
+                       else {
+                               zero_v2(mvec);
+                       }
+                       svec[0] = -mvec[1];
+                       svec[1] = mvec[0];
+
                        if (p2d->rnd[0] > 0.5f) {
                        if (p2d->rnd[0] > 0.5f) {
-                               add_v2_fl(&p2d->x, -fac);
+                               mul_v2_fl(svec, -fac);
                        }
                        else {
                        }
                        else {
-                               add_v2_fl(&p2d->x, fac);
+                               mul_v2_fl(svec, fac);
                        }
                        }
+                       add_v2_v2(&p2d->x, svec);
                }
 
                /* apply randomness to pressure */
                }
 
                /* apply randomness to pressure */