Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/gpencil/gpencil_sculpt_paint.c
| Show First 20 Lines • Show All 1,456 Lines • ▼ Show 20 Lines | static bool gpencil_sculpt_brush_do_stroke(tGP_BrushEditData *gso, | ||||
| bool include_last = false; | bool include_last = false; | ||||
| bool changed = false; | bool changed = false; | ||||
| float rot_eval = 0.0f; | float rot_eval = 0.0f; | ||||
| if (gps->totpoints == 1) { | if (gps->totpoints == 1) { | ||||
| bGPDspoint pt_temp; | bGPDspoint pt_temp; | ||||
| pt = &gps->points[0]; | pt = &gps->points[0]; | ||||
| if ((is_masking && (pt->flag & GP_SPOINT_SELECT) != 0) || (!is_masking)) { | 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_world_space(gps->points, diff_mat, &pt_temp); | ||||
| gpencil_point_to_xy(gsc, gps, &pt_temp, &pc1[0], &pc1[1]); | gpencil_point_to_xy(gsc, gps, &pt_temp, &pc1[0], &pc1[1]); | ||||
| pt_active = (pt->runtime.pt_orig) ? pt->runtime.pt_orig : pt; | pt_active = (pt->runtime.pt_orig) ? pt->runtime.pt_orig : pt; | ||||
| /* Do bound-box check first. */ | /* Do bound-box check first. */ | ||||
| if ((!ELEM(V2D_IS_CLIPPED, pc1[0], pc1[1])) && BLI_rcti_isect_pt(rect, pc1[0], pc1[1])) { | if ((!ELEM(V2D_IS_CLIPPED, pc1[0], pc1[1])) && BLI_rcti_isect_pt(rect, pc1[0], pc1[1])) { | ||||
| /* only check if point is inside */ | /* only check if point is inside */ | ||||
| int mval_i[2]; | int mval_i[2]; | ||||
| round_v2i_v2fl(mval_i, gso->mval); | round_v2i_v2fl(mval_i, gso->mval); | ||||
| Show All 20 Lines | for (i = 0; (i + 1) < gps->totpoints; i++) { | ||||
| * (and we are only allowed to edit/consider selected points) */ | * (and we are only allowed to edit/consider selected points) */ | ||||
| if (GPENCIL_ANY_SCULPT_MASK(gso->mask)) { | if (GPENCIL_ANY_SCULPT_MASK(gso->mask)) { | ||||
| if (!(pt1->flag & GP_SPOINT_SELECT) && !(pt2->flag & GP_SPOINT_SELECT)) { | if (!(pt1->flag & GP_SPOINT_SELECT) && !(pt2->flag & GP_SPOINT_SELECT)) { | ||||
| include_last = false; | include_last = false; | ||||
| continue; | continue; | ||||
| } | } | ||||
| } | } | ||||
| bGPDspoint npt; | bGPDspoint npt; | ||||
| gpencil_point_to_parent_space(pt1, diff_mat, &npt); | gpencil_point_to_world_space(pt1, diff_mat, &npt); | ||||
| gpencil_point_to_xy(gsc, gps, &npt, &pc1[0], &pc1[1]); | gpencil_point_to_xy(gsc, gps, &npt, &pc1[0], &pc1[1]); | ||||
| gpencil_point_to_parent_space(pt2, diff_mat, &npt); | gpencil_point_to_world_space(pt2, diff_mat, &npt); | ||||
| gpencil_point_to_xy(gsc, gps, &npt, &pc2[0], &pc2[1]); | gpencil_point_to_xy(gsc, gps, &npt, &pc2[0], &pc2[1]); | ||||
| /* Check that point segment of the bound-box of the selection stroke. */ | /* Check that point segment of the bound-box of the selection stroke. */ | ||||
| if (((!ELEM(V2D_IS_CLIPPED, pc1[0], pc1[1])) && BLI_rcti_isect_pt(rect, pc1[0], pc1[1])) || | if (((!ELEM(V2D_IS_CLIPPED, pc1[0], pc1[1])) && BLI_rcti_isect_pt(rect, pc1[0], pc1[1])) || | ||||
| ((!ELEM(V2D_IS_CLIPPED, pc2[0], pc2[1])) && BLI_rcti_isect_pt(rect, pc2[0], pc2[1]))) { | ((!ELEM(V2D_IS_CLIPPED, pc2[0], pc2[1])) && BLI_rcti_isect_pt(rect, pc2[0], pc2[1]))) { | ||||
| /* Check if point segment of stroke had anything to do with | /* Check if point segment of stroke had anything to do with | ||||
| * brush region (either within stroke painted, or on its lines) | * brush region (either within stroke painted, or on its lines) | ||||
| * - this assumes that line-width is irrelevant. | * - this assumes that line-width is irrelevant. | ||||
| ▲ Show 20 Lines • Show All 284 Lines • ▼ Show 20 Lines | for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) { | ||||
| } | } | ||||
| bGPDspoint *pt1, *pt2; | bGPDspoint *pt1, *pt2; | ||||
| int pc1[2] = {0}; | int pc1[2] = {0}; | ||||
| int pc2[2] = {0}; | int pc2[2] = {0}; | ||||
| bGPDspoint npt; | bGPDspoint npt; | ||||
| if (gps->totpoints == 1) { | if (gps->totpoints == 1) { | ||||
| gpencil_point_to_parent_space(gps->points, bound_mat, &npt); | gpencil_point_to_world_space(gps->points, bound_mat, &npt); | ||||
| gpencil_point_to_xy(gsc, gps, &npt, &pc1[0], &pc1[1]); | gpencil_point_to_xy(gsc, gps, &npt, &pc1[0], &pc1[1]); | ||||
| /* Only check if point is inside. */ | /* Only check if point is inside. */ | ||||
| if (len_v2v2_int(mval_i, pc1) <= radius) { | if (len_v2v2_int(mval_i, pc1) <= radius) { | ||||
| BLI_ghash_insert(gso->automasking_strokes, gps, gps); | BLI_ghash_insert(gso->automasking_strokes, gps, gps); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* Loop over the points in the stroke, checking for intersections | /* Loop over the points in the stroke, checking for intersections | ||||
| * - an intersection means that we touched the stroke. | * - an intersection means that we touched the stroke. | ||||
| */ | */ | ||||
| for (int i = 0; (i + 1) < gps->totpoints; i++) { | for (int i = 0; (i + 1) < gps->totpoints; i++) { | ||||
| /* Get points to work with. */ | /* Get points to work with. */ | ||||
| pt1 = gps->points + i; | pt1 = gps->points + i; | ||||
| pt2 = gps->points + i + 1; | pt2 = gps->points + i + 1; | ||||
| /* Check first point. */ | /* Check first point. */ | ||||
| gpencil_point_to_parent_space(pt1, bound_mat, &npt); | gpencil_point_to_world_space(pt1, bound_mat, &npt); | ||||
| gpencil_point_to_xy(gsc, gps, &npt, &pc1[0], &pc1[1]); | gpencil_point_to_xy(gsc, gps, &npt, &pc1[0], &pc1[1]); | ||||
| if (len_v2v2_int(mval_i, pc1) <= radius) { | if (len_v2v2_int(mval_i, pc1) <= radius) { | ||||
| BLI_ghash_insert(gso->automasking_strokes, gps, gps); | BLI_ghash_insert(gso->automasking_strokes, gps, gps); | ||||
| i = gps->totpoints; | i = gps->totpoints; | ||||
| continue; | continue; | ||||
| } | } | ||||
| /* Check second point. */ | /* Check second point. */ | ||||
| gpencil_point_to_parent_space(pt2, bound_mat, &npt); | gpencil_point_to_world_space(pt2, bound_mat, &npt); | ||||
| gpencil_point_to_xy(gsc, gps, &npt, &pc2[0], &pc2[1]); | gpencil_point_to_xy(gsc, gps, &npt, &pc2[0], &pc2[1]); | ||||
| if (len_v2v2_int(mval_i, pc2) <= radius) { | if (len_v2v2_int(mval_i, pc2) <= radius) { | ||||
| BLI_ghash_insert(gso->automasking_strokes, gps, gps); | BLI_ghash_insert(gso->automasking_strokes, gps, gps); | ||||
| i = gps->totpoints; | i = gps->totpoints; | ||||
| continue; | continue; | ||||
| } | } | ||||
| /* Check segment. */ | /* Check segment. */ | ||||
| ▲ Show 20 Lines • Show All 494 Lines • Show Last 20 Lines | |||||