Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/gpencil/gpencil_paint.c
| Show First 20 Lines • Show All 1,131 Lines • ▼ Show 20 Lines | if (totelem == 2) { | ||||
| } | } | ||||
| } | } | ||||
| /* reproject to plane (only in 3d space) */ | /* reproject to plane (only in 3d space) */ | ||||
| gpencil_reproject_toplane(p, gps); | gpencil_reproject_toplane(p, gps); | ||||
| pt = gps->points; | pt = gps->points; | ||||
| for (int i = 0; i < gps->totpoints; i++, pt++) { | for (int i = 0; i < gps->totpoints; i++, pt++) { | ||||
| /* if parented change position relative to parent object */ | /* if parented change position relative to parent object */ | ||||
| gpencil_apply_parent_point(depsgraph, obact, gpl, pt); | gpencil_world_to_object_space_point(depsgraph, obact, gpl, pt); | ||||
| } | } | ||||
| /* If camera view or view projection, reproject flat to view to avoid perspective effect. */ | /* If camera view or view projection, reproject flat to view to avoid perspective effect. */ | ||||
| if ((!is_depth) && | if ((!is_depth) && | ||||
| (((align_flag & GP_PROJECT_VIEWSPACE) && is_lock_axis_view) || (is_camera))) { | (((align_flag & GP_PROJECT_VIEWSPACE) && is_lock_axis_view) || (is_camera))) { | ||||
| ED_gpencil_project_stroke_to_view(p->C, p->gpl, gps); | ED_gpencil_project_stroke_to_view(p->C, p->gpl, gps); | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 148 Lines • ▼ Show 20 Lines | else { | ||||
| if ((brush->gpencil_settings->flag & GP_BRUSH_GROUP_SETTINGS) && | if ((brush->gpencil_settings->flag & GP_BRUSH_GROUP_SETTINGS) && | ||||
| (brush->gpencil_settings->flag & GP_BRUSH_OUTLINE_STROKE)) { | (brush->gpencil_settings->flag & GP_BRUSH_OUTLINE_STROKE)) { | ||||
| gps = gpencil_stroke_to_outline(p, gps); | gps = gpencil_stroke_to_outline(p, gps); | ||||
| } | } | ||||
| /* reproject to plane (only in 3d space) */ | /* reproject to plane (only in 3d space) */ | ||||
| gpencil_reproject_toplane(p, gps); | gpencil_reproject_toplane(p, gps); | ||||
| /* change position relative to parent object */ | /* change position relative to parent object */ | ||||
| gpencil_apply_parent(depsgraph, obact, gpl, gps); | gpencil_world_to_object_space(depsgraph, obact, gpl, gps); | ||||
| /* If camera view or view projection, reproject flat to view to avoid perspective effect. */ | /* If camera view or view projection, reproject flat to view to avoid perspective effect. */ | ||||
| if ((!is_depth) && (((align_flag & GP_PROJECT_VIEWSPACE) && is_lock_axis_view) || is_camera)) { | if ((!is_depth) && (((align_flag & GP_PROJECT_VIEWSPACE) && is_lock_axis_view) || is_camera)) { | ||||
| ED_gpencil_project_stroke_to_view(p->C, p->gpl, gps); | ED_gpencil_project_stroke_to_view(p->C, p->gpl, gps); | ||||
| } | } | ||||
| if (depth_arr) { | if (depth_arr) { | ||||
| MEM_freeN(depth_arr); | MEM_freeN(depth_arr); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 232 Lines • ▼ Show 20 Lines | static void gpencil_stroke_eraser_dostroke(tGPsdata *p, | ||||
| if (gps->totpoints == 0) { | if (gps->totpoints == 0) { | ||||
| /* just free stroke */ | /* just free stroke */ | ||||
| gpencil_free_stroke(p->gpd, gpf, gps); | gpencil_free_stroke(p->gpd, gpf, gps); | ||||
| } | } | ||||
| else if (gps->totpoints == 1) { | else if (gps->totpoints == 1) { | ||||
| /* only process if it hasn't been masked out... */ | /* only process if it hasn't been masked out... */ | ||||
| if (!(p->flags & GP_PAINTFLAG_SELECTMASK) || (gps->points->flag & GP_SPOINT_SELECT)) { | if (!(p->flags & GP_PAINTFLAG_SELECTMASK) || (gps->points->flag & GP_SPOINT_SELECT)) { | ||||
| bGPDspoint pt_temp; | bGPDspoint pt_temp; | ||||
| gpencil_point_to_parent_space(gps->points, p->diff_mat, &pt_temp); | gpencil_point_to_world_space(gps->points, p->diff_mat, &pt_temp); | ||||
| gpencil_point_to_xy(&p->gsc, gps, &pt_temp, &pc1[0], &pc1[1]); | gpencil_point_to_xy(&p->gsc, gps, &pt_temp, &pc1[0], &pc1[1]); | ||||
| /* 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 */ | ||||
| if (len_v2v2_int(mval_i, pc1) <= radius) { | if (len_v2v2_int(mval_i, pc1) <= radius) { | ||||
| /* free stroke */ | /* free stroke */ | ||||
| gpencil_free_stroke(p->gpd, gpf, gps); | gpencil_free_stroke(p->gpd, gpf, gps); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else if ((p->flags & GP_PAINTFLAG_STROKE_ERASER) || | else if ((p->flags & GP_PAINTFLAG_STROKE_ERASER) || | ||||
| (eraser->gpencil_settings->eraser_mode == GP_BRUSH_ERASER_STROKE)) { | (eraser->gpencil_settings->eraser_mode == GP_BRUSH_ERASER_STROKE)) { | ||||
| for (i = 0; (i + 1) < gps->totpoints; i++) { | for (i = 0; (i + 1) < gps->totpoints; i++) { | ||||
| /* only process if it hasn't been masked out... */ | /* only process if it hasn't been masked out... */ | ||||
| if ((p->flags & GP_PAINTFLAG_SELECTMASK) && !(gps->points->flag & GP_SPOINT_SELECT)) { | if ((p->flags & GP_PAINTFLAG_SELECTMASK) && !(gps->points->flag & GP_SPOINT_SELECT)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| /* get points to work with */ | /* get points to work with */ | ||||
| pt1 = gps->points + i; | pt1 = gps->points + i; | ||||
| bGPDspoint npt; | bGPDspoint npt; | ||||
| gpencil_point_to_parent_space(pt1, p->diff_mat, &npt); | gpencil_point_to_world_space(pt1, p->diff_mat, &npt); | ||||
| gpencil_point_to_xy(&p->gsc, gps, &npt, &pc1[0], &pc1[1]); | gpencil_point_to_xy(&p->gsc, gps, &npt, &pc1[0], &pc1[1]); | ||||
| /* 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 */ | ||||
| if (len_v2v2_int(mval_i, pc1) <= radius) { | if (len_v2v2_int(mval_i, pc1) <= radius) { | ||||
| /* free stroke */ | /* free stroke */ | ||||
| gpencil_free_stroke(p->gpd, gpf, gps); | gpencil_free_stroke(p->gpd, gpf, gps); | ||||
| ▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | for (i = 0; (i + 1) < gps->totpoints; i++) { | ||||
| float inf2 = 0.0f; | float inf2 = 0.0f; | ||||
| /* only process if it hasn't been masked out... */ | /* only process if it hasn't been masked out... */ | ||||
| if ((p->flags & GP_PAINTFLAG_SELECTMASK) && !(gps->points->flag & GP_SPOINT_SELECT)) { | if ((p->flags & GP_PAINTFLAG_SELECTMASK) && !(gps->points->flag & GP_SPOINT_SELECT)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| bGPDspoint npt; | bGPDspoint npt; | ||||
| gpencil_point_to_parent_space(pt1, p->diff_mat, &npt); | gpencil_point_to_world_space(pt1, p->diff_mat, &npt); | ||||
| gpencil_point_to_xy(&p->gsc, gps, &npt, &pc1[0], &pc1[1]); | gpencil_point_to_xy(&p->gsc, gps, &npt, &pc1[0], &pc1[1]); | ||||
| gpencil_point_to_parent_space(pt2, p->diff_mat, &npt); | gpencil_point_to_world_space(pt2, p->diff_mat, &npt); | ||||
| gpencil_point_to_xy(&p->gsc, gps, &npt, &pc2[0], &pc2[1]); | gpencil_point_to_xy(&p->gsc, gps, &npt, &pc2[0], &pc2[1]); | ||||
| if (pt0) { | if (pt0) { | ||||
| gpencil_point_to_parent_space(pt0, p->diff_mat, &npt); | gpencil_point_to_world_space(pt0, p->diff_mat, &npt); | ||||
| gpencil_point_to_xy(&p->gsc, gps, &npt, &pc0[0], &pc0[1]); | gpencil_point_to_xy(&p->gsc, gps, &npt, &pc0[0], &pc0[1]); | ||||
| } | } | ||||
| else { | else { | ||||
| /* avoid null values */ | /* avoid null values */ | ||||
| copy_v2_v2_int(pc0, pc1); | copy_v2_v2_int(pc0, pc1); | ||||
| } | } | ||||
| /* Check that point segment of the bound-box of the eraser stroke. */ | /* Check that point segment of the bound-box of the eraser stroke. */ | ||||
| ▲ Show 20 Lines • Show All 2,391 Lines • Show Last 20 Lines | |||||