diff options
author | Antonio Vazquez <blendergit@gmail.com> | 2020-04-17 20:35:24 +0300 |
---|---|---|
committer | Antonio Vazquez <blendergit@gmail.com> | 2020-04-17 20:41:57 +0300 |
commit | 75ded99ff959d5f0ef819bb726bcdbc0a5a2217e (patch) | |
tree | 1546ed0dda71d18d98ac4eef49252a8369ecf963 /source/blender/editors/gpencil/gpencil_sculpt_paint.c | |
parent | e4915730605568816033a141af28bd27124e3abf (diff) |
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.
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_sculpt_paint.c')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_sculpt_paint.c | 12 |
1 files changed, 8 insertions, 4 deletions
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; |