Fix T99248: GPencil Sculpt Grab/Push don't work with one point

There were two problems:

1) The checking of the collision was not working with one point only.
2) For one point, the masking was checked always and if the masking was not activated, the stroke was skipped.
This commit is contained in:
Antonio Vazquez
2022-06-29 16:03:55 +02:00
parent a5ac0375b0
commit b708f45922

View File

@@ -1161,6 +1161,7 @@ static bool gpencil_sculpt_brush_init(bContext *C, wmOperator *op)
gso->is_painting = false;
gso->first = true;
gso->mval_prev[0] = -1.0f;
gso->gpd = ED_gpencil_data_get_active(C);
gso->cfra = INT_MAX; /* NOTE: So that first stroke will get handled in init_stroke() */
@@ -1442,6 +1443,7 @@ static bool gpencil_sculpt_brush_do_stroke(tGP_BrushEditData *gso,
char tool = gso->brush->gpencil_sculpt_tool;
const int radius = (brush->flag & GP_BRUSH_USE_PRESSURE) ? gso->brush->size * gso->pressure :
gso->brush->size;
const bool is_masking = GPENCIL_ANY_SCULPT_MASK(gso->mask);
bGPDstroke *gps_active = (gps->runtime.gps_orig) ? gps->runtime.gps_orig : gps;
bGPDspoint *pt_active = NULL;
@@ -1459,7 +1461,7 @@ static bool gpencil_sculpt_brush_do_stroke(tGP_BrushEditData *gso,
if (gps->totpoints == 1) {
bGPDspoint pt_temp;
pt = &gps->points[0];
if (GPENCIL_ANY_SCULPT_MASK(gso->mask) && (pt->flag & GP_SPOINT_SELECT) != 0) {
if ((is_masking && (pt->flag & GP_SPOINT_SELECT) != 0) || (!is_masking)) {
gpencil_point_to_parent_space(gps->points, diff_mat, &pt_temp);
gpencil_point_to_xy(gsc, gps, &pt_temp, &pc1[0], &pc1[1]);
@@ -1618,7 +1620,8 @@ static bool gpencil_sculpt_brush_do_frame(bContext *C,
}
/* Check if the stroke collide with brush. */
if (!ED_gpencil_stroke_check_collision(gsc, gps, gso->mval, radius, bound_mat)) {
if ((gps->totpoints > 1) &&
(!ED_gpencil_stroke_check_collision(gsc, gps, gso->mval, radius, bound_mat))) {
continue;
}
@@ -1982,7 +1985,7 @@ static void gpencil_sculpt_brush_apply(bContext *C, wmOperator *op, PointerRNA *
}
/* Store coordinates as reference, if operator just started running */
if (gso->first) {
if (gso->mval_prev[0] == -1.0f) {
gso->mval_prev[0] = gso->mval[0];
gso->mval_prev[1] = gso->mval[1];
gso->pressure_prev = gso->pressure;