51 struct Mask *mask_orig,
52 const float normal_co[2],
56 const bool use_deform,
57 const bool use_project,
70 float dist_best_sq = FLT_MAX, co[2];
81 co[0] = normal_co[0] * scalex;
82 co[1] = normal_co[1] * scaley;
86 mask_layer_orig !=
NULL;
87 mask_layer_orig = mask_layer_orig->next, mask_layer_eval = mask_layer_eval->next) {
92 for (
MaskSpline *spline_orig = mask_layer_orig->splines.first,
93 *spline_eval = mask_layer_eval->splines.first;
95 spline_orig = spline_orig->next, spline_eval = spline_eval->next) {
99 for (i = 0, cur_point_eval = use_deform ? spline_eval->points_deform : spline_eval->points;
100 i < spline_eval->tot_point;
101 i++, cur_point_eval++) {
104 spline_eval, cur_point_eval,
width,
height, &tot_diff_point);
108 uint tot_feather_point;
109 float *feather_points =
NULL, *points;
113 spline_eval, cur_point_eval,
width,
height, &tot_feather_point);
115 points = feather_points;
116 tot_point = tot_feather_point;
119 points = diff_points;
120 tot_point = tot_diff_point;
123 for (j = 0; j < tot_point - 1; j++) {
124 float dist_sq,
a[2], b[2];
126 a[0] = points[2 * j] * scalex;
127 a[1] = points[2 * j + 1] * scaley;
129 b[0] = points[2 * j + 2] * scalex;
130 b[1] = points[2 * j + 3] * scaley;
134 if (dist_sq < dist_best_sq) {
136 sub_v2_v2v2(tangent, &diff_points[2 * j + 2], &diff_points[2 * j]);
139 point_mask_layer = mask_layer_orig;
140 point_spline = spline_orig;
142 &spline_orig->points[(cur_point_eval - spline_eval->points_deform)] :
143 &spline_orig->points[(cur_point_eval - spline_eval->points)];
144 dist_best_sq = dist_sq;
145 u = (
float)j / tot_point;
149 if (feather_points !=
NULL) {
158 if (point && dist_best_sq < threshold) {
160 *r_mask_layer = point_mask_layer;
164 *r_spline = point_spline;
181 *r_score = dist_best_sq;
188 *r_mask_layer =
NULL;
215 const float normal_co[2],
216 const float threshold,
229 const float threshold_sq = threshold * threshold;
230 float len_sq = FLT_MAX, scalex, scaley;
240 co[0] = normal_co[0] * scalex;
241 co[1] = normal_co[1] * scaley;
245 mask_layer_orig !=
NULL;
246 mask_layer_orig = mask_layer_orig->next, mask_layer_eval = mask_layer_eval->next) {
252 for (
MaskSpline *spline_orig = mask_layer_orig->splines.first,
253 *spline_eval = mask_layer_eval->splines.first;
255 spline_orig = spline_orig->next, spline_eval = spline_eval->next) {
258 for (
int i = 0; i < spline_orig->tot_point; i++) {
263 float cur_len_sq, vec[2];
265 vec[0] = bezt->
vec[1][0] * scalex;
266 vec[1] = bezt->
vec[1][1] * scaley;
270 if (cur_len_sq < len_sq) {
271 point_spline = spline_orig;
272 point_mask_layer = mask_layer_orig;
273 point = cur_point_orig;
286 float handle_left[2], handle_right[2];
287 float len_left_sq, len_right_sq;
296 if (len_left_sq <= len_right_sq) {
299 cur_len_sq = len_left_sq;
304 cur_len_sq = len_right_sq;
308 if (len_right_sq <= len_left_sq) {
311 cur_len_sq = len_right_sq;
316 cur_len_sq = len_left_sq;
322 point_mask_layer = mask_layer_orig;
323 point_spline = spline_orig;
324 point = cur_point_orig;
326 which_handle = cur_which_handle;
332 if (len_sq < threshold_sq) {
334 *r_mask_layer = point_mask_layer;
338 *r_spline = point_spline;
341 if (r_which_handle) {
342 *r_which_handle = which_handle;
346 *r_score =
sqrtf(len_sq);
353 *r_mask_layer =
NULL;
360 if (r_which_handle) {
369 const float normal_co[2],
370 const float threshold,
384 const float threshold_sq = threshold * threshold;
385 float len = FLT_MAX, co[2];
386 float scalex, scaley;
395 co[0] = normal_co[0] * scalex;
396 co[1] = normal_co[1] * scaley;
400 mask_layer_orig !=
NULL;
401 mask_layer_orig = mask_layer_orig->next, mask_layer_eval = mask_layer_eval->next) {
403 for (
MaskSpline *spline_orig = mask_layer_orig->splines.first,
404 *spline_eval = mask_layer_eval->splines.first;
406 spline_orig = spline_orig->next, spline_eval = spline_eval->next) {
409 int i, tot_feather_point;
410 float(*feather_points)[2], (*fp)[2];
418 for (i = 0; i < spline_orig->tot_point; i++) {
423 for (j = 0; j <= cur_point_eval->
tot_uw; j++) {
424 float cur_len_sq, vec[2];
426 vec[0] = (*fp)[0] * scalex;
427 vec[1] = (*fp)[1] * scaley;
431 if (point ==
NULL || cur_len_sq <
len) {
436 uw = &cur_point_orig->
uw[j - 1];
439 point_mask_layer = mask_layer_orig;
440 point_spline = spline_orig;
441 point = cur_point_orig;
453 if (
len < threshold_sq) {
455 *r_mask_layer = point_mask_layer;
459 *r_spline = point_spline;
478 *r_mask_layer =
NULL;
496 switch (
area->spacetype) {
533 switch (
area->spacetype) {
571 switch (
area->spacetype) {
609 bool handles_as_control_point,
612 if (handles_as_control_point) {
622 bool handles_as_control_point)
640 mask_layer = mask_layer->next) {
644 for (
MaskSpline *spline = mask_layer->splines.first; spline !=
NULL; spline = spline->next) {
646 for (
int i = 0; i < spline->tot_point; i++) {
693 if (
area &&
area->spacedata.first) {
694 switch (
area->spacetype) {
728 if (
area &&
area->spacedata.first) {
729 switch (
area->spacetype) {
736 *zoomx = *zoomy = 1.0f;
747 *zoomx = *zoomy = 1.0f;
753 *zoomx = *zoomy = 1.0f;
759 if (
area &&
area->spacedata.first) {
760 switch (
area->spacetype) {
767 *aspx = *aspy = 1.0f;
778 *aspx = *aspy = 1.0f;
784 *aspx = *aspy = 1.0f;
790 if (
area &&
area->spacedata.first) {
791 switch (
area->spacetype) {
804 *scalex = *scaley = 1.0f;
821 *scalex = *scaley = 1.0f;
827 *scalex = *scaley = 1.0f;
834 switch (
area->spacetype) {
typedef float(TangentPoint)[2]
struct ScrArea * CTX_wm_area(const bContext *C)
struct Mask * CTX_data_edit_mask(const bContext *C)
struct Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
struct ARegion * CTX_wm_region(const bContext *C)
struct Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
#define MASKPOINT_ISSEL_ANY(p)
float * BKE_mask_point_segment_feather_diff(struct MaskSpline *spline, struct MaskSplinePoint *point, int width, int height, unsigned int *tot_feather_point)
void BKE_mask_coord_from_image(struct Image *image, struct ImageUser *iuser, float r_co[2], const float co[2])
@ MASK_WHICH_HANDLE_RIGHT
@ MASK_WHICH_HANDLE_STICK
float BKE_mask_spline_project_co(struct MaskSpline *spline, struct MaskSplinePoint *point, float start_u, const float co[2], const eMaskSign sign)
void BKE_mask_coord_to_image(struct Image *image, struct ImageUser *iuser, float r_co[2], const float co[2])
void BKE_mask_coord_to_movieclip(struct MovieClip *clip, struct MovieClipUser *user, float r_co[2], const float co[2])
void BKE_mask_point_handle(const struct MaskSplinePoint *point, eMaskWhichHandle which_handle, float r_handle[2])
float(* BKE_mask_spline_feather_points(struct MaskSpline *spline, int *tot_feather_point))[2]
eMaskhandleMode BKE_mask_point_handles_mode_get(const struct MaskSplinePoint *point)
struct MaskSplinePoint * BKE_mask_spline_point_array(struct MaskSpline *spline)
void BKE_mask_coord_from_movieclip(struct MovieClip *clip, struct MovieClipUser *user, float r_co[2], const float co[2])
float * BKE_mask_point_segment_diff(struct MaskSpline *spline, struct MaskSplinePoint *point, int width, int height, unsigned int *r_tot_diff_point)
float dist_squared_to_line_segment_v2(const float p[2], const float l1[2], const float l2[2])
MINLINE float len_squared_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void copy_v2_v2(float r[2], const float a[2])
void minmax_v2v2_v2(float min[2], float max[2], const float vec[2])
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE void zero_v2(float r[2])
#define INIT_MINMAX2(min, max)
struct Depsgraph Depsgraph
struct ID * DEG_get_evaluated_id(const struct Depsgraph *depsgraph, struct ID *id)
#define MASK_RESTRICT_SELECT
#define MASK_RESTRICT_VIEW
void ED_clip_point_stable_pos__reverse(struct SpaceClip *sc, struct 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?...
void ED_space_clip_get_aspect(struct SpaceClip *sc, float *aspx, float *aspy)
void ED_space_clip_get_zoom(struct SpaceClip *sc, struct ARegion *region, float *zoomx, float *zoomy)
void ED_space_clip_get_size(struct SpaceClip *sc, int *width, int *height)
void ED_clip_mouse_pos(struct SpaceClip *sc, struct ARegion *region, const int mval[2], float co[2])
void ED_clip_point_stable_pos(struct SpaceClip *sc, struct ARegion *region, float x, float y, float *xr, float *yr)
void ED_image_point_pos(struct SpaceImage *sima, const struct ARegion *region, float x, float y, float *r_x, float *r_y)
void ED_space_image_get_zoom(struct SpaceImage *sima, const struct ARegion *region, float *r_zoomx, float *r_zoomy)
void ED_image_point_pos__reverse(struct SpaceImage *sima, const struct ARegion *region, const float co[2], float r_co[2])
void ED_image_mouse_pos(struct SpaceImage *sima, const struct ARegion *region, const int mval[2], float co[2])
void ED_space_image_get_size(struct SpaceImage *sima, int *r_width, int *r_height)
void ED_space_image_get_aspect(struct SpaceImage *sima, float *r_aspx, float *r_aspy)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
Read Guarded memory(de)allocation.
void UI_view2d_scale_get(const struct View2D *v2d, float *r_x, float *r_y)
void UI_view2d_region_to_view(const struct View2D *v2d, float x, float y, float *r_view_x, float *r_view_y) ATTR_NONNULL()
const Depsgraph * depsgraph
void(* MEM_freeN)(void *vmemh)
MaskSplinePoint * ED_mask_point_find_nearest(const bContext *C, Mask *mask_orig, const float normal_co[2], const float threshold, MaskLayer **r_mask_layer, MaskSpline **r_spline, eMaskWhichHandle *r_which_handle, float *r_score)
bool ED_mask_feather_find_nearest(const bContext *C, Mask *mask_orig, const float normal_co[2], const float threshold, MaskLayer **r_mask_layer, MaskSpline **r_spline, MaskSplinePoint **r_point, MaskSplinePointUW **r_uw, float *r_score)
void ED_mask_zoom(ScrArea *area, ARegion *region, float *zoomx, float *zoomy)
void ED_mask_get_aspect(ScrArea *area, ARegion *UNUSED(region), float *aspx, float *aspy)
void ED_mask_point_pos(ScrArea *area, ARegion *region, float x, float y, float *xr, float *yr)
static void mask_point_scaled_handle(const MaskSplinePoint *point, const eMaskWhichHandle which_handle, const float scalex, const float scaley, float handle[2])
void ED_mask_cursor_location_get(ScrArea *area, float cursor[2])
bool ED_mask_find_nearest_diff_point(const bContext *C, struct Mask *mask_orig, const float normal_co[2], int threshold, bool feather, float tangent[2], const bool use_deform, const bool use_project, MaskLayer **r_mask_layer, MaskSpline **r_spline, MaskSplinePoint **r_point, float *r_u, float *r_score)
bool ED_mask_selected_minmax(const bContext *C, float min[2], float max[2], bool handles_as_control_point)
static void handle_position_for_minmax(const MaskSplinePoint *point, eMaskWhichHandle which_handle, bool handles_as_control_point, float r_handle[2])
void ED_mask_get_size(ScrArea *area, int *width, int *height)
void ED_mask_mouse_pos(ScrArea *area, ARegion *region, const int mval[2], float co[2])
void ED_mask_point_pos__reverse(ScrArea *area, ARegion *region, float x, float y, float *xr, float *yr)
void ED_mask_pixelspace_factor(ScrArea *area, ARegion *region, float *scalex, float *scaley)
static void area(int d1, int d2, int e1, int e2, float weights[2])
struct MovieClipUser user
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)