39 const float normal_co[2],
43 const bool use_deform,
44 const bool use_project,
51 const float threshold_sq = threshold * threshold;
59 float dist_best_sq =
FLT_MAX, co[2];
70 co[0] = normal_co[0] * scalex;
71 co[1] = normal_co[1] * scaley;
74 *mask_layer_eval = mask_eval->
masklayers.first();
75 mask_layer_orig !=
nullptr;
76 mask_layer_orig = mask_layer_orig->next, mask_layer_eval = mask_layer_eval->next)
82 for (
MaskSpline *spline_orig = mask_layer_orig->splines.first(),
83 *spline_eval = mask_layer_eval->splines.first();
84 spline_orig !=
nullptr;
85 spline_orig = spline_orig->
next, spline_eval = spline_eval->
next)
91 cur_point_eval = use_deform ? spline_eval->runtime->points_deform.data() :
93 i < spline_eval->tot_point;
94 i++, cur_point_eval++)
98 spline_eval, cur_point_eval, width, height, &tot_diff_point);
102 uint tot_feather_point;
103 float *feather_points =
nullptr, *points;
107 spline_eval, cur_point_eval, width, height, &tot_feather_point);
109 points = feather_points;
110 tot_point = tot_feather_point;
113 points = diff_points;
114 tot_point = tot_diff_point;
117 for (j = 0; j < tot_point - 1; j++) {
118 float dist_sq, a[2],
b[2];
120 a[0] = points[2 * j] * scalex;
121 a[1] = points[2 * j + 1] * scaley;
123 b[0] = points[2 * j + 2] * scalex;
124 b[1] = points[2 * j + 3] * scaley;
128 if (dist_sq < dist_best_sq) {
130 sub_v2_v2v2(tangent, &diff_points[2 * j + 2], &diff_points[2 * j]);
133 point_mask_layer = mask_layer_orig;
134 point_spline = spline_orig;
136 &spline_orig->points[(cur_point_eval -
137 spline_eval->runtime->points_deform.data())] :
138 &spline_orig->points[(cur_point_eval - spline_eval->points)];
139 dist_best_sq = dist_sq;
140 u =
float(j) / tot_point;
144 if (feather_points !=
nullptr) {
145 MEM_delete(feather_points);
147 MEM_delete(diff_points);
153 if (point && dist_best_sq < threshold_sq) {
155 *r_mask_layer = point_mask_layer;
159 *r_spline = point_spline;
176 *r_score = dist_best_sq;
183 *r_mask_layer =
nullptr;
210 const float normal_co[2],
211 const float threshold,
224 const float threshold_sq = threshold * threshold;
225 float len_sq =
FLT_MAX, scalex, scaley;
235 co[0] = normal_co[0] * scalex;
236 co[1] = normal_co[1] * scaley;
239 *mask_layer_eval = mask_eval->
masklayers.first();
240 mask_layer_orig !=
nullptr;
241 mask_layer_orig = mask_layer_orig->next, mask_layer_eval = mask_layer_eval->next)
248 for (
MaskSpline *spline_orig = mask_layer_orig->splines.first(),
249 *spline_eval = mask_layer_eval->splines.first();
250 spline_orig !=
nullptr;
251 spline_orig = spline_orig->
next, spline_eval = spline_eval->
next)
255 for (
int i = 0; i < spline_orig->tot_point; i++) {
260 float cur_len_sq, vec[2];
262 vec[0] = bezt->
vec[1][0] * scalex;
263 vec[1] = bezt->
vec[1][1] * scaley;
267 if (cur_len_sq < len_sq) {
268 point_spline = spline_orig;
269 point_mask_layer = mask_layer_orig;
270 point = cur_point_orig;
283 float handle_left[2], handle_right[2];
284 float len_left_sq, len_right_sq;
293 if (len_left_sq <= len_right_sq) {
296 cur_len_sq = len_left_sq;
301 cur_len_sq = len_right_sq;
305 if (len_right_sq <= len_left_sq) {
308 cur_len_sq = len_right_sq;
313 cur_len_sq = len_left_sq;
319 point_mask_layer = mask_layer_orig;
320 point_spline = spline_orig;
321 point = cur_point_orig;
323 which_handle = cur_which_handle;
329 if (len_sq < threshold_sq) {
331 *r_mask_layer = point_mask_layer;
335 *r_spline = point_spline;
338 if (r_which_handle) {
339 *r_which_handle = which_handle;
343 *r_score =
sqrtf(len_sq);
350 *r_mask_layer =
nullptr;
357 if (r_which_handle) {
366 const float normal_co[2],
367 const float threshold,
381 const float threshold_sq = threshold * threshold;
383 float scalex, scaley;
392 co[0] = normal_co[0] * scalex;
393 co[1] = normal_co[1] * scaley;
396 *mask_layer_eval = mask_eval->
masklayers.first();
397 mask_layer_orig !=
nullptr;
398 mask_layer_orig = mask_layer_orig->next, mask_layer_eval = mask_layer_eval->next)
401 for (
MaskSpline *spline_orig = mask_layer_orig->splines.first(),
402 *spline_eval = mask_layer_eval->splines.first();
403 spline_orig !=
nullptr;
404 spline_orig = spline_orig->
next, spline_eval = spline_eval->
next)
408 int i, tot_feather_point;
409 float (*feather_points)[2], (*fp)[2];
417 for (i = 0; i < spline_orig->tot_point; i++) {
422 for (j = 0; j <= cur_point_eval->
tot_uw; j++) {
423 float cur_len_sq, vec[2];
425 vec[0] = (*fp)[0] * scalex;
426 vec[1] = (*fp)[1] * scaley;
430 if (point ==
nullptr || cur_len_sq <
len) {
435 uw = &cur_point_orig->
uw[j - 1];
438 point_mask_layer = mask_layer_orig;
439 point_spline = spline_orig;
440 point = cur_point_orig;
448 MEM_delete(feather_points);
452 if (
len < threshold_sq) {
454 *r_mask_layer = point_mask_layer;
458 *r_spline = point_spline;
477 *r_mask_layer =
nullptr;
605 bool handles_as_knot,
608 if (handles_as_knot) {
618 const bool handles_as_knot,
619 const bool handles_as_knot_selected_only)
626 if (
mask ==
nullptr) {
642 for (
int i = 0; i < spline.
tot_point; i++) {
650 if (bezt->
f2 &
SELECT || handles_as_knot_selected_only) {
685 const bool handles_as_knot_selected_only,
691 C,
min,
max,
false, handles_as_knot_selected_only);
701 if (r_has_select !=
nullptr) {
702 *r_has_select = mask_selected;
756 *r_zoomx = *r_zoomy = 1.0f;
767 *r_zoomx = *r_zoomy = 1.0f;
773 *r_zoomx = *r_zoomy = 1.0f;
787 *r_aspx = *r_aspy = 1.0f;
798 *r_aspx = *r_aspy = 1.0f;
804 *r_aspx = *r_aspy = 1.0f;
824 *r_scalex = *r_scaley = 1.0f;
841 *r_scalex = *r_scaley = 1.0f;
847 *r_scalex = *r_scaley = 1.0f;
Read Blender memory allocation and freeing.
#define INIT_MINMAX2(min, max)
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
void view2d_region_to_view(const View2D *v2d, float x, float y, float *r_view_x, float *r_view_y) ATTR_NONNULL()
void view2d_scale_get(const View2D *v2d, float *r_x, float *r_y)
@ MASK_WHICH_HANDLE_RIGHT
@ MASK_WHICH_HANDLE_STICK
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void ED_space_clip_get_size(const SpaceClip *sc, int *r_width, int *r_height)
ScrArea * CTX_wm_area(const bContext *C)
void ED_space_image_get_aspect(SpaceImage *sima, float *r_aspx, float *r_aspy)
void BKE_mask_point_handle(const MaskSplinePoint *point, eMaskWhichHandle which_handle, float r_handle[2])
Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
MINLINE void copy_v2_v2(float r[2], const float a[2])
void ED_space_image_get_size(SpaceImage *sima, int *r_width, int *r_height)
void ED_clip_point_stable_pos__reverse(const SpaceClip *sc, const ARegion *region, const float co[2], float r_co[2])
the reverse of ED_clip_point_stable_pos(), gets the marker region coords. better name here?...
MaskSplinePoint * ED_mask_point_find_nearest(const bContext *C, Mask *mask_orig, const float normal_co[2], float threshold, MaskLayer **r_mask_layer, MaskSpline **r_spline, eMaskWhichHandle *r_which_handle, float *r_score)
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
void ED_clip_point_stable_pos(const SpaceClip *sc, const ARegion *region, float x, float y, float *xr, float *yr)
void ED_mask_zoom(ScrArea *area, ARegion *region, float *r_zoomx, float *r_zoomy)
void ED_mask_cursor_location_get(ScrArea *area, float cursor[2])
void ED_mask_point_pos__reverse(ScrArea *area, ARegion *region, float x, float y, float *r_x, float *r_y)
void ED_space_clip_get_aspect(const SpaceClip *sc, float *r_aspx, float *r_aspy)
float dist_squared_to_line_segment_v2(const float p[2], const float l1[2], const float l2[2])
static void mask_point_scaled_handle(const MaskSplinePoint *point, const eMaskWhichHandle which_handle, const float scalex, const float scaley, float handle[2])
void ED_image_point_pos(SpaceImage *sima, const ARegion *region, float x, float y, float *r_x, float *r_y)
void ED_mask_pixelspace_factor(ScrArea *area, ARegion *region, float *r_scalex, float *r_scaley)
void BKE_mask_coord_to_movieclip(MovieClip *clip, MovieClipUser *user, float r_co[2], const float co[2])
void BKE_mask_coord_from_image(Image *image, ImageUser *iuser, float r_co[2], const float co[2])
bool BKE_mask_point_selected(const MaskSplinePoint *p)
void minmax_v2v2_v2(float min[2], float max[2], const float vec[2])
void ED_image_mouse_pos(SpaceImage *sima, const ARegion *region, const int mval[2], float co[2])
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C, bool rna_write_check=false)
void BKE_mask_coord_from_movieclip(MovieClip *clip, MovieClipUser *user, float r_co[2], const float co[2])
float(* BKE_mask_spline_feather_points(MaskSpline *spline, int *tot_feather_point))[2]
void ED_mask_get_size(ScrArea *area, int *r_width, int *r_height)
Mask * CTX_data_edit_mask(const bContext *C)
float * BKE_mask_point_segment_feather_diff(MaskSpline *spline, MaskSplinePoint *point, int width, int height, unsigned int *r_tot_feather_point)
void ED_mask_center_from_pivot_ex(const bContext *C, ScrArea *area, char mode, bool handles_as_knot_selected_only, float r_center[2], bool *r_has_select)
void ED_clip_mouse_pos(const SpaceClip *sc, const ARegion *region, const int mval[2], float r_co[2])
static void handle_position_for_minmax(const MaskSplinePoint *point, eMaskWhichHandle which_handle, bool handles_as_knot, float r_handle[2])
void ED_mask_point_pos(ScrArea *area, ARegion *region, float x, float y, float *r_x, float *r_y)
void ED_mask_get_aspect(ScrArea *area, ARegion *region, float *r_aspx, float *r_aspy)
void mid_v2_v2v2(float r[2], const float a[2], const float b[2])
void ED_space_image_get_zoom(SpaceImage *sima, const ARegion *region, float *r_zoomx, float *r_zoomy)
void BKE_mask_coord_to_image(Image *image, ImageUser *iuser, float r_co[2], const float co[2])
bool ED_mask_selected_minmax(const bContext *C, float min[2], float max[2], bool handles_as_knot, bool handles_as_knot_selected_only)
MINLINE float len_squared_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
void ED_mask_mouse_pos(ScrArea *area, ARegion *region, const int mval[2], float r_co[2])
void ED_image_point_pos__reverse(SpaceImage *sima, const ARegion *region, const float co[2], float r_co[2])
MaskSplinePoint * BKE_mask_spline_point_array(MaskSpline *spline)
eMaskhandleMode BKE_mask_point_handles_mode_get(const MaskSplinePoint *point)
MINLINE void zero_v2(float r[2])
ARegion * CTX_wm_region(const bContext *C)
void ED_space_clip_get_zoom(const SpaceClip *sc, const ARegion *region, float *r_zoomx, float *r_zoomy)
float * BKE_mask_point_segment_diff(MaskSpline *spline, MaskSplinePoint *point, int width, int height, unsigned int *r_tot_diff_point)
float BKE_mask_spline_project_co(MaskSpline *spline, MaskSplinePoint *point, float start_u, const float co[2], eMaskSign sign)
bool ED_mask_find_nearest_diff_point(const bContext *C, Mask *mask_orig, const float normal_co[2], int threshold, bool feather, float tangent[2], bool use_deform, bool use_project, MaskLayer **r_mask_layer, MaskSpline **r_spline, MaskSplinePoint **r_point, float *r_u, float *r_score)
bool ED_mask_feather_find_nearest(const bContext *C, Mask *mask_orig, const float normal_co[2], float threshold, MaskLayer **r_mask_layer, MaskSpline **r_spline, MaskSplinePoint **r_point, MaskSplinePointUW **r_uw, float *r_score)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
MaskLayerVisibility visibility_flag
ListBaseT< MaskSpline > splines
ListBaseT< struct MaskLayer > masklayers
ListBaseT< SpaceLink > spacedata
struct MovieClipUser user