[Bf-blender-cvs] [73cd6eb982f] temp-gpencil-bezier-stroke-type: GPencil: Fix bezier stroke weight painting

Falk David noreply at git.blender.org
Thu Apr 22 15:57:04 CEST 2021


Commit: 73cd6eb982faa26be512dc339be0bff504a1afeb
Author: Falk David
Date:   Thu Apr 22 15:56:55 2021 +0200
Branches: temp-gpencil-bezier-stroke-type
https://developer.blender.org/rB73cd6eb982faa26be512dc339be0bff504a1afeb

GPencil: Fix bezier stroke weight painting

The last element of a bezier stroke could not be weight painted.
This was because the checks use line segments to test for a hit and then
pick the first point of that segment to paint the weight. This causes the
problems for the last point.

Instead of testing of the segment is inside the circle, we just test
if the points are inside the circle.

Note that this should also be done for poly strokes at some point,
because it makes the code simpler.

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

M	source/blender/editors/gpencil/gpencil_weight_paint.c

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

diff --git a/source/blender/editors/gpencil/gpencil_weight_paint.c b/source/blender/editors/gpencil/gpencil_weight_paint.c
index 780c837915c..a1df9f88655 100644
--- a/source/blender/editors/gpencil/gpencil_weight_paint.c
+++ b/source/blender/editors/gpencil/gpencil_weight_paint.c
@@ -440,25 +440,19 @@ static void gpencil_weightpaint_select_curve(tGP_BrushWeightpaintData *gso,
   }
 
   /* If the curve has more than one control point... */
-  for (int i = 0; i < gpc->tot_curve_points - 1; i++) {
+  for (int i = 0; i < gpc->tot_curve_points; i++) {
     bGPDcurve_point *cpt = &gpc->curve_points[i];
-    bGPDcurve_point *cpt_next = &gpc->curve_points[i + 1];
     BezTriple *bezt = &cpt->bezt;
-    BezTriple *bezt_next = &cpt_next->bezt;
 
     int screen_co[2];
-    int screen_co2[2];
-
     /* Test if points can be projected. */
-    if (!(gpencil_3d_point_to_screen_space(region, rect, diff_mat, &bezt->vec[1], &screen_co) ||
-          gpencil_3d_point_to_screen_space(
-              region, rect, diff_mat, &bezt_next->vec[1], &screen_co2))) {
+    if (!gpencil_3d_point_to_screen_space(region, rect, diff_mat, bezt->vec[1], screen_co)) {
       continue;
     }
 
-    /* Test if the segment is in the circle. */
-    if (!gpencil_stroke_inside_circle(
-            gso->mval, radius, screen_co[0], screen_co[1], screen_co2[0], screen_co2[1])) {
+    float co[2] = {(float)screen_co[0], (float)screen_co[1]};
+    /* Test if the point is in the circle. */
+    if (len_v2v2(gso->mval, co) > radius) {
       continue;
     }



More information about the Bf-blender-cvs mailing list