Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/mask/mask_query.c
| Show First 20 Lines • Show All 598 Lines • ▼ Show 20 Lines | else { | ||||
| BLI_assert(0); | BLI_assert(0); | ||||
| zero_v2(co); | zero_v2(co); | ||||
| } | } | ||||
| *xr = co[0]; | *xr = co[0]; | ||||
| *yr = co[1]; | *yr = co[1]; | ||||
| } | } | ||||
| bool ED_mask_selected_minmax(const bContext *C, float min[2], float max[2]) | bool ED_mask_selected_minmax(const bContext *C, float min[2], float max[2], bool include_handles) | ||||
| { | { | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); | Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); | ||||
| Mask *mask = CTX_data_edit_mask(C); | Mask *mask = CTX_data_edit_mask(C); | ||||
| /* Use evaluated mask to take animation into account. | |||||
| * The animation of splies is not "flushed" back to original, so need to explicitly | |||||
| * sue evaluated datablock here. */ | |||||
| Mask *mask_eval = (Mask *)DEG_get_evaluated_id(depsgraph, &mask->id); | |||||
| bool ok = false; | bool ok = false; | ||||
| if (mask == NULL) { | if (mask == NULL) { | ||||
| return ok; | return ok; | ||||
| } | } | ||||
| /* Use evaluated mask to take animation into account. | |||||
| * The animation of splies is not "flushed" back to original, so need to explicitly | |||||
| * sue evaluated datablock here. */ | |||||
| Mask *mask_eval = (Mask *)DEG_get_evaluated_id(depsgraph, &mask->id); | |||||
| INIT_MINMAX2(min, max); | INIT_MINMAX2(min, max); | ||||
| for (MaskLayer *mask_layer = mask_eval->masklayers.first; mask_layer != NULL; | for (MaskLayer *mask_layer = mask_eval->masklayers.first; mask_layer != NULL; | ||||
| mask_layer = mask_layer->next) { | mask_layer = mask_layer->next) { | ||||
| if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) { | if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| for (MaskSpline *spline = mask_layer->splines.first; spline != NULL; spline = spline->next) { | for (MaskSpline *spline = mask_layer->splines.first; spline != NULL; spline = spline->next) { | ||||
| MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline); | MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline); | ||||
| for (int i = 0; i < spline->tot_point; i++) { | for (int i = 0; i < spline->tot_point; i++) { | ||||
| const MaskSplinePoint *point = &spline->points[i]; | const MaskSplinePoint *point = &spline->points[i]; | ||||
| const MaskSplinePoint *deform_point = &points_array[i]; | const MaskSplinePoint *deform_point = &points_array[i]; | ||||
| const BezTriple *bezt = &point->bezt; | const BezTriple *bezt = &point->bezt; | ||||
| float handle[2]; | float handle[2]; | ||||
| if (!MASKPOINT_ISSEL_ANY(point)) { | if (!MASKPOINT_ISSEL_ANY(point)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (bezt->f2 & SELECT) { | if (bezt->f2 & SELECT) { | ||||
| minmax_v2v2_v2(min, max, deform_point->bezt.vec[1]); | minmax_v2v2_v2(min, max, deform_point->bezt.vec[1]); | ||||
| ok = true; | |||||
| } | |||||
| if (!include_handles) { | |||||
| /* Ignore handles. */ | |||||
| } | } | ||||
| if (BKE_mask_point_handles_mode_get(point) == MASK_HANDLE_MODE_STICK) { | else if (BKE_mask_point_handles_mode_get(point) == MASK_HANDLE_MODE_STICK) { | ||||
| BKE_mask_point_handle(deform_point, MASK_WHICH_HANDLE_STICK, handle); | BKE_mask_point_handle(deform_point, MASK_WHICH_HANDLE_STICK, handle); | ||||
| minmax_v2v2_v2(min, max, handle); | minmax_v2v2_v2(min, max, handle); | ||||
| ok = true; | |||||
| } | } | ||||
| else { | else { | ||||
| if ((bezt->f1 & SELECT) && (bezt->h1 != HD_VECT)) { | if ((bezt->f1 & SELECT) && (bezt->h1 != HD_VECT)) { | ||||
| BKE_mask_point_handle(deform_point, MASK_WHICH_HANDLE_LEFT, handle); | BKE_mask_point_handle(deform_point, MASK_WHICH_HANDLE_LEFT, handle); | ||||
| minmax_v2v2_v2(min, max, handle); | minmax_v2v2_v2(min, max, handle); | ||||
| ok = true; | |||||
| } | } | ||||
| if ((bezt->f3 & SELECT) && (bezt->h2 != HD_VECT)) { | if ((bezt->f3 & SELECT) && (bezt->h2 != HD_VECT)) { | ||||
| BKE_mask_point_handle(deform_point, MASK_WHICH_HANDLE_RIGHT, handle); | BKE_mask_point_handle(deform_point, MASK_WHICH_HANDLE_RIGHT, handle); | ||||
| minmax_v2v2_v2(min, max, handle); | minmax_v2v2_v2(min, max, handle); | ||||
| ok = true; | |||||
| } | } | ||||
| } | } | ||||
| ok = true; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return ok; | return ok; | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| ▲ Show 20 Lines • Show All 176 Lines • Show Last 20 Lines | |||||