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.
This commit is contained in:
@@ -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. */
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user