Blender V4.3
BKE_mask.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2012 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
11#ifdef __cplusplus
12extern "C" {
13#endif
14
15struct Depsgraph;
16struct Image;
17struct ImageUser;
18struct ListBase;
19struct Main;
20struct Mask;
21struct MaskLayer;
22struct MaskLayerShape;
23struct MaskParent;
24struct MaskSpline;
25struct MaskSplinePoint;
27struct MovieClip;
28struct MovieClipUser;
29
30/* `mask_ops.cc` */
31
39
44
45/* -------------------------------------------------------------------- */
49struct MaskLayer *BKE_mask_layer_new(struct Mask *mask, const char *name);
53struct MaskLayer *BKE_mask_layer_active(struct Mask *mask);
54void BKE_mask_layer_active_set(struct Mask *mask, struct MaskLayer *masklay);
55void BKE_mask_layer_remove(struct Mask *mask, struct MaskLayer *masklay);
56
59void BKE_mask_layer_free_shapes(struct MaskLayer *masklay);
60void BKE_mask_layer_free(struct MaskLayer *masklay);
61void BKE_mask_layer_free_list(struct ListBase *masklayers);
62void BKE_mask_spline_free(struct MaskSpline *spline);
63void BKE_mask_spline_free_list(struct ListBase *splines);
64struct MaskSpline *BKE_mask_spline_copy(const struct MaskSpline *spline);
65void BKE_mask_point_free(struct MaskSplinePoint *point);
66
67void BKE_mask_layer_unique_name(struct Mask *mask, struct MaskLayer *masklay);
68void BKE_mask_layer_rename(struct Mask *mask,
69 struct MaskLayer *masklay,
70 const char *oldname,
71 const char *newname);
72
73struct MaskLayer *BKE_mask_layer_copy(const struct MaskLayer *masklay);
74void BKE_mask_layer_copy_list(struct ListBase *masklayers_new, const struct ListBase *masklayers);
75
78/* -------------------------------------------------------------------- */
84 struct MaskSpline *spline, const struct MaskSplinePoint *point_ref);
85
86struct MaskSpline *BKE_mask_spline_add(struct MaskLayer *masklay);
87bool BKE_mask_spline_remove(struct MaskLayer *mask_layer, struct MaskSpline *spline);
89void BKE_mask_spline_direction_switch(struct MaskLayer *masklay, struct MaskSpline *spline);
90
92 struct MaskSplinePoint *points_array,
93 struct MaskSplinePoint *point);
94
95typedef enum {
99} eMaskSign;
100float BKE_mask_spline_project_co(struct MaskSpline *spline,
101 struct MaskSplinePoint *point,
102 float start_u,
103 const float co[2],
104 eMaskSign sign);
105
108/* -------------------------------------------------------------------- */
113void BKE_mask_point_handle(const struct MaskSplinePoint *point,
114 eMaskWhichHandle which_handle,
115 float r_handle[2]);
117 eMaskWhichHandle which_handle,
118 float loc[2],
119 bool keep_direction,
120 float orig_handle[2],
121 float orig_vec[3][3]);
122
123void BKE_mask_point_segment_co(struct MaskSpline *spline,
124 struct MaskSplinePoint *point,
125 float u,
126 float co[2]);
127void BKE_mask_point_normal(struct MaskSpline *spline,
128 struct MaskSplinePoint *point,
129 float u,
130 float n[2]);
131float BKE_mask_point_weight_scalar(struct MaskSpline *spline,
132 struct MaskSplinePoint *point,
133 float u);
134float BKE_mask_point_weight(struct MaskSpline *spline, struct MaskSplinePoint *point, float u);
136 struct MaskSplinePointUW *uw);
137void BKE_mask_point_add_uw(struct MaskSplinePoint *point, float u, float w);
138
139void BKE_mask_point_select_set(struct MaskSplinePoint *point, bool do_select);
141 eMaskWhichHandle which_handle,
142 bool do_select);
143
146/* -------------------------------------------------------------------- */
150struct Mask *BKE_mask_new(struct Main *bmain, const char *name);
151
152void BKE_mask_coord_from_frame(float r_co[2], const float co[2], const float frame_size[2]);
154 struct MovieClipUser *user,
155 float r_co[2],
156 const float co[2]);
157void BKE_mask_coord_from_image(struct Image *image,
158 struct ImageUser *iuser,
159 float r_co[2],
160 const float co[2]);
164void BKE_mask_coord_to_frame(float r_co[2], const float co[2], const float frame_size[2]);
165void BKE_mask_coord_to_movieclip(struct MovieClip *clip,
166 struct MovieClipUser *user,
167 float r_co[2],
168 const float co[2]);
169void BKE_mask_coord_to_image(struct Image *image,
170 struct ImageUser *iuser,
171 float r_co[2],
172 const float co[2]);
173
176/* -------------------------------------------------------------------- */
180void BKE_mask_evaluate(struct Mask *mask, float ctime, bool do_newframe);
181void BKE_mask_layer_evaluate(struct MaskLayer *masklay, float ctime, bool do_newframe);
182void BKE_mask_parent_init(struct MaskParent *parent);
184 struct MaskSplinePoint *point,
185 float u);
191 struct MaskSplinePoint *point,
192 float t[2]);
193void BKE_mask_calc_handle_point(struct MaskSpline *spline, struct MaskSplinePoint *point);
200 struct MaskSplinePoint *point,
201 bool do_recalc_length);
203 struct MaskSplinePoint *point,
204 struct MaskSplinePoint **r_point_prev,
205 struct MaskSplinePoint **r_point_next);
206void BKE_mask_layer_calc_handles(struct MaskLayer *masklay);
207void BKE_mask_spline_ensure_deform(struct MaskSpline *spline);
209 float ctime,
210 float parent_matrix[3][3]);
211
214/* -------------------------------------------------------------------- */
218int BKE_mask_layer_shape_totvert(struct MaskLayer *masklay);
222void BKE_mask_layer_shape_from_mask(struct MaskLayer *masklay,
223 struct MaskLayerShape *masklay_shape);
227void BKE_mask_layer_shape_to_mask(struct MaskLayer *masklay, struct MaskLayerShape *masklay_shape);
232 struct MaskLayerShape *masklay_shape_a,
233 struct MaskLayerShape *masklay_shape_b,
234 float fac);
240 float frame,
241 struct MaskLayerShape **r_masklay_shape_a,
242 struct MaskLayerShape **r_masklay_shape_b);
246struct MaskLayerShape *BKE_mask_layer_shape_alloc(struct MaskLayer *masklay, int frame);
247void BKE_mask_layer_shape_free(struct MaskLayerShape *masklay_shape);
250void BKE_mask_layer_shape_unlink(struct MaskLayer *masklay, struct MaskLayerShape *masklay_shape);
251void BKE_mask_layer_shape_sort(struct MaskLayer *masklay);
252
254 int index,
255 struct MaskSpline **r_masklay_shape,
256 int *r_index);
257int BKE_mask_layer_shape_spline_to_index(struct MaskLayer *masklay, struct MaskSpline *spline);
258
263 int index,
264 bool do_init,
265 bool do_init_interpolate);
266
270void BKE_mask_layer_shape_changed_remove(struct MaskLayer *masklay, int index, int count);
271
272int BKE_mask_get_duration(struct Mask *mask);
273
276/* -------------------------------------------------------------------- */
283void BKE_mask_clipboard_free(void);
287void BKE_mask_clipboard_copy_from_layer(struct MaskLayer *mask_layer);
295void BKE_mask_clipboard_paste_to_layer(struct Main *bmain, struct MaskLayer *mask_layer);
296
297#define MASKPOINT_ISSEL_ANY(p) ((((p)->bezt.f1 | (p)->bezt.f2 | (p)->bezt.f3) & SELECT) != 0)
298#define MASKPOINT_ISSEL_KNOT(p) (((p)->bezt.f2 & SELECT) != 0)
299
300#define MASKPOINT_ISSEL_HANDLE(point, which_handle) \
301 ((((which_handle) == MASK_WHICH_HANDLE_STICK) ? \
302 ((((point)->bezt.f1 | (point)->bezt.f3) & SELECT)) : \
303 (((which_handle) == MASK_WHICH_HANDLE_LEFT) ? ((point)->bezt.f1 & SELECT) : \
304 ((point)->bezt.f3 & SELECT))) != 0)
305
306#define MASKPOINT_SEL_ALL(p) \
307 { \
308 (p)->bezt.f1 |= SELECT; \
309 (p)->bezt.f2 |= SELECT; \
310 (p)->bezt.f3 |= SELECT; \
311 } \
312 (void)0
313#define MASKPOINT_DESEL_ALL(p) \
314 { \
315 (p)->bezt.f1 &= ~SELECT; \
316 (p)->bezt.f2 &= ~SELECT; \
317 (p)->bezt.f3 &= ~SELECT; \
318 } \
319 (void)0
320#define MASKPOINT_INVSEL_ALL(p) \
321 { \
322 (p)->bezt.f1 ^= SELECT; \
323 (p)->bezt.f2 ^= SELECT; \
324 (p)->bezt.f3 ^= SELECT; \
325 } \
326 (void)0
327
330/* -------------------------------------------------------------------- */
334#define MASK_RESOL_MAX 128
335
336/* `mask_evaluate.cc` */
337
338int BKE_mask_spline_resolution(struct MaskSpline *spline, int width, int height);
339unsigned int BKE_mask_spline_feather_resolution(struct MaskSpline *spline, int width, int height);
340int BKE_mask_spline_differentiate_calc_total(const struct MaskSpline *spline, unsigned int resol);
341
343 unsigned int resol,
344 unsigned int *r_tot_diff_point))[2];
346 float (*feather_points)[2],
347 unsigned int tot_feather_point);
349 struct MaskSpline *spline, int width, int height, unsigned int *r_tot_diff_point))[2];
355 struct MaskSpline *spline,
356 unsigned int resol,
357 bool do_feather_isect,
358 unsigned int *r_tot_feather_point))[2];
359
360/* *** mask point functions which involve evaluation *** */
361
362float (*BKE_mask_spline_feather_points(struct MaskSpline *spline, int *tot_feather_point))[2];
363
364float *BKE_mask_point_segment_diff(struct MaskSpline *spline,
365 struct MaskSplinePoint *point,
366 int width,
367 int height,
368 unsigned int *r_tot_diff_point);
369
370/* *** mask point functions which involve evaluation *** */
371
373 struct MaskSplinePoint *point,
374 int width,
375 int height,
376 unsigned int *r_tot_feather_point);
377
378void BKE_mask_layer_evaluate_animation(struct MaskLayer *masklay, float ctime);
379void BKE_mask_layer_evaluate_deform(struct MaskLayer *masklay, float ctime);
380
381void BKE_mask_eval_animation(struct Depsgraph *depsgraph, struct Mask *mask);
382void BKE_mask_eval_update(struct Depsgraph *depsgraph, struct Mask *mask);
383
386/* -------------------------------------------------------------------- */
390/* `mask_rasterize.cc` */
391
392struct MaskRasterHandle;
394
398 struct Mask *mask,
399 int width,
400 int height,
401 bool do_aspect_correct,
402 bool do_mask_aa,
403 bool do_feather);
404float BKE_maskrasterize_handle_sample(MaskRasterHandle *mr_handle, const float xy[2]);
405
410 unsigned int width,
411 unsigned int height,
412 float *buffer);
413
416#ifdef __cplusplus
417}
418#endif
void BKE_mask_layer_free(struct MaskLayer *masklay)
int BKE_mask_spline_resolution(struct MaskSpline *spline, int width, int height)
eMaskhandleMode
Definition BKE_mask.h:40
@ MASK_HANDLE_MODE_INDIVIDUAL_HANDLES
Definition BKE_mask.h:42
@ MASK_HANDLE_MODE_STICK
Definition BKE_mask.h:41
void BKE_mask_layer_unique_name(struct Mask *mask, struct MaskLayer *masklay)
struct Mask * BKE_mask_new(struct Main *bmain, const char *name)
float(* BKE_mask_spline_differentiate_with_resolution(struct MaskSpline *spline, unsigned int resol, unsigned int *r_tot_diff_point))[2]
void BKE_maskrasterize_handle_free(MaskRasterHandle *mr_handle)
void BKE_mask_layer_shape_changed_add(struct MaskLayer *masklay, int index, bool do_init, bool do_init_interpolate)
void BKE_mask_get_handle_point_adjacent(struct MaskSpline *spline, struct MaskSplinePoint *point, struct MaskSplinePoint **r_point_prev, struct MaskSplinePoint **r_point_next)
void BKE_mask_layer_evaluate_deform(struct MaskLayer *masklay, float ctime)
float(* BKE_mask_spline_differentiate(struct MaskSpline *spline, int width, int height, unsigned int *r_tot_diff_point))[2]
struct MaskSplinePointUW * BKE_mask_point_sort_uw(struct MaskSplinePoint *point, struct MaskSplinePointUW *uw)
void BKE_mask_layer_shape_unlink(struct MaskLayer *masklay, struct MaskLayerShape *masklay_shape)
void BKE_mask_layer_shape_to_mask(struct MaskLayer *masklay, struct MaskLayerShape *masklay_shape)
void BKE_mask_calc_tangent_polyline(struct MaskSpline *spline, struct MaskSplinePoint *point, float t[2])
void BKE_mask_layer_shape_sort(struct MaskLayer *masklay)
void BKE_mask_layer_remove(struct Mask *mask, struct MaskLayer *masklay)
void BKE_mask_point_select_set(struct MaskSplinePoint *point, bool do_select)
bool BKE_mask_spline_remove(struct MaskLayer *mask_layer, struct MaskSpline *spline)
struct MaskLayerShape * BKE_mask_layer_shape_duplicate(struct MaskLayerShape *masklay_shape)
struct MaskSplinePoint * BKE_mask_spline_point_array_from_point(struct MaskSpline *spline, const struct MaskSplinePoint *point_ref)
void BKE_mask_coord_from_image(struct Image *image, struct ImageUser *iuser, float r_co[2], const float co[2])
unsigned int BKE_mask_spline_feather_resolution(struct MaskSpline *spline, int width, int height)
void BKE_mask_calc_handle_point_auto(struct MaskSpline *spline, struct MaskSplinePoint *point, bool do_recalc_length)
Resets auto handles even for non-auto bezier points.
eMaskWhichHandle
Definition BKE_mask.h:32
@ MASK_WHICH_HANDLE_NONE
Definition BKE_mask.h:33
@ MASK_WHICH_HANDLE_BOTH
Definition BKE_mask.h:37
@ MASK_WHICH_HANDLE_RIGHT
Definition BKE_mask.h:36
@ MASK_WHICH_HANDLE_LEFT
Definition BKE_mask.h:35
@ MASK_WHICH_HANDLE_STICK
Definition BKE_mask.h:34
struct MaskSpline * BKE_mask_spline_add(struct MaskLayer *masklay)
struct MaskSpline * BKE_mask_spline_copy(const struct MaskSpline *spline)
void BKE_mask_spline_free(struct MaskSpline *spline)
struct MaskLayerShape * BKE_mask_layer_shape_alloc(struct MaskLayer *masklay, int frame)
struct MaskLayer * BKE_mask_layer_copy(const struct MaskLayer *masklay)
float BKE_maskrasterize_handle_sample(MaskRasterHandle *mr_handle, const float xy[2])
MaskRasterHandle * BKE_maskrasterize_handle_new(void)
void BKE_mask_point_direction_switch(struct MaskSplinePoint *point)
void BKE_mask_layer_copy_list(struct ListBase *masklayers_new, const struct ListBase *masklayers)
void BKE_mask_layer_evaluate(struct MaskLayer *masklay, float ctime, bool do_newframe)
void BKE_mask_layer_shape_to_mask_interp(struct MaskLayer *masklay, struct MaskLayerShape *masklay_shape_a, struct MaskLayerShape *masklay_shape_b, float fac)
void BKE_mask_layer_free_list(struct ListBase *masklayers)
void BKE_mask_calc_handle_point(struct MaskSpline *spline, struct MaskSplinePoint *point)
int BKE_mask_get_duration(struct Mask *mask)
void BKE_mask_evaluate(struct Mask *mask, float ctime, bool do_newframe)
void BKE_mask_point_free(struct MaskSplinePoint *point)
int BKE_mask_layer_shape_find_frame_range(struct MaskLayer *masklay, float frame, struct MaskLayerShape **r_masklay_shape_a, struct MaskLayerShape **r_masklay_shape_b)
int BKE_mask_spline_differentiate_calc_total(const struct MaskSpline *spline, unsigned int resol)
void BKE_mask_layer_active_set(struct Mask *mask, struct MaskLayer *masklay)
struct BezTriple * BKE_mask_spline_point_next_bezt(struct MaskSpline *spline, struct MaskSplinePoint *points_array, struct MaskSplinePoint *point)
bool BKE_mask_layer_shape_spline_from_index(struct MaskLayer *masklay, int index, struct MaskSpline **r_masklay_shape, int *r_index)
void BKE_mask_layer_shape_from_mask(struct MaskLayer *masklay, struct MaskLayerShape *masklay_shape)
void BKE_mask_spline_ensure_deform(struct MaskSpline *spline)
void BKE_mask_spline_free_list(struct ListBase *splines)
float BKE_mask_point_weight(struct MaskSpline *spline, struct MaskSplinePoint *point, float u)
float * BKE_mask_point_segment_feather_diff(struct MaskSpline *spline, struct MaskSplinePoint *point, int width, int height, unsigned int *r_tot_feather_point)
void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle, struct Mask *mask, int width, int height, bool do_aspect_correct, bool do_mask_aa, bool do_feather)
struct MaskLayer * BKE_mask_layer_new(struct Mask *mask, const char *name)
float BKE_mask_point_weight_scalar(struct MaskSpline *spline, struct MaskSplinePoint *point, float u)
void BKE_mask_point_set_handle(struct MaskSplinePoint *point, eMaskWhichHandle which_handle, float loc[2], bool keep_direction, float orig_handle[2], float orig_vec[3][3])
void BKE_mask_eval_update(struct Depsgraph *depsgraph, struct Mask *mask)
eMaskSign
Definition BKE_mask.h:95
@ MASK_PROJ_ANY
Definition BKE_mask.h:97
@ MASK_PROJ_NEG
Definition BKE_mask.h:96
@ MASK_PROJ_POS
Definition BKE_mask.h:98
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_frame(float r_co[2], const float co[2], const float frame_size[2])
float * BKE_mask_point_segment_diff(struct MaskSpline *spline, struct MaskSplinePoint *point, int width, int height, unsigned int *r_tot_diff_point)
void BKE_mask_clipboard_paste_to_layer(struct Main *bmain, struct MaskLayer *mask_layer)
void BKE_mask_coord_to_movieclip(struct MovieClip *clip, struct MovieClipUser *user, float r_co[2], const float co[2])
void BKE_mask_calc_handle_adjacent_interp(struct MaskSpline *spline, struct MaskSplinePoint *point, float u)
void BKE_mask_layer_free_shapes(struct MaskLayer *masklay)
Free all animation keys for a mask layer.
void BKE_mask_point_handle(const struct MaskSplinePoint *point, eMaskWhichHandle which_handle, float r_handle[2])
void BKE_mask_spline_feather_collapse_inner_loops(struct MaskSpline *spline, float(*feather_points)[2], unsigned int tot_feather_point)
void BKE_mask_layer_calc_handles(struct MaskLayer *masklay)
void BKE_mask_layer_shape_free(struct MaskLayerShape *masklay_shape)
void BKE_mask_point_parent_matrix_get(struct MaskSplinePoint *point, float ctime, float parent_matrix[3][3])
int BKE_mask_layer_shape_totvert(struct MaskLayer *masklay)
void BKE_mask_layer_rename(struct Mask *mask, struct MaskLayer *masklay, const char *oldname, const char *newname)
void BKE_mask_point_add_uw(struct MaskSplinePoint *point, float u, float w)
void BKE_mask_point_normal(struct MaskSpline *spline, struct MaskSplinePoint *point, float u, float n[2])
struct MaskLayerShape * BKE_mask_layer_shape_verify_frame(struct MaskLayer *masklay, int frame)
float(* BKE_mask_spline_feather_points(struct MaskSpline *spline, int *tot_feather_point))[2]
void BKE_mask_point_segment_co(struct MaskSpline *spline, struct MaskSplinePoint *point, float u, float co[2])
eMaskhandleMode BKE_mask_point_handles_mode_get(const struct MaskSplinePoint *point)
int BKE_mask_layer_shape_spline_to_index(struct MaskLayer *masklay, struct MaskSpline *spline)
void BKE_mask_coord_from_movieclip(struct MovieClip *clip, struct MovieClipUser *user, float r_co[2], const float co[2])
void BKE_mask_layer_shape_changed_remove(struct MaskLayer *masklay, int index, int count)
void BKE_mask_point_select_set_handle(struct MaskSplinePoint *point, eMaskWhichHandle which_handle, bool do_select)
struct MaskLayerShape * BKE_mask_layer_shape_find_frame(struct MaskLayer *masklay, int frame)
void BKE_mask_clipboard_free(void)
bool BKE_mask_clipboard_is_empty(void)
void BKE_mask_parent_init(struct MaskParent *parent)
float(* BKE_mask_spline_feather_differentiated_points_with_resolution(struct MaskSpline *spline, unsigned int resol, bool do_feather_isect, unsigned int *r_tot_feather_point))[2]
float BKE_mask_spline_project_co(struct MaskSpline *spline, struct MaskSplinePoint *point, float start_u, const float co[2], eMaskSign sign)
struct MaskLayer * BKE_mask_layer_active(struct Mask *mask)
void BKE_mask_coord_from_frame(float r_co[2], const float co[2], const float frame_size[2])
void BKE_mask_layer_evaluate_animation(struct MaskLayer *masklay, float ctime)
void BKE_maskrasterize_buffer(MaskRasterHandle *mr_handle, unsigned int width, unsigned int height, float *buffer)
Rasterize a buffer from a single mask (threaded execution).
void BKE_mask_clipboard_copy_from_layer(struct MaskLayer *mask_layer)
void BKE_mask_eval_animation(struct Depsgraph *depsgraph, struct Mask *mask)
void BKE_mask_spline_direction_switch(struct MaskLayer *masklay, struct MaskSpline *spline)
struct MaskSplinePoint * BKE_mask_spline_point_array(struct MaskSpline *spline)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition btQuadWord.h:119
const Depsgraph * depsgraph
draw_view in_light_buf[] float
int count
int xy[2]
Definition wm_draw.cc:170