Blender V5.3
mask_add.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2012 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <algorithm>
10
11#include "MEM_guardedalloc.h"
12
13#include "BKE_context.hh"
14#include "BKE_curve.hh"
15#include "BKE_mask.hh"
16
17#include "BLI_math_matrix_c.hh"
18#include "BLI_math_vector_c.hh"
19
20#include "DEG_depsgraph.hh"
21
22#include "DNA_mask_types.h"
23#include "DNA_scene_types.h"
24#include "DNA_screen_types.h"
25
26#include "WM_api.hh"
27#include "WM_types.hh"
28
29#include "ED_mask.hh" /* own include */
30#include "ED_select_utils.hh"
31
32#include "RNA_access.hh"
33#include "RNA_define.hh"
34
35#include "mask_intern.hh" /* own include */
36
37namespace blender {
38
39/* -------------------------------------------------------------------- */
42
44 MaskSpline *spline,
45 MaskSplinePoint *new_point,
46 const float point_co[2],
47 const float u,
48 const float ctime,
49 const MaskSplinePoint *reference_point,
50 const bool reference_adjacent)
51{
52 const MaskSplinePoint *reference_parent_point = nullptr;
53 BezTriple *bezt;
54 float co[3];
55
56 copy_v2_v2(co, point_co);
57 co[2] = 0.0f;
58
59 /* point coordinate */
60 bezt = &new_point->bezt;
61
62 bezt->h1 = bezt->h2 = HD_ALIGN;
63
64 if (reference_point) {
65 if (reference_point->bezt.h1 == HD_VECT && reference_point->bezt.h2 == HD_VECT) {
66 /* If the reference point is sharp try using some smooth point as reference
67 * for handles.
68 */
69 int point_index = reference_point - spline->points;
70 int delta = new_point == spline->points ? 1 : -1;
71 for (int i = 0; i < spline->tot_point - 1; i++) {
72 MaskSplinePoint *current_point;
73
74 point_index += delta;
75 if (point_index == -1 || point_index >= spline->tot_point) {
76 if (spline->flag & MASK_SPLINE_CYCLIC) {
77 if (point_index == -1) {
78 point_index = spline->tot_point - 1;
79 }
80 else if (point_index >= spline->tot_point) {
81 point_index = 0;
82 }
83 }
84 else {
85 break;
86 }
87 }
88
89 current_point = &spline->points[point_index];
90 if (current_point->bezt.h1 != HD_VECT || current_point->bezt.h2 != HD_VECT) {
91 bezt->h1 = bezt->h2 = std::max(current_point->bezt.h2, current_point->bezt.h1);
92 break;
93 }
94 }
95 }
96 else {
97 bezt->h1 = bezt->h2 = std::max(reference_point->bezt.h2, reference_point->bezt.h1);
98 }
99
100 reference_parent_point = reference_point;
101 }
102 else if (reference_adjacent) {
103 if (spline->tot_point != 1) {
104 MaskSplinePoint *prev_point, *next_point, *close_point;
105
106 const int index = int(new_point - spline->points);
107 if (spline->flag & MASK_SPLINE_CYCLIC) {
108 prev_point = &spline->points[mod_i(index - 1, spline->tot_point)];
109 next_point = &spline->points[mod_i(index + 1, spline->tot_point)];
110 }
111 else {
112 prev_point = (index != 0) ? &spline->points[index - 1] : nullptr;
113 next_point = (index != spline->tot_point - 1) ? &spline->points[index + 1] : nullptr;
114 }
115
116 if (prev_point && next_point) {
117 close_point = (len_squared_v2v2(new_point->bezt.vec[1], prev_point->bezt.vec[1]) <
118 len_squared_v2v2(new_point->bezt.vec[1], next_point->bezt.vec[1])) ?
119 prev_point :
120 next_point;
121 }
122 else {
123 close_point = prev_point ? prev_point : next_point;
124 }
125
126 /* handle type */
127 eBezTriple_Handle handle_type = HD_FREE;
128 if (prev_point) {
129 handle_type = prev_point->bezt.h2;
130 }
131 if (next_point) {
132 handle_type = std::max(next_point->bezt.h2, handle_type);
133 }
134 bezt->h1 = bezt->h2 = handle_type;
135
136 /* parent */
137 reference_parent_point = close_point;
138
139 /* NOTE: we may want to copy other attributes later, radius? pressure? color? */
140 }
141 }
142
143 copy_v3_v3(bezt->vec[0], co);
144 copy_v3_v3(bezt->vec[1], co);
145 copy_v3_v3(bezt->vec[2], co);
146
147 if (reference_parent_point) {
148 new_point->parent = reference_parent_point->parent;
149
150 if (new_point->parent.id) {
151 float parent_matrix[3][3];
152 BKE_mask_point_parent_matrix_get(new_point, ctime, parent_matrix);
153 invert_m3(parent_matrix);
154 mul_m3_v2(parent_matrix, new_point->bezt.vec[1]);
155 }
156 }
157 else {
158 BKE_mask_parent_init(&new_point->parent);
159 }
160
161 if (spline->tot_point != 1) {
162 BKE_mask_calc_handle_adjacent_interp(spline, new_point, u);
163 }
164
165 /* select new point */
168}
169
171
172/* -------------------------------------------------------------------- */
175
176static void finSelectedSplinePoint(MaskLayer *mask_layer,
177 MaskSpline **spline,
178 MaskSplinePoint **point,
179 bool check_active)
180{
181 MaskSpline *cur_spline = mask_layer->splines.first();
182
183 *spline = nullptr;
184 *point = nullptr;
185
186 if (check_active) {
187 /* TODO: having an active point but no active spline is possible, why? */
188 if (mask_layer->act_spline && mask_layer->act_point &&
190 {
191 *spline = mask_layer->act_spline;
192 *point = mask_layer->act_point;
193 return;
194 }
195 }
196
197 while (cur_spline) {
198 for (int i = 0; i < cur_spline->tot_point; i++) {
199 MaskSplinePoint *cur_point = &cur_spline->points[i];
200
201 if (BKE_mask_point_selected(cur_point)) {
202 if (!ELEM(*spline, nullptr, cur_spline)) {
203 *spline = nullptr;
204 *point = nullptr;
205 return;
206 }
207 if (*point) {
208 *point = nullptr;
209 }
210 else {
211 *spline = cur_spline;
212 *point = cur_point;
213 }
214 }
215 }
216
217 cur_spline = cur_spline->next;
218 }
219}
220
222
223/* -------------------------------------------------------------------- */
226
227static void mask_spline_add_point_at_index(MaskSpline *spline, int point_index)
228{
229 MaskSplinePoint *new_point_array;
230
231 new_point_array = MEM_new_array<MaskSplinePoint>(spline->tot_point + 1, "add mask vert points");
232
233 memcpy(new_point_array, spline->points, sizeof(MaskSplinePoint) * (point_index + 1));
234 memcpy(new_point_array + point_index + 2,
235 spline->points + point_index + 1,
236 sizeof(MaskSplinePoint) * (spline->tot_point - point_index - 1));
237
238 MEM_delete(spline->points);
239 spline->points = new_point_array;
240 spline->tot_point++;
241}
242
243static bool add_vertex_subdivide(const bContext *C, Mask *mask, const float co[2])
244{
245 MaskLayer *mask_layer;
246 MaskSpline *spline;
247 MaskSplinePoint *point = nullptr;
248 const float threshold = 12;
249 float tangent[2];
250 float u;
251
253 mask,
254 co,
255 threshold,
256 false,
257 tangent,
258 true,
259 true,
260 &mask_layer,
261 &spline,
262 &point,
263 &u,
264 nullptr))
265 {
266 Scene *scene = CTX_data_scene(C);
267 const float ctime = scene->r.cfra;
268
269 MaskSplinePoint *new_point;
270 int point_index = point - spline->points;
271
273
274 mask_spline_add_point_at_index(spline, point_index);
275
276 new_point = &spline->points[point_index + 1];
277
278 setup_vertex_point(mask, spline, new_point, co, u, ctime, nullptr, true);
279
280 /* TODO: we could pass the spline! */
282 BKE_mask_layer_shape_spline_to_index(mask_layer, spline) +
283 point_index + 1,
284 true,
285 true);
286
287 mask_layer->act_spline = spline;
288 mask_layer->act_point = new_point;
289
291
292 return true;
293 }
294
295 return false;
296}
297
298static bool add_vertex_extrude(const bContext *C,
299 Mask *mask,
300 MaskLayer *mask_layer,
301 const float co[2])
302{
303 Scene *scene = CTX_data_scene(C);
304 const float ctime = scene->r.cfra;
305
306 MaskSpline *spline;
307 MaskSplinePoint *point;
308 MaskSplinePoint *new_point = nullptr, *ref_point = nullptr;
309
310 /* check on which side we want to add the point */
311 int point_index;
312 float tangent_point[2];
313 float tangent_co[2];
314 bool do_cyclic_correct = false;
315 bool do_prev; /* use prev point rather than next?? */
316
317 if (!mask_layer) {
318 return false;
319 }
320 finSelectedSplinePoint(mask_layer, &spline, &point, true);
321
323
324 point_index = (point - spline->points);
325
327
328 if ((spline->flag & MASK_SPLINE_CYCLIC) ||
329 (point_index > 0 && point_index != spline->tot_point - 1))
330 {
331 BKE_mask_calc_tangent_polyline(spline, point, tangent_point);
332 sub_v2_v2v2(tangent_co, co, point->bezt.vec[1]);
333
334 if (dot_v2v2(tangent_point, tangent_co) < 0.0f) {
335 do_prev = true;
336 }
337 else {
338 do_prev = false;
339 }
340 }
341 else if (((spline->flag & MASK_SPLINE_CYCLIC) == 0) && (point_index == 0)) {
342 do_prev = true;
343 }
344 else if (((spline->flag & MASK_SPLINE_CYCLIC) == 0) && (point_index == spline->tot_point - 1)) {
345 do_prev = false;
346 }
347 else {
348 do_prev = false; /* quiet warning */
349 /* should never get here */
350 BLI_assert(0);
351 }
352
353 /* use the point before the active one */
354 if (do_prev) {
355 point_index--;
356 if (point_index < 0) {
357 point_index += spline->tot_point; /* wrap index */
358 if ((spline->flag & MASK_SPLINE_CYCLIC) == 0) {
359 do_cyclic_correct = true;
360 point_index = 0;
361 }
362 }
363 }
364
365#if 0
366 print_v2("", tangent_point);
367 printf("%d\n", point_index);
368#endif
369
370 mask_spline_add_point_at_index(spline, point_index);
371
372 if (do_cyclic_correct) {
373 ref_point = &spline->points[point_index + 1];
374 new_point = &spline->points[point_index];
375 *ref_point = *new_point;
376 *new_point = MaskSplinePoint{};
377 }
378 else {
379 ref_point = &spline->points[point_index];
380 new_point = &spline->points[point_index + 1];
381 }
382
383 mask_layer->act_point = new_point;
384
385 setup_vertex_point(mask, spline, new_point, co, 0.5f, ctime, ref_point, false);
386
387 if (mask_layer->splines_shapes.first_) {
388 point_index = ((int(new_point - spline->points) + 0) % spline->tot_point);
390 BKE_mask_layer_shape_spline_to_index(mask_layer, spline) +
391 point_index,
392 true,
393 true);
394 }
395
397
398 return true;
399}
400
401static bool add_vertex_new(const bContext *C, Mask *mask, MaskLayer *mask_layer, const float co[2])
402{
403 Scene *scene = CTX_data_scene(C);
404 const float ctime = scene->r.cfra;
405
406 MaskSpline *spline;
407 MaskSplinePoint *new_point = nullptr, *ref_point = nullptr;
408
409 if (!mask_layer) {
410 /* If there's no mask layer currently operating on, create new one. */
411 mask_layer = BKE_mask_layer_new(mask, "");
412 mask->masklay_act = mask->masklay_tot - 1;
413 }
414
416
417 spline = BKE_mask_spline_add(mask_layer);
418
419 mask_layer->act_spline = spline;
420 new_point = spline->points;
421
422 mask_layer->act_point = new_point;
423
424 setup_vertex_point(mask, spline, new_point, co, 0.5f, ctime, ref_point, false);
425
426 {
427 int point_index = ((int(new_point - spline->points) + 0) % spline->tot_point);
429 BKE_mask_layer_shape_spline_to_index(mask_layer, spline) +
430 point_index,
431 true,
432 true);
433 }
434
436
437 return true;
438}
439
440/* Convert coordinate from normalized space to pixel one.
441 * TODO(sergey): Make the function more generally available. */
443 const float point_normalized[2],
444 float point_pixel[2])
445{
446 ScrArea *area = CTX_wm_area(C);
447 ARegion *region = CTX_wm_region(C);
448
449 float scalex, scaley;
450 ED_mask_pixelspace_factor(area, region, &scalex, &scaley);
451
452 point_pixel[0] = point_normalized[0] * scalex;
453 point_pixel[1] = point_normalized[1] * scaley;
454}
455
457 Mask *mask,
458 MaskSpline *spline,
459 MaskSplinePoint *active_point,
460 MaskSplinePoint *other_point,
461 float co[2])
462{
463 const float tolerance_in_pixels_squared = 4 * 4;
464
465 if (spline->flag & MASK_SPLINE_CYCLIC) {
466 /* The spline is already cyclic, so there is no need to handle anything here.
467 * Return PASS_THROUGH so that it's possible to add vertices close to the endpoints of the
468 * cyclic spline. */
470 }
471
472 float co_pixel[2];
473 mask_point_make_pixel_space(C, co, co_pixel);
474
475 float point_pixel[2];
476 mask_point_make_pixel_space(C, other_point->bezt.vec[1], point_pixel);
477
478 const float dist_squared = len_squared_v2v2(co_pixel, point_pixel);
479 if (dist_squared > tolerance_in_pixels_squared) {
481 }
482
483 spline->flag |= MASK_SPLINE_CYCLIC;
484
485 /* TODO: update keyframes in time. */
486 BKE_mask_calc_handle_point_auto(spline, active_point, false);
487 BKE_mask_calc_handle_point_auto(spline, other_point, false);
488
490
492
493 return OPERATOR_FINISHED;
494}
495
497 bContext *C, Mask *mask, MaskSpline *spline, MaskSplinePoint *active_point, float co[2])
498{
499 MaskSplinePoint *first_point = &spline->points[0];
500 MaskSplinePoint *last_point = &spline->points[spline->tot_point - 1];
501 const bool is_first_point_active = (active_point == first_point);
502 const bool is_last_point_active = (active_point == last_point);
503 if (is_last_point_active) {
504 return add_vertex_handle_cyclic_at_point(C, mask, spline, active_point, first_point, co);
505 }
506 if (is_first_point_active) {
507 return add_vertex_handle_cyclic_at_point(C, mask, spline, active_point, last_point, co);
508 }
510}
511
513
514/* -------------------------------------------------------------------- */
517
519{
520 MaskViewLockState lock_state;
521 ED_mask_view_lock_state_store(C, &lock_state);
522
524 if (mask == nullptr) {
525 /* if there's no active mask, create one */
526 mask = ED_mask_new(C, nullptr);
527 }
528
529 MaskLayer *mask_layer = BKE_mask_layer_active(mask);
530
531 if (mask_layer && mask_layer->visibility_flag & (MASK_HIDE_VIEW | MASK_HIDE_SELECT)) {
532 mask_layer = nullptr;
533 }
534
535 float co[2];
536 RNA_float_get_array(op->ptr, "location", co);
537
538 /* TODO: having an active point but no active spline is possible, why? */
539 if (mask_layer && mask_layer->act_spline && mask_layer->act_point &&
541 {
542 MaskSpline *spline = mask_layer->act_spline;
543 MaskSplinePoint *active_point = mask_layer->act_point;
544 const wmOperatorStatus cyclic_result = add_vertex_handle_cyclic(
545 C, mask, spline, active_point, co);
546 if (cyclic_result != OPERATOR_PASS_THROUGH) {
547 return cyclic_result;
548 }
549
550 if (!add_vertex_subdivide(C, mask, co)) {
551 if (!add_vertex_extrude(C, mask, mask_layer, co)) {
552 return OPERATOR_CANCELLED;
553 }
554 }
555 }
556 else {
557 if (!add_vertex_subdivide(C, mask, co)) {
558 if (!add_vertex_new(C, mask, mask_layer, co)) {
559 return OPERATOR_CANCELLED;
560 }
561 }
562 }
563
565
567
568 return OPERATOR_FINISHED;
569}
570
572{
573 ScrArea *area = CTX_wm_area(C);
574 ARegion *region = CTX_wm_region(C);
575
576 float co[2];
577
578 ED_mask_mouse_pos(area, region, event->mval, co);
579
580 RNA_float_set_array(op->ptr, "location", co);
581
582 return add_vertex_exec(C, op);
583}
584
586{
587 /* identifiers */
588 ot->name = "Add Vertex";
589 ot->description = "Add vertex to active spline";
590 ot->idname = "MASK_OT_add_vertex";
591
592 /* API callbacks. */
593 ot->exec = add_vertex_exec;
596
597 /* flags */
599
600 /* properties */
602 "location",
603 2,
604 nullptr,
605 -FLT_MAX,
606 FLT_MAX,
607 "Location",
608 "Location of vertex in normalized space",
609 -1.0f,
610 1.0f);
611}
612
614
615/* -------------------------------------------------------------------- */
618
620{
622 MaskLayer *mask_layer;
623 MaskSpline *spline;
624 MaskSplinePoint *point = nullptr;
625 const float threshold = 12;
626 float co[2], u;
627
628 RNA_float_get_array(op->ptr, "location", co);
629
630 point = ED_mask_point_find_nearest(C, mask, co, threshold, nullptr, nullptr, nullptr, nullptr);
631 if (point) {
632 return OPERATOR_FINISHED;
633 }
634
636 mask,
637 co,
638 threshold,
639 true,
640 nullptr,
641 true,
642 true,
643 &mask_layer,
644 &spline,
645 &point,
646 &u,
647 nullptr))
648 {
649 float w = BKE_mask_point_weight(spline, point, u);
650 float weight_scalar = BKE_mask_point_weight_scalar(spline, point, u);
651
652 if (weight_scalar != 0.0f) {
653 w = w / weight_scalar;
654 }
655
656 BKE_mask_point_add_uw(point, u, w);
657
659
661
662 return OPERATOR_FINISHED;
663 }
664
665 return OPERATOR_CANCELLED;
666}
667
669 wmOperator *op,
670 const wmEvent *event)
671{
672 ScrArea *area = CTX_wm_area(C);
673 ARegion *region = CTX_wm_region(C);
674
675 float co[2];
676
677 ED_mask_mouse_pos(area, region, event->mval, co);
678
679 RNA_float_set_array(op->ptr, "location", co);
680
681 return add_feather_vertex_exec(C, op);
682}
683
685{
686 /* identifiers */
687 ot->name = "Add Feather Vertex";
688 ot->description = "Add vertex to feather";
689 ot->idname = "MASK_OT_add_feather_vertex";
690
691 /* API callbacks. */
695
696 /* flags */
698
699 /* properties */
701 "location",
702 2,
703 nullptr,
704 -FLT_MAX,
705 FLT_MAX,
706 "Location",
707 "Location of vertex in normalized space",
708 -1.0f,
709 1.0f);
710}
711
713
714/* -------------------------------------------------------------------- */
717
718static BezTriple *points_to_bezier(const float (*points)[2],
719 const int num_points,
720 const eBezTriple_Handle handle_type,
721 const float scale,
722 const float location[2])
723{
724 BezTriple *bezier_points = MEM_new_array_zeroed<BezTriple>(num_points, __func__);
725 for (int i = 0; i < num_points; i++) {
726 copy_v2_v2(bezier_points[i].vec[1], points[i]);
727 mul_v2_fl(bezier_points[i].vec[1], scale);
728 add_v2_v2(bezier_points[i].vec[1], location);
729
730 bezier_points[i].h1 = handle_type;
731 bezier_points[i].h2 = handle_type;
732 }
733
734 for (int i = 0; i < num_points; i++) {
735 BKE_nurb_handle_calc(&bezier_points[i],
736 &bezier_points[(i - 1 + num_points) % num_points],
737 &bezier_points[(i + 1) % num_points],
738 false,
739 false);
740 }
741
742 return bezier_points;
743}
744
746 wmOperator *op,
747 const float (*points)[2],
748 int num_points,
749 eBezTriple_Handle handle_type)
750{
751 MaskViewLockState lock_state;
752 ED_mask_view_lock_state_store(C, &lock_state);
753
754 ScrArea *area = CTX_wm_area(C);
755 int size = RNA_float_get(op->ptr, "size");
756
757 int width, height;
758 ED_mask_get_size(area, &width, &height);
759 float scale = float(size) / max_ii(width, height);
760
761 /* Get location in mask space. */
762 float frame_size[2];
763 frame_size[0] = width;
764 frame_size[1] = height;
765 float location[2];
766 RNA_float_get_array(op->ptr, "location", location);
767 location[0] /= width;
768 location[1] /= height;
769 BKE_mask_coord_from_frame(location, location, frame_size);
770
771 /* Make it so new primitive is centered to mouse location. */
772 location[0] -= 0.5f * scale;
773 location[1] -= 0.5f * scale;
774
775 bool added_mask = false;
776 MaskLayer *mask_layer = ED_mask_layer_ensure(C, &added_mask);
778
780
781 MaskSpline *new_spline = BKE_mask_spline_add(mask_layer);
783 new_spline->points = static_cast<MaskSplinePoint *>(
784 MEM_realloc_zeroed(new_spline->points, sizeof(MaskSplinePoint) * num_points));
785
786 mask_layer->act_spline = new_spline;
787 mask_layer->act_point = nullptr;
788
789 const int spline_index = BKE_mask_layer_shape_spline_to_index(mask_layer, new_spline);
790
791 BezTriple *bezier_points = points_to_bezier(points, num_points, handle_type, scale, location);
792
793 for (int i = 0; i < num_points; i++) {
794 new_spline->tot_point = i + 1;
795
796 MaskSplinePoint *new_point = &new_spline->points[i];
797 BKE_mask_parent_init(&new_point->parent);
798
799 new_point->bezt = bezier_points[i];
800
801 BKE_mask_point_select_set(new_point, true);
802
803 if (mask_layer->splines_shapes.first_) {
804 BKE_mask_layer_shape_changed_add(mask_layer, spline_index + i, true, false);
805 }
806 }
807
808 MEM_delete(bezier_points);
809
810 if (added_mask) {
812 }
814
816
818
819 return OPERATOR_FINISHED;
820}
821
823 wmOperator *op,
824 const wmEvent * /*event*/)
825{
826 ScrArea *area = CTX_wm_area(C);
827 float cursor[2];
828 int width, height;
829
830 ED_mask_get_size(area, &width, &height);
831 ED_mask_cursor_location_get(area, cursor);
832
833 cursor[0] *= width;
834 cursor[1] *= height;
835
836 RNA_float_set_array(op->ptr, "location", cursor);
837
838 return op->type->exec(C, op);
839}
840
842{
844 "size",
845 100,
846 -FLT_MAX,
847 FLT_MAX,
848 "Size",
849 "Size of new primitive",
850 -FLT_MAX,
851 FLT_MAX);
853 "location",
854 2,
855 nullptr,
856 -FLT_MAX,
857 FLT_MAX,
858 "Location",
859 "Location of new primitive",
860 -FLT_MAX,
861 FLT_MAX);
862}
863
865
866/* -------------------------------------------------------------------- */
869
871{
872 const float points[4][2] = {{0.0f, 0.5f}, {0.5f, 1.0f}, {1.0f, 0.5f}, {0.5f, 0.0f}};
873 int num_points = ARRAY_SIZE(points);
874
875 create_primitive_from_points(C, op, points, num_points, HD_AUTO);
876
877 return OPERATOR_FINISHED;
878}
879
881{
882 /* identifiers */
883 ot->name = "Add Circle";
884 ot->description = "Add new circle-shaped spline";
885 ot->idname = "MASK_OT_primitive_circle_add";
886
887 /* API callbacks. */
891
892 /* flags */
894
895 /* properties */
897}
898
900
901/* -------------------------------------------------------------------- */
904
906{
907 const float points[4][2] = {{0.0f, 0.0f}, {0.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, 0.0f}};
908 int num_points = ARRAY_SIZE(points);
909
910 create_primitive_from_points(C, op, points, num_points, HD_VECT);
911
912 return OPERATOR_FINISHED;
913}
914
916{
917 /* identifiers */
918 ot->name = "Add Square";
919 ot->description = "Add new square-shaped spline";
920 ot->idname = "MASK_OT_primitive_square_add";
921
922 /* API callbacks. */
926
927 /* flags */
929
930 /* properties */
932}
933
935
936} // namespace blender
Read Blender memory allocation and freeing.
#define C
Definition RandGen.cpp:29
#define NA_ADDED
Definition WM_types.hh:636
#define NA_EDITED
Definition WM_types.hh:634
#define NC_MASK
Definition WM_types.hh:411
#define ELEM(...)
#define MEM_realloc_zeroed(vmemh, len)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition btQuadWord.h:119
#define FLT_MAX
float3x3 scale(float3x3 mat, float2 scale)
BMesh Iterators.
void MASK_OT_primitive_square_add(wmOperatorType *ot)
Definition mask_add.cc:915
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void RNA_float_set_array(PointerRNA *ptr, const char *name, const float *values)
static wmOperatorStatus add_vertex_exec(bContext *C, wmOperator *op)
MINLINE int mod_i(int i, int n)
ScrArea * CTX_wm_area(const bContext *C)
static wmOperatorStatus add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static wmOperatorStatus primitive_square_add_exec(bContext *C, wmOperator *op)
Definition mask_add.cc:905
static wmOperatorStatus add_vertex_handle_cyclic(bContext *C, Mask *mask, MaskSpline *spline, MaskSplinePoint *active_point, float co[2])
Definition mask_add.cc:496
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void mul_v2_fl(float r[2], float f)
MINLINE void copy_v2_v2(float r[2], const float a[2])
void ED_mask_select_toggle_all(Mask *mask, int action)
void ED_mask_view_lock_state_store(const bContext *C, MaskViewLockState *state)
Definition mask_edit.cc:209
MaskLayer * BKE_mask_layer_new(Mask *mask, const char *name)
static void setup_vertex_point(Mask *mask, MaskSpline *spline, MaskSplinePoint *new_point, const float point_co[2], const float u, const float ctime, const MaskSplinePoint *reference_point, const bool reference_adjacent)
Definition mask_add.cc:43
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 BKE_mask_point_parent_matrix_get(MaskSplinePoint *point, float ctime, float parent_matrix[3][3])
MINLINE int max_ii(int a, int b)
void mul_m3_v2(const float m[3][3], float r[2])
void BKE_mask_calc_handle_adjacent_interp(MaskSpline *spline, MaskSplinePoint *point, float u)
void ED_mask_cursor_location_get(ScrArea *area, float cursor[2])
void BKE_nurb_handle_calc(BezTriple *bezt, BezTriple *prev, BezTriple *next, bool is_fcurve, char smoothing)
Definition curve.cc:3975
static bool add_vertex_extrude(const bContext *C, Mask *mask, MaskLayer *mask_layer, const float co[2])
Definition mask_add.cc:298
MaskLayer * ED_mask_layer_ensure(bContext *C, bool *r_added_mask)
Definition mask_ops.cc:85
PropertyRNA * RNA_def_float_vector(StructOrFunctionRNA *cont_, const char *identifier, const int len, const float *default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
static wmOperatorStatus add_vertex_handle_cyclic_at_point(bContext *C, Mask *mask, MaskSpline *spline, MaskSplinePoint *active_point, MaskSplinePoint *other_point, float co[2])
Definition mask_add.cc:456
void ED_mask_pixelspace_factor(ScrArea *area, ARegion *region, float *r_scalex, float *r_scaley)
static wmOperatorStatus add_feather_vertex_exec(bContext *C, wmOperator *op)
Definition mask_add.cc:619
MINLINE void add_v2_v2(float r[2], const float a[2])
static void mask_spline_add_point_at_index(MaskSpline *spline, int point_index)
Definition mask_add.cc:227
bool BKE_mask_point_selected(const MaskSplinePoint *p)
Definition BKE_mask.hh:155
void DEG_id_tag_update(ID *id, unsigned int flags)
float BKE_mask_point_weight_scalar(MaskSpline *spline, MaskSplinePoint *point, float u)
static wmOperatorStatus primitive_add_invoke(bContext *C, wmOperator *op, const wmEvent *)
Definition mask_add.cc:822
MaskSpline * BKE_mask_spline_add(MaskLayer *masklay)
void BKE_mask_point_deselect_handles(MaskSplinePoint *p)
Definition BKE_mask.hh:180
void BKE_mask_coord_from_frame(float r_co[2], const float co[2], const float frame_size[2])
MaskLayer * BKE_mask_layer_active(Mask *mask)
void BKE_mask_calc_tangent_polyline(MaskSpline *spline, MaskSplinePoint *point, float t[2])
@ MASK_SPLINE_CYCLIC
@ MASK_SPLINE_SELECT
constexpr size_t ARRAY_SIZE(const T(&arg)[N]) noexcept
void BKE_mask_point_select_set(MaskSplinePoint *point, bool do_select)
void ED_mask_get_size(ScrArea *area, int *r_width, int *r_height)
Mask * CTX_data_edit_mask(const bContext *C)
void ED_mask_select_flush_all(Mask *mask)
void ED_mask_view_lock_state_restore_no_jump(const bContext *C, const MaskViewLockState *state)
Definition mask_edit.cc:217
MINLINE float dot_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
bool ED_maskedit_mask_poll(bContext *C)
Definition mask_edit.cc:61
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void print_v2(const char *str, const float v[2])
static bool add_vertex_subdivide(const bContext *C, Mask *mask, const float co[2])
Definition mask_add.cc:243
bool invert_m3(float mat[3][3])
float BKE_mask_point_weight(MaskSpline *spline, MaskSplinePoint *point, float u)
static wmOperatorStatus primitive_circle_add_exec(bContext *C, wmOperator *op)
Definition mask_add.cc:870
int BKE_mask_layer_shape_spline_to_index(MaskLayer *masklay, MaskSpline *spline)
static void mask_point_make_pixel_space(bContext *C, const float point_normalized[2], float point_pixel[2])
Definition mask_add.cc:442
void BKE_mask_parent_init(MaskParent *parent)
bool ED_maskedit_visible_splines_poll(bContext *C)
Definition mask_edit.cc:45
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1074
static void define_primitive_add_properties(wmOperatorType *ot)
Definition mask_add.cc:841
static wmOperatorStatus add_feather_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition mask_add.cc:668
static void finSelectedSplinePoint(MaskLayer *mask_layer, MaskSpline **spline, MaskSplinePoint **point, bool check_active)
Definition mask_add.cc:176
Scene * CTX_data_scene(const bContext *C)
@ OPTYPE_REGISTER
Definition WM_types.hh:188
@ OPTYPE_UNDO
Definition WM_types.hh:190
void MASK_OT_add_vertex(wmOperatorType *ot)
Definition mask_add.cc:585
void BKE_mask_point_add_uw(MaskSplinePoint *point, float u, float w)
void MASK_OT_add_feather_vertex(wmOperatorType *ot)
Definition mask_add.cc:684
void MASK_OT_primitive_circle_add(wmOperatorType *ot)
Definition mask_add.cc:880
MINLINE float len_squared_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
static int create_primitive_from_points(bContext *C, wmOperator *op, const float(*points)[2], int num_points, eBezTriple_Handle handle_type)
Definition mask_add.cc:745
void ED_mask_mouse_pos(ScrArea *area, ARegion *region, const int mval[2], float r_co[2])
static BezTriple * points_to_bezier(const float(*points)[2], const int num_points, const eBezTriple_Handle handle_type, const float scale, const float location[2])
Definition mask_add.cc:718
Mask * ED_mask_new(bContext *C, const char *name)
Definition mask_ops.cc:55
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
ARegion * CTX_wm_region(const bContext *C)
float RNA_float_get(PointerRNA *ptr, const char *name)
void BKE_mask_layer_shape_changed_add(MaskLayer *masklay, int index, bool do_init, bool do_init_interpolate)
void BKE_mask_point_select_handles(MaskSplinePoint *p)
Definition BKE_mask.hh:173
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
void BKE_mask_calc_handle_point_auto(MaskSpline *spline, MaskSplinePoint *point, bool do_recalc_length)
Resets auto handles even for non-auto bezier points.
static bool add_vertex_new(const bContext *C, Mask *mask, MaskLayer *mask_layer, const float co[2])
Definition mask_add.cc:401
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)
Definition mask_query.cc:37
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
eBezTriple_Handle h2
eBezTriple_Handle h1
struct MaskSplinePoint * act_point
struct MaskSpline * act_spline
ListBaseT< MaskLayerShape > splines_shapes
MaskLayerVisibility visibility_flag
ListBaseT< MaskSpline > splines
MaskSplinePoint * points
struct MaskSpline * next
MaskSplineFlag flag
struct RenderData r
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1125
const char * description
Definition WM_types.hh:1115
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1165
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1141
struct wmOperatorType * type