2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2012 Blender Foundation.
19 * All rights reserved.
21 * Contributor(s): Blender Foundation,
24 * ***** END GPL LICENSE BLOCK *****
27 #ifndef __BKE_MASK_H__
28 #define __BKE_MASK_H__
34 struct MaskLayerShape;
36 struct MaskSplinePoint;
37 struct MaskSplinePointUW;
42 struct MaskSplinePoint *BKE_mask_spline_point_array(struct MaskSpline *spline);
43 struct MaskSplinePoint *BKE_mask_spline_point_array_from_point(struct MaskSpline *spline, struct MaskSplinePoint *point_ref);
46 struct MaskLayer *BKE_mask_layer_new(struct Mask *mask, const char *name);
47 struct MaskLayer *BKE_mask_layer_active(struct Mask *mask);
48 void BKE_mask_layer_active_set(struct Mask *mask, struct MaskLayer *masklay);
49 void BKE_mask_layer_remove(struct Mask *mask, struct MaskLayer *masklay);
51 void BKE_mask_layer_free_shapes(struct MaskLayer *masklay);
52 void BKE_mask_layer_free(struct MaskLayer *masklay);
53 void BKE_mask_spline_free(struct MaskSpline *spline);
54 struct MaskSpline *BKE_mask_spline_copy(struct MaskSpline *spline);
55 void BKE_mask_point_free(struct MaskSplinePoint *point);
57 void BKE_mask_layer_unique_name(struct Mask *mask, struct MaskLayer *masklay);
60 struct MaskSpline *BKE_mask_spline_add(struct MaskLayer *masklay);
62 float (*BKE_mask_spline_differentiate(struct MaskSpline *spline, int *tot_diff_point))[2];
63 float (*BKE_mask_spline_feather_differentiated_points(struct MaskSpline *spline, int *tot_feather_point))[2];
65 float (*BKE_mask_spline_differentiate_with_resolution(struct MaskSpline *spline, int width, int height, int *tot_diff_point))[2];
66 float (*BKE_mask_spline_feather_differentiated_points_with_resolution(struct MaskSpline *spline,
67 int width, int height, int *tot_feather_point))[2];
69 float (*BKE_mask_spline_feather_points(struct MaskSpline *spline, int *tot_feather_point))[2];
71 void BKE_mask_point_direction_switch(struct MaskSplinePoint *point);
72 void BKE_mask_spline_direction_switch(struct MaskLayer *masklay, struct MaskSpline *spline);
79 float BKE_mask_spline_project_co(struct MaskSpline *spline, struct MaskSplinePoint *point,
80 float start_u, const float co[2], const eMaskSign sign);
83 int BKE_mask_point_has_handle(struct MaskSplinePoint *point);
84 void BKE_mask_point_handle(struct MaskSplinePoint *point, float handle[2]);
85 void BKE_mask_point_set_handle(struct MaskSplinePoint *point, float loc[2], int keep_direction,
86 float orig_handle[2], float orig_vec[3][3]);
88 float *BKE_mask_point_segment_diff(struct MaskSpline *spline, struct MaskSplinePoint *point, int *tot_diff_point);
89 float *BKE_mask_point_segment_feather_diff(struct MaskSpline *spline, struct MaskSplinePoint *point,
90 int *tot_feather_point);
92 float *BKE_mask_point_segment_diff_with_resolution(struct MaskSpline *spline, struct MaskSplinePoint *point,
93 int width, int height, int *tot_diff_point);
95 float *BKE_mask_point_segment_feather_diff_with_resolution(struct MaskSpline *spline, struct MaskSplinePoint *point,
96 int width, int height,
97 int *tot_feather_point);
99 void BKE_mask_point_segment_co(struct MaskSpline *spline, struct MaskSplinePoint *point, float u, float co[2]);
100 void BKE_mask_point_normal(struct MaskSpline *spline, struct MaskSplinePoint *point,
101 float u, float n[2]);
102 float BKE_mask_point_weight_scalar(struct MaskSpline *spline, struct MaskSplinePoint *point, const float u);
103 float BKE_mask_point_weight(struct MaskSpline *spline, struct MaskSplinePoint *point, const float u);
104 struct MaskSplinePointUW *BKE_mask_point_sort_uw(struct MaskSplinePoint *point, struct MaskSplinePointUW *uw);
105 void BKE_mask_point_add_uw(struct MaskSplinePoint *point, float u, float w);
107 void BKE_mask_point_select_set(struct MaskSplinePoint *point, const short do_select);
108 void BKE_mask_point_select_set_handle(struct MaskSplinePoint *point, const short do_select);
111 struct Mask *BKE_mask_new(const char *name);
113 void BKE_mask_free(struct Mask *mask);
114 void BKE_mask_unlink(struct Main *bmain, struct Mask *mask);
116 void BKE_mask_coord_from_movieclip(struct MovieClip *clip, struct MovieClipUser *user, float r_co[2], const float co[2]);
117 void BKE_mask_coord_to_movieclip(struct MovieClip *clip, struct MovieClipUser *user, float r_co[2], const float co[2]);
121 void BKE_mask_update_display(struct Mask *mask, float ctime);
123 void BKE_mask_evaluate_all_masks(struct Main *bmain, float ctime, const int do_newframe);
124 void BKE_mask_evaluate(struct Mask *mask, const float ctime, const int do_newframe);
125 void BKE_mask_update_scene(struct Main *bmain, struct Scene *scene, const int do_newframe);
126 void BKE_mask_parent_init(struct MaskParent *parent);
127 void BKE_mask_calc_handle_adjacent_interp(struct MaskSpline *spline, struct MaskSplinePoint *point, const float u);
128 void BKE_mask_calc_tangent_polyline(struct MaskSpline *spline, struct MaskSplinePoint *point, float t[2]);
129 void BKE_mask_calc_handle_point(struct MaskSpline *spline, struct MaskSplinePoint *point);
130 void BKE_mask_calc_handle_point_auto(struct MaskSpline *spline, struct MaskSplinePoint *point,
131 const short do_recalc_length);
132 void BKE_mask_get_handle_point_adjacent(struct MaskSpline *spline, struct MaskSplinePoint *point,
133 struct MaskSplinePoint **r_point_prev, struct MaskSplinePoint **r_point_next);
134 void BKE_mask_layer_calc_handles(struct MaskLayer *masklay);
135 void BKE_mask_layer_calc_handles_deform(struct MaskLayer *masklay);
136 void BKE_mask_calc_handles(struct Mask *mask);
137 void BKE_mask_calc_handles_deform(struct Mask *mask);
138 void BKE_mask_spline_ensure_deform(struct MaskSpline *spline);
141 int BKE_mask_layer_shape_totvert(struct MaskLayer *masklay);
142 void BKE_mask_layer_shape_from_mask(struct MaskLayer *masklay, struct MaskLayerShape *masklay_shape);
143 void BKE_mask_layer_shape_to_mask(struct MaskLayer *masklay, struct MaskLayerShape *masklay_shape);
144 void BKE_mask_layer_shape_to_mask_interp(struct MaskLayer *masklay,
145 struct MaskLayerShape *masklay_shape_a,
146 struct MaskLayerShape *masklay_shape_b,
148 struct MaskLayerShape *BKE_mask_layer_shape_find_frame(struct MaskLayer *masklay, const int frame);
149 int BKE_mask_layer_shape_find_frame_range(struct MaskLayer *masklay, const float frame,
150 struct MaskLayerShape **r_masklay_shape_a,
151 struct MaskLayerShape **r_masklay_shape_b);
152 struct MaskLayerShape *BKE_mask_layer_shape_alloc(struct MaskLayer *masklay, const int frame);
153 void BKE_mask_layer_shape_free(struct MaskLayerShape *masklay_shape);
154 struct MaskLayerShape *BKE_mask_layer_shape_varify_frame(struct MaskLayer *masklay, const int frame);
155 struct MaskLayerShape *BKE_mask_layer_shape_duplicate(struct MaskLayerShape *masklay_shape);
156 void BKE_mask_layer_shape_unlink(struct MaskLayer *masklay, struct MaskLayerShape *masklay_shape);
157 void BKE_mask_layer_shape_sort(struct MaskLayer *masklay);
159 int BKE_mask_layer_shape_spline_from_index(struct MaskLayer *masklay, int index,
160 struct MaskSpline **r_masklay_shape, int *r_index);
161 int BKE_mask_layer_shape_spline_to_index(struct MaskLayer *masklay, struct MaskSpline *spline);
163 int BKE_mask_layer_shape_spline_index(struct MaskLayer *masklay, int index,
164 struct MaskSpline **r_masklay_shape, int *r_index);
165 void BKE_mask_layer_shape_changed_add(struct MaskLayer *masklay, int index,
166 int do_init, int do_init_interpolate);
168 void BKE_mask_layer_shape_changed_remove(struct MaskLayer *masklay, int index, int count);
171 int BKE_mask_get_duration(struct Mask *mask);
172 void BKE_mask_rasterize(struct Mask *mask, int width, int height, float *buffer,
173 const short do_aspect_correct, int do_mask_aa);
175 #define MASKPOINT_ISSEL_ANY(p) ( ((p)->bezt.f1 | (p)->bezt.f2 | (p)->bezt.f2) & SELECT)
176 #define MASKPOINT_ISSEL_KNOT(p) ( (p)->bezt.f2 & SELECT)
177 #define MASKPOINT_ISSEL_HANDLE_ONLY(p) ( (((p)->bezt.f1 | (p)->bezt.f2) & SELECT) && (((p)->bezt.f2 & SELECT) == 0) )
178 #define MASKPOINT_ISSEL_HANDLE(p) ( (((p)->bezt.f1 | (p)->bezt.f2) & SELECT) )
180 #define MASKPOINT_SEL_ALL(p) { (p)->bezt.f1 |= SELECT; (p)->bezt.f2 |= SELECT; (p)->bezt.f3 |= SELECT; } (void)0
181 #define MASKPOINT_DESEL_ALL(p) { (p)->bezt.f1 &= ~SELECT; (p)->bezt.f2 &= ~SELECT; (p)->bezt.f3 &= ~SELECT; } (void)0
182 #define MASKPOINT_INVSEL_ALL(p) { (p)->bezt.f1 ^= SELECT; (p)->bezt.f2 ^= SELECT; (p)->bezt.f3 ^= SELECT; } (void)0
184 #define MASKPOINT_SEL_HANDLE(p) { (p)->bezt.f1 |= SELECT; (p)->bezt.f3 |= SELECT; } (void)0
185 #define MASKPOINT_DESEL_HANDLE(p) { (p)->bezt.f1 &= ~SELECT; (p)->bezt.f3 &= ~SELECT; } (void)0