[Bf-blender-cvs] [75ded99ff95] blender-v2.83-release: Fix T75811: GPencil Sculpt not working when use Subdivide

Antonio Vazquez noreply at git.blender.org
Fri Apr 17 19:42:11 CEST 2020


Commit: 75ded99ff959d5f0ef819bb726bcdbc0a5a2217e
Author: Antonio Vazquez
Date:   Fri Apr 17 19:35:24 2020 +0200
Branches: blender-v2.83-release
https://developer.blender.org/rB75ded99ff959d5f0ef819bb726bcdbc0a5a2217e

Fix T75811: GPencil Sculpt not working when use Subdivide

When use the subdivide modifier the number of points was not correct and can produce segment faults.

Also, the points were selected by default and this was wrong.

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

M	source/blender/blenkernel/intern/gpencil.c
M	source/blender/blenkernel/intern/gpencil_modifier.c
M	source/blender/editors/gpencil/gpencil_sculpt_paint.c

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

diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index a0fa07f4a41..041ef0503b9 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -1971,8 +1971,11 @@ void BKE_gpencil_frame_original_pointers_update(const struct bGPDframe *gpf_orig
         if (i > gps_eval->totpoints - 1) {
           break;
         }
+        bGPDspoint *pt_orig = &gps_orig->points[i];
         bGPDspoint *pt_eval = &gps_eval->points[i];
-        pt_eval->runtime.pt_orig = &gps_orig->points[i];
+        pt_orig->runtime.pt_orig = NULL;
+        pt_orig->runtime.idx_orig = i;
+        pt_eval->runtime.pt_orig = pt_orig;
         pt_eval->runtime.idx_orig = i;
       }
       /* Increase pointer. */
diff --git a/source/blender/blenkernel/intern/gpencil_modifier.c b/source/blender/blenkernel/intern/gpencil_modifier.c
index 0bb6ce84b1b..b732d9cdd4c 100644
--- a/source/blender/blenkernel/intern/gpencil_modifier.c
+++ b/source/blender/blenkernel/intern/gpencil_modifier.c
@@ -684,6 +684,7 @@ void BKE_gpencil_stroke_subdivide(bGPDstroke *gps, int level, int type)
       CLAMP(pt_final->strength, GPENCIL_STRENGTH_MIN, 1.0f);
       pt_final->time = interpf(pt->time, next->time, 0.5f);
       pt_final->runtime.pt_orig = NULL;
+      pt_final->flag = 0;
       interp_v4_v4v4(pt_final->vert_color, pt->vert_color, next->vert_color, 0.5f);
 
       if (gps->dvert != NULL) {
diff --git a/source/blender/editors/gpencil/gpencil_sculpt_paint.c b/source/blender/editors/gpencil/gpencil_sculpt_paint.c
index 7b6054e4156..f7f3b128351 100644
--- a/source/blender/editors/gpencil/gpencil_sculpt_paint.c
+++ b/source/blender/editors/gpencil/gpencil_sculpt_paint.c
@@ -1371,7 +1371,7 @@ static float gpsculpt_rotation_eval_get(tGP_BrushEditData *gso,
   }
 
   GP_SpaceConversion *gsc = &gso->gsc;
-  bGPDstroke *gps_orig = gps_eval->runtime.gps_orig;
+  bGPDstroke *gps_orig = (gps_eval->runtime.gps_orig) ? gps_eval->runtime.gps_orig : gps_eval;
   bGPDspoint *pt_orig = &gps_orig->points[pt_eval->runtime.idx_orig];
   bGPDspoint *pt_prev_eval = NULL;
   bGPDspoint *pt_orig_prev = NULL;
@@ -1422,6 +1422,7 @@ static bool gpsculpt_brush_do_stroke(tGP_BrushEditData *gso,
   GP_SpaceConversion *gsc = &gso->gsc;
   rcti *rect = &gso->brush_rect;
   Brush *brush = gso->brush;
+  char tool = gso->brush->gpencil_sculpt_tool;
   const int radius = (brush->flag & GP_BRUSH_USE_PRESSURE) ? gso->brush->size * gso->pressure :
                                                              gso->brush->size;
 
@@ -1501,9 +1502,12 @@ static bool gpsculpt_brush_do_stroke(tGP_BrushEditData *gso,
 
           /* To each point individually... */
           pt = &gps->points[i];
+          if ((pt->runtime.pt_orig == NULL) && (tool != GPSCULPT_TOOL_GRAB)) {
+            continue;
+          }
           pt_active = (pt->runtime.pt_orig) ? pt->runtime.pt_orig : pt;
           index = (pt->runtime.pt_orig) ? pt->runtime.idx_orig : i;
-          if (pt_active != NULL) {
+          if ((pt_active != NULL) && (index < gps_active->totpoints)) {
             rot_eval = gpsculpt_rotation_eval_get(gso, gps, pt, i);
             ok = apply(gso, gps_active, rot_eval, index, radius, pc1);
           }
@@ -1520,7 +1524,7 @@ static bool gpsculpt_brush_do_stroke(tGP_BrushEditData *gso,
             pt = &gps->points[i + 1];
             pt_active = (pt->runtime.pt_orig) ? pt->runtime.pt_orig : pt;
             index = (pt->runtime.pt_orig) ? pt->runtime.idx_orig : i + 1;
-            if (pt_active != NULL) {
+            if ((pt_active != NULL) && (index < gps_active->totpoints)) {
               rot_eval = gpsculpt_rotation_eval_get(gso, gps, pt, i + 1);
               ok |= apply(gso, gps_active, rot_eval, index, radius, pc2);
               include_last = false;
@@ -1541,7 +1545,7 @@ static bool gpsculpt_brush_do_stroke(tGP_BrushEditData *gso,
           pt = &gps->points[i];
           pt_active = (pt->runtime.pt_orig) ? pt->runtime.pt_orig : pt;
           index = (pt->runtime.pt_orig) ? pt->runtime.idx_orig : i;
-          if (pt_active != NULL) {
+          if ((pt_active != NULL) && (index < gps_active->totpoints)) {
             rot_eval = gpsculpt_rotation_eval_get(gso, gps, pt, i);
             changed |= apply(gso, gps_active, rot_eval, index, radius, pc1);
             include_last = false;



More information about the Bf-blender-cvs mailing list