Blender  V3.3
mask_add.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2012 Blender Foundation. All rights reserved. */
3 
8 #include "MEM_guardedalloc.h"
9 
10 #include "BLI_math.h"
11 
12 #include "BKE_context.h"
13 #include "BKE_curve.h"
14 #include "BKE_mask.h"
15 
16 #include "DEG_depsgraph.h"
17 
18 #include "DNA_mask_types.h"
19 #include "DNA_scene_types.h"
20 #include "DNA_screen_types.h"
21 
22 #include "WM_api.h"
23 #include "WM_types.h"
24 
25 #include "ED_mask.h" /* own include */
26 #include "ED_screen.h"
27 #include "ED_select_utils.h"
28 
29 #include "RNA_access.h"
30 #include "RNA_define.h"
31 
32 #include "mask_intern.h" /* own include */
33 
34 /* -------------------------------------------------------------------- */
39  MaskSpline *spline,
40  MaskSplinePoint *new_point,
41  const float point_co[2],
42  const float u,
43  const float ctime,
44  const MaskSplinePoint *reference_point,
45  const bool reference_adjacent)
46 {
47  const MaskSplinePoint *reference_parent_point = NULL;
48  BezTriple *bezt;
49  float co[3];
50 
51  copy_v2_v2(co, point_co);
52  co[2] = 0.0f;
53 
54  /* point coordinate */
55  bezt = &new_point->bezt;
56 
57  bezt->h1 = bezt->h2 = HD_ALIGN;
58 
59  if (reference_point) {
60  if (reference_point->bezt.h1 == HD_VECT && reference_point->bezt.h2 == HD_VECT) {
61  /* If the reference point is sharp try using some smooth point as reference
62  * for handles.
63  */
64  int point_index = reference_point - spline->points;
65  int delta = new_point == spline->points ? 1 : -1;
66  for (int i = 0; i < spline->tot_point - 1; i++) {
67  MaskSplinePoint *current_point;
68 
69  point_index += delta;
70  if (point_index == -1 || point_index >= spline->tot_point) {
71  if (spline->flag & MASK_SPLINE_CYCLIC) {
72  if (point_index == -1) {
73  point_index = spline->tot_point - 1;
74  }
75  else if (point_index >= spline->tot_point) {
76  point_index = 0;
77  }
78  }
79  else {
80  break;
81  }
82  }
83 
84  current_point = &spline->points[point_index];
85  if (current_point->bezt.h1 != HD_VECT || current_point->bezt.h2 != HD_VECT) {
86  bezt->h1 = bezt->h2 = MAX2(current_point->bezt.h2, current_point->bezt.h1);
87  break;
88  }
89  }
90  }
91  else {
92  bezt->h1 = bezt->h2 = MAX2(reference_point->bezt.h2, reference_point->bezt.h1);
93  }
94 
95  reference_parent_point = reference_point;
96  }
97  else if (reference_adjacent) {
98  if (spline->tot_point != 1) {
99  MaskSplinePoint *prev_point, *next_point, *close_point;
100 
101  const int index = (int)(new_point - spline->points);
102  if (spline->flag & MASK_SPLINE_CYCLIC) {
103  prev_point = &spline->points[mod_i(index - 1, spline->tot_point)];
104  next_point = &spline->points[mod_i(index + 1, spline->tot_point)];
105  }
106  else {
107  prev_point = (index != 0) ? &spline->points[index - 1] : NULL;
108  next_point = (index != spline->tot_point - 1) ? &spline->points[index + 1] : NULL;
109  }
110 
111  if (prev_point && next_point) {
112  close_point = (len_squared_v2v2(new_point->bezt.vec[1], prev_point->bezt.vec[1]) <
113  len_squared_v2v2(new_point->bezt.vec[1], next_point->bezt.vec[1])) ?
114  prev_point :
115  next_point;
116  }
117  else {
118  close_point = prev_point ? prev_point : next_point;
119  }
120 
121  /* handle type */
122  char handle_type = 0;
123  if (prev_point) {
124  handle_type = prev_point->bezt.h2;
125  }
126  if (next_point) {
127  handle_type = MAX2(next_point->bezt.h2, handle_type);
128  }
129  bezt->h1 = bezt->h2 = handle_type;
130 
131  /* parent */
132  reference_parent_point = close_point;
133 
134  /* NOTE: we may want to copy other attributes later, radius? pressure? color? */
135  }
136  }
137 
138  copy_v3_v3(bezt->vec[0], co);
139  copy_v3_v3(bezt->vec[1], co);
140  copy_v3_v3(bezt->vec[2], co);
141 
142  if (reference_parent_point) {
143  new_point->parent = reference_parent_point->parent;
144 
145  if (new_point->parent.id) {
146  float parent_matrix[3][3];
147  BKE_mask_point_parent_matrix_get(new_point, ctime, parent_matrix);
148  invert_m3(parent_matrix);
149  mul_m3_v2(parent_matrix, new_point->bezt.vec[1]);
150  }
151  }
152  else {
153  BKE_mask_parent_init(&new_point->parent);
154  }
155 
156  if (spline->tot_point != 1) {
157  BKE_mask_calc_handle_adjacent_interp(spline, new_point, u);
158  }
159 
160  /* select new point */
161  MASKPOINT_SEL_ALL(new_point);
163 }
164 
167 /* -------------------------------------------------------------------- */
171 static void finSelectedSplinePoint(MaskLayer *mask_layer,
172  MaskSpline **spline,
174  bool check_active)
175 {
176  MaskSpline *cur_spline = mask_layer->splines.first;
177 
178  *spline = NULL;
179  *point = NULL;
180 
181  if (check_active) {
182  /* TODO: having an active point but no active spline is possible, why? */
183  if (mask_layer->act_spline && mask_layer->act_point &&
184  MASKPOINT_ISSEL_ANY(mask_layer->act_point)) {
185  *spline = mask_layer->act_spline;
186  *point = mask_layer->act_point;
187  return;
188  }
189  }
190 
191  while (cur_spline) {
192  for (int i = 0; i < cur_spline->tot_point; i++) {
193  MaskSplinePoint *cur_point = &cur_spline->points[i];
194 
195  if (MASKPOINT_ISSEL_ANY(cur_point)) {
196  if (!ELEM(*spline, NULL, cur_spline)) {
197  *spline = NULL;
198  *point = NULL;
199  return;
200  }
201  if (*point) {
202  *point = NULL;
203  }
204  else {
205  *spline = cur_spline;
206  *point = cur_point;
207  }
208  }
209  }
210 
211  cur_spline = cur_spline->next;
212  }
213 }
214 
217 /* -------------------------------------------------------------------- */
222 {
223  MaskSplinePoint *new_point_array;
224 
225  new_point_array = MEM_callocN(sizeof(MaskSplinePoint) * (spline->tot_point + 1),
226  "add mask vert points");
227 
228  memcpy(new_point_array, spline->points, sizeof(MaskSplinePoint) * (point_index + 1));
229  memcpy(new_point_array + point_index + 2,
230  spline->points + point_index + 1,
231  sizeof(MaskSplinePoint) * (spline->tot_point - point_index - 1));
232 
233  MEM_freeN(spline->points);
234  spline->points = new_point_array;
235  spline->tot_point++;
236 }
237 
238 static bool add_vertex_subdivide(const bContext *C, Mask *mask, const float co[2])
239 {
240  MaskLayer *mask_layer;
241  MaskSpline *spline;
243  const float threshold = 12;
244  float tangent[2];
245  float u;
246 
248  mask,
249  co,
250  threshold,
251  false,
252  tangent,
253  true,
254  true,
255  &mask_layer,
256  &spline,
257  &point,
258  &u,
259  NULL)) {
261  const float ctime = scene->r.cfra;
262 
263  MaskSplinePoint *new_point;
264  int point_index = point - spline->points;
265 
267 
269 
270  new_point = &spline->points[point_index + 1];
271 
272  setup_vertex_point(mask, spline, new_point, co, u, ctime, NULL, true);
273 
274  /* TODO: we could pass the spline! */
276  BKE_mask_layer_shape_spline_to_index(mask_layer, spline) +
277  point_index + 1,
278  true,
279  true);
280 
281  mask_layer->act_spline = spline;
282  mask_layer->act_point = new_point;
283 
285 
286  return true;
287  }
288 
289  return false;
290 }
291 
292 static bool add_vertex_extrude(const bContext *C,
293  Mask *mask,
294  MaskLayer *mask_layer,
295  const float co[2])
296 {
298  const float ctime = scene->r.cfra;
299 
300  MaskSpline *spline;
302  MaskSplinePoint *new_point = NULL, *ref_point = NULL;
303 
304  /* check on which side we want to add the point */
305  int point_index;
306  float tangent_point[2];
307  float tangent_co[2];
308  bool do_cyclic_correct = false;
309  bool do_prev; /* use prev point rather than next?? */
310 
311  if (!mask_layer) {
312  return false;
313  }
314  finSelectedSplinePoint(mask_layer, &spline, &point, true);
315 
317 
318  point_index = (point - spline->points);
319 
321 
322  if ((spline->flag & MASK_SPLINE_CYCLIC) ||
323  (point_index > 0 && point_index != spline->tot_point - 1)) {
324  BKE_mask_calc_tangent_polyline(spline, point, tangent_point);
325  sub_v2_v2v2(tangent_co, co, point->bezt.vec[1]);
326 
327  if (dot_v2v2(tangent_point, tangent_co) < 0.0f) {
328  do_prev = true;
329  }
330  else {
331  do_prev = false;
332  }
333  }
334  else if (((spline->flag & MASK_SPLINE_CYCLIC) == 0) && (point_index == 0)) {
335  do_prev = true;
336  }
337  else if (((spline->flag & MASK_SPLINE_CYCLIC) == 0) && (point_index == spline->tot_point - 1)) {
338  do_prev = false;
339  }
340  else {
341  do_prev = false; /* quiet warning */
342  /* should never get here */
343  BLI_assert(0);
344  }
345 
346  /* use the point before the active one */
347  if (do_prev) {
348  point_index--;
349  if (point_index < 0) {
350  point_index += spline->tot_point; /* wrap index */
351  if ((spline->flag & MASK_SPLINE_CYCLIC) == 0) {
352  do_cyclic_correct = true;
353  point_index = 0;
354  }
355  }
356  }
357 
358 #if 0
359  print_v2("", tangent_point);
360  printf("%d\n", point_index);
361 #endif
362 
364 
365  if (do_cyclic_correct) {
366  ref_point = &spline->points[point_index + 1];
367  new_point = &spline->points[point_index];
368  *ref_point = *new_point;
369  memset(new_point, 0, sizeof(*new_point));
370  }
371  else {
372  ref_point = &spline->points[point_index];
373  new_point = &spline->points[point_index + 1];
374  }
375 
376  mask_layer->act_point = new_point;
377 
378  setup_vertex_point(mask, spline, new_point, co, 0.5f, ctime, ref_point, false);
379 
380  if (mask_layer->splines_shapes.first) {
381  point_index = (((int)(new_point - spline->points) + 0) % spline->tot_point);
383  BKE_mask_layer_shape_spline_to_index(mask_layer, spline) +
384  point_index,
385  true,
386  true);
387  }
388 
390 
391  return true;
392 }
393 
394 static bool add_vertex_new(const bContext *C, Mask *mask, MaskLayer *mask_layer, const float co[2])
395 {
397  const float ctime = scene->r.cfra;
398 
399  MaskSpline *spline;
400  MaskSplinePoint *new_point = NULL, *ref_point = NULL;
401 
402  if (!mask_layer) {
403  /* If there's no mask layer currently operating on, create new one. */
404  mask_layer = BKE_mask_layer_new(mask, "");
405  mask->masklay_act = mask->masklay_tot - 1;
406  }
407 
409 
410  spline = BKE_mask_spline_add(mask_layer);
411 
412  mask_layer->act_spline = spline;
413  new_point = spline->points;
414 
415  mask_layer->act_point = new_point;
416 
417  setup_vertex_point(mask, spline, new_point, co, 0.5f, ctime, ref_point, false);
418 
419  {
420  int point_index = (((int)(new_point - spline->points) + 0) % spline->tot_point);
422  BKE_mask_layer_shape_spline_to_index(mask_layer, spline) +
423  point_index,
424  true,
425  true);
426  }
427 
429 
430  return true;
431 }
432 
433 /* Convert coordinate from normalized space to pixel one.
434  * TODO(sergey): Make the function more generally available. */
436  const float point_normalized[2],
437  float point_pixel[2])
438 {
440  ARegion *region = CTX_wm_region(C);
441 
442  float scalex, scaley;
443  ED_mask_pixelspace_factor(area, region, &scalex, &scaley);
444 
445  point_pixel[0] = point_normalized[0] * scalex;
446  point_pixel[1] = point_normalized[1] * scaley;
447 }
448 
450  Mask *mask,
451  MaskSpline *spline,
452  MaskSplinePoint *active_point,
453  MaskSplinePoint *other_point,
454  float co[2])
455 {
456  const float tolerance_in_pixels_squared = 4 * 4;
457 
458  if (spline->flag & MASK_SPLINE_CYCLIC) {
459  /* The spline is already cyclic, so there is no need to handle anything here.
460  * Return PASS_THROUGH so that it's possible to add vertices close to the endpoints of the
461  * cyclic spline. */
462  return OPERATOR_PASS_THROUGH;
463  }
464 
465  float co_pixel[2];
466  mask_point_make_pixel_space(C, co, co_pixel);
467 
468  float point_pixel[2];
469  mask_point_make_pixel_space(C, other_point->bezt.vec[1], point_pixel);
470 
471  const float dist_squared = len_squared_v2v2(co_pixel, point_pixel);
472  if (dist_squared > tolerance_in_pixels_squared) {
473  return OPERATOR_PASS_THROUGH;
474  }
475 
476  spline->flag |= MASK_SPLINE_CYCLIC;
477 
478  /* TODO: update keyframes in time. */
479  BKE_mask_calc_handle_point_auto(spline, active_point, false);
480  BKE_mask_calc_handle_point_auto(spline, other_point, false);
481 
483 
485 
486  return OPERATOR_FINISHED;
487 }
488 
490  bContext *C, Mask *mask, MaskSpline *spline, MaskSplinePoint *active_point, float co[2])
491 {
492  MaskSplinePoint *first_point = &spline->points[0];
493  MaskSplinePoint *last_point = &spline->points[spline->tot_point - 1];
494  const bool is_first_point_active = (active_point == first_point);
495  const bool is_last_point_active = (active_point == last_point);
496  if (is_last_point_active) {
497  return add_vertex_handle_cyclic_at_point(C, mask, spline, active_point, first_point, co);
498  }
499  if (is_first_point_active) {
500  return add_vertex_handle_cyclic_at_point(C, mask, spline, active_point, last_point, co);
501  }
502  return OPERATOR_PASS_THROUGH;
503 }
504 
507 /* -------------------------------------------------------------------- */
512 {
513  MaskViewLockState lock_state;
514  ED_mask_view_lock_state_store(C, &lock_state);
515 
517  if (mask == NULL) {
518  /* if there's no active mask, create one */
519  mask = ED_mask_new(C, NULL);
520  }
521 
522  MaskLayer *mask_layer = BKE_mask_layer_active(mask);
523 
524  if (mask_layer && mask_layer->visibility_flag & (MASK_HIDE_VIEW | MASK_HIDE_SELECT)) {
525  mask_layer = NULL;
526  }
527 
528  float co[2];
529  RNA_float_get_array(op->ptr, "location", co);
530 
531  /* TODO: having an active point but no active spline is possible, why? */
532  if (mask_layer && mask_layer->act_spline && mask_layer->act_point &&
533  MASKPOINT_ISSEL_ANY(mask_layer->act_point)) {
534  MaskSpline *spline = mask_layer->act_spline;
535  MaskSplinePoint *active_point = mask_layer->act_point;
536  const int cyclic_result = add_vertex_handle_cyclic(C, mask, spline, active_point, co);
537  if (cyclic_result != OPERATOR_PASS_THROUGH) {
538  return cyclic_result;
539  }
540 
541  if (!add_vertex_subdivide(C, mask, co)) {
542  if (!add_vertex_extrude(C, mask, mask_layer, co)) {
543  return OPERATOR_CANCELLED;
544  }
545  }
546  }
547  else {
548  if (!add_vertex_subdivide(C, mask, co)) {
549  if (!add_vertex_new(C, mask, mask_layer, co)) {
550  return OPERATOR_CANCELLED;
551  }
552  }
553  }
554 
556 
558 
559  return OPERATOR_FINISHED;
560 }
561 
562 static int add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event)
563 {
565  ARegion *region = CTX_wm_region(C);
566 
567  float co[2];
568 
569  ED_mask_mouse_pos(area, region, event->mval, co);
570 
571  RNA_float_set_array(op->ptr, "location", co);
572 
573  return add_vertex_exec(C, op);
574 }
575 
577 {
578  /* identifiers */
579  ot->name = "Add Vertex";
580  ot->description = "Add vertex to active spline";
581  ot->idname = "MASK_OT_add_vertex";
582 
583  /* api callbacks */
587 
588  /* flags */
590 
591  /* properties */
593  "location",
594  2,
595  NULL,
596  -FLT_MAX,
597  FLT_MAX,
598  "Location",
599  "Location of vertex in normalized space",
600  -1.0f,
601  1.0f);
602 }
603 
606 /* -------------------------------------------------------------------- */
611 {
613  MaskLayer *mask_layer;
614  MaskSpline *spline;
616  const float threshold = 12;
617  float co[2], u;
618 
619  RNA_float_get_array(op->ptr, "location", co);
620 
622  if (point) {
623  return OPERATOR_FINISHED;
624  }
625 
627  mask,
628  co,
629  threshold,
630  true,
631  NULL,
632  true,
633  true,
634  &mask_layer,
635  &spline,
636  &point,
637  &u,
638  NULL)) {
639  float w = BKE_mask_point_weight(spline, point, u);
640  float weight_scalar = BKE_mask_point_weight_scalar(spline, point, u);
641 
642  if (weight_scalar != 0.0f) {
643  w = w / weight_scalar;
644  }
645 
647 
649 
651 
652  return OPERATOR_FINISHED;
653  }
654 
655  return OPERATOR_CANCELLED;
656 }
657 
658 static int add_feather_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event)
659 {
661  ARegion *region = CTX_wm_region(C);
662 
663  float co[2];
664 
665  ED_mask_mouse_pos(area, region, event->mval, co);
666 
667  RNA_float_set_array(op->ptr, "location", co);
668 
669  return add_feather_vertex_exec(C, op);
670 }
671 
673 {
674  /* identifiers */
675  ot->name = "Add Feather Vertex";
676  ot->description = "Add vertex to feather";
677  ot->idname = "MASK_OT_add_feather_vertex";
678 
679  /* api callbacks */
683 
684  /* flags */
686 
687  /* properties */
689  "location",
690  2,
691  NULL,
692  -FLT_MAX,
693  FLT_MAX,
694  "Location",
695  "Location of vertex in normalized space",
696  -1.0f,
697  1.0f);
698 }
699 
702 /* -------------------------------------------------------------------- */
706 static BezTriple *points_to_bezier(const float (*points)[2],
707  const int num_points,
708  const char handle_type,
709  const float scale,
710  const float location[2])
711 {
712  BezTriple *bezier_points = MEM_calloc_arrayN(num_points, sizeof(BezTriple), __func__);
713  for (int i = 0; i < num_points; i++) {
714  copy_v2_v2(bezier_points[i].vec[1], points[i]);
715  mul_v2_fl(bezier_points[i].vec[1], scale);
716  add_v2_v2(bezier_points[i].vec[1], location);
717 
718  bezier_points[i].h1 = handle_type;
719  bezier_points[i].h2 = handle_type;
720  }
721 
722  for (int i = 0; i < num_points; i++) {
723  BKE_nurb_handle_calc(&bezier_points[i],
724  &bezier_points[(i - 1 + num_points) % num_points],
725  &bezier_points[(i + 1) % num_points],
726  false,
727  false);
728  }
729 
730  return bezier_points;
731 }
732 
734  bContext *C, wmOperator *op, const float (*points)[2], int num_points, char handle_type)
735 {
736  MaskViewLockState lock_state;
737  ED_mask_view_lock_state_store(C, &lock_state);
738 
740  int size = RNA_float_get(op->ptr, "size");
741 
742  int width, height;
744  float scale = (float)size / max_ii(width, height);
745 
746  /* Get location in mask space. */
747  float frame_size[2];
748  frame_size[0] = width;
749  frame_size[1] = height;
750  float location[2];
751  RNA_float_get_array(op->ptr, "location", location);
752  location[0] /= width;
753  location[1] /= height;
754  BKE_mask_coord_from_frame(location, location, frame_size);
755 
756  /* Make it so new primitive is centered to mouse location. */
757  location[0] -= 0.5f * scale;
758  location[1] -= 0.5f * scale;
759 
760  bool added_mask = false;
761  MaskLayer *mask_layer = ED_mask_layer_ensure(C, &added_mask);
763 
765 
766  MaskSpline *new_spline = BKE_mask_spline_add(mask_layer);
767  new_spline->flag = MASK_SPLINE_CYCLIC | SELECT;
768  new_spline->points = MEM_recallocN(new_spline->points, sizeof(MaskSplinePoint) * num_points);
769 
770  mask_layer->act_spline = new_spline;
771  mask_layer->act_point = NULL;
772 
773  const int spline_index = BKE_mask_layer_shape_spline_to_index(mask_layer, new_spline);
774 
775  BezTriple *bezier_points = points_to_bezier(points, num_points, handle_type, scale, location);
776 
777  for (int i = 0; i < num_points; i++) {
778  new_spline->tot_point = i + 1;
779 
780  MaskSplinePoint *new_point = &new_spline->points[i];
781  BKE_mask_parent_init(&new_point->parent);
782 
783  new_point->bezt = bezier_points[i];
784 
785  BKE_mask_point_select_set(new_point, true);
786 
787  if (mask_layer->splines_shapes.first) {
788  BKE_mask_layer_shape_changed_add(mask_layer, spline_index + i, true, false);
789  }
790  }
791 
792  MEM_freeN(bezier_points);
793 
794  if (added_mask) {
796  }
798 
800 
802 
803  return OPERATOR_FINISHED;
804 }
805 
806 static int primitive_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
807 {
809  float cursor[2];
810  int width, height;
811 
814 
815  cursor[0] *= width;
816  cursor[1] *= height;
817 
818  RNA_float_set_array(op->ptr, "location", cursor);
819 
820  return op->type->exec(C, op);
821 }
822 
824 {
826  ot->srna, "size", 100, -FLT_MAX, FLT_MAX, "Size", "Size of new circle", -FLT_MAX, FLT_MAX);
828  "location",
829  2,
830  NULL,
831  -FLT_MAX,
832  FLT_MAX,
833  "Location",
834  "Location of new circle",
835  -FLT_MAX,
836  FLT_MAX);
837 }
838 
841 /* -------------------------------------------------------------------- */
846 {
847  const float points[4][2] = {{0.0f, 0.5f}, {0.5f, 1.0f}, {1.0f, 0.5f}, {0.5f, 0.0f}};
848  int num_points = sizeof(points) / (sizeof(float[2]));
849 
850  create_primitive_from_points(C, op, points, num_points, HD_AUTO);
851 
852  return OPERATOR_FINISHED;
853 }
854 
856 {
857  /* identifiers */
858  ot->name = "Add Circle";
859  ot->description = "Add new circle-shaped spline";
860  ot->idname = "MASK_OT_primitive_circle_add";
861 
862  /* api callbacks */
866 
867  /* flags */
869 
870  /* properties */
872 }
873 
876 /* -------------------------------------------------------------------- */
881 {
882  const float points[4][2] = {{0.0f, 0.0f}, {0.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, 0.0f}};
883  int num_points = sizeof(points) / (sizeof(float[2]));
884 
885  create_primitive_from_points(C, op, points, num_points, HD_VECT);
886 
887  return OPERATOR_FINISHED;
888 }
889 
891 {
892  /* identifiers */
893  ot->name = "Add Square";
894  ot->description = "Add new square-shaped spline";
895  ot->idname = "MASK_OT_primitive_square_add";
896 
897  /* api callbacks */
901 
902  /* flags */
904 
905  /* properties */
907 }
908 
typedef float(TangentPoint)[2]
struct ScrArea * CTX_wm_area(const bContext *C)
Definition: context.c:738
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1090
struct Mask * CTX_data_edit_mask(const bContext *C)
Definition: context.c:1390
struct ARegion * CTX_wm_region(const bContext *C)
Definition: context.c:749
void BKE_nurb_handle_calc(struct BezTriple *bezt, struct BezTriple *prev, struct BezTriple *next, bool is_fcurve, char smoothing)
Definition: curve.cc:3978
#define MASKPOINT_ISSEL_ANY(p)
Definition: BKE_mask.h:296
void BKE_mask_layer_shape_changed_add(struct MaskLayer *masklay, int index, bool do_init, bool do_init_interpolate)
Definition: mask.c:1894
void BKE_mask_calc_tangent_polyline(struct MaskSpline *spline, struct MaskSplinePoint *point, float t[2])
Definition: mask.c:1412
void BKE_mask_point_select_set(struct MaskSplinePoint *point, bool do_select)
Definition: mask.c:955
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.
Definition: mask.c:1495
struct MaskLayer * BKE_mask_layer_new(struct Mask *mask, const char *name)
Definition: mask.c:337
#define MASKPOINT_SEL_ALL(p)
Definition: BKE_mask.h:305
struct MaskLayer * BKE_mask_layer_active(struct Mask *mask)
Definition: mask.c:361
float BKE_mask_point_weight(struct MaskSpline *spline, struct MaskSplinePoint *point, float u)
Definition: mask.c:857
float BKE_mask_point_weight_scalar(struct MaskSpline *spline, struct MaskSplinePoint *point, float u)
Definition: mask.c:837
void BKE_mask_calc_handle_adjacent_interp(struct MaskSpline *spline, struct MaskSplinePoint *point, float u)
Definition: mask.c:1449
void BKE_mask_point_parent_matrix_get(struct MaskSplinePoint *point, float ctime, float parent_matrix[3][3])
Definition: mask.c:1277
void BKE_mask_point_add_uw(struct MaskSplinePoint *point, float u, float w)
Definition: mask.c:937
int BKE_mask_layer_shape_spline_to_index(struct MaskLayer *masklay, struct MaskSpline *spline)
Definition: mask.c:1846
void BKE_mask_parent_init(struct MaskParent *parent)
Definition: mask.c:1577
#define MASKPOINT_DESEL_ALL(p)
Definition: BKE_mask.h:312
void BKE_mask_coord_from_frame(float r_co[2], const float co[2], const float frame_size[2])
Definition: mask.c:1184
struct MaskSpline * BKE_mask_spline_add(struct MaskLayer *masklay)
Definition: mask.c:469
#define BLI_assert(a)
Definition: BLI_assert.h:46
MINLINE int max_ii(int a, int b)
MINLINE int mod_i(int i, int n)
void mul_m3_v2(const float m[3][3], float r[2])
Definition: math_matrix.c:724
bool invert_m3(float R[3][3])
Definition: math_matrix.c:1171
MINLINE float len_squared_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void mul_v2_fl(float r[2], float f)
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void add_v2_v2(float r[2], const float a[2])
void print_v2(const char *str, const float v[2])
Definition: math_vector.c:813
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE float dot_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
#define UNUSED(x)
#define MAX2(a, b)
#define ELEM(...)
void DEG_id_tag_update(struct ID *id, int flag)
@ ID_RECALC_GEOMETRY
Definition: DNA_ID.h:791
@ HD_VECT
@ HD_AUTO
@ HD_ALIGN
#define MASK_HIDE_SELECT
#define MASK_HIDE_VIEW
@ MASK_SPLINE_CYCLIC
@ OPERATOR_CANCELLED
@ OPERATOR_FINISHED
@ OPERATOR_PASS_THROUGH
bool ED_maskedit_mask_poll(struct bContext *C)
Definition: mask_edit.c:61
void ED_mask_mouse_pos(struct ScrArea *area, struct ARegion *region, const int mval[2], float co[2])
Definition: mask_query.c:478
void ED_mask_pixelspace_factor(struct ScrArea *area, struct ARegion *region, float *scalex, float *scaley)
Definition: mask_query.c:770
bool ED_maskedit_visible_splines_poll(struct bContext *C)
Definition: mask_edit.c:45
void ED_mask_cursor_location_get(struct ScrArea *area, float cursor[2])
Definition: mask_query.c:813
void ED_mask_get_size(struct ScrArea *area, int *width, int *height)
Definition: mask_query.c:674
@ SEL_DESELECT
_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 GLsizei width
Read Guarded memory(de)allocation.
#define MEM_recallocN(vmemh, len)
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a point
#define C
Definition: RandGen.cpp:25
@ OPTYPE_UNDO
Definition: WM_types.h:148
@ OPTYPE_REGISTER
Definition: WM_types.h:146
#define NA_ADDED
Definition: WM_types.h:525
#define NA_EDITED
Definition: WM_types.h:523
#define NC_MASK
Definition: WM_types.h:348
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition: btQuadWord.h:119
#define SELECT
Scene scene
ccl_gpu_kernel_postfix ccl_global float int int int int float threshold
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
void *(* MEM_calloc_arrayN)(size_t len, size_t size, const char *str)
Definition: mallocn.c:32
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:31
void MASK_OT_add_feather_vertex(wmOperatorType *ot)
Definition: mask_add.c:672
static int create_primitive_from_points(bContext *C, wmOperator *op, const float(*points)[2], int num_points, char handle_type)
Definition: mask_add.c:733
static int add_vertex_exec(bContext *C, wmOperator *op)
Definition: mask_add.c:511
static int primitive_circle_add_exec(bContext *C, wmOperator *op)
Definition: mask_add.c:845
static BezTriple * points_to_bezier(const float(*points)[2], const int num_points, const char handle_type, const float scale, const float location[2])
Definition: mask_add.c:706
static int primitive_square_add_exec(bContext *C, wmOperator *op)
Definition: mask_add.c:880
static bool add_vertex_extrude(const bContext *C, Mask *mask, MaskLayer *mask_layer, const float co[2])
Definition: mask_add.c:292
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.c:38
void MASK_OT_primitive_square_add(wmOperatorType *ot)
Definition: mask_add.c:890
static int add_feather_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition: mask_add.c:658
static int add_feather_vertex_exec(bContext *C, wmOperator *op)
Definition: mask_add.c:610
void MASK_OT_primitive_circle_add(wmOperatorType *ot)
Definition: mask_add.c:855
static void define_primitive_add_properties(wmOperatorType *ot)
Definition: mask_add.c:823
static int add_vertex_handle_cyclic(bContext *C, Mask *mask, MaskSpline *spline, MaskSplinePoint *active_point, float co[2])
Definition: mask_add.c:489
static void mask_point_make_pixel_space(bContext *C, const float point_normalized[2], float point_pixel[2])
Definition: mask_add.c:435
static int primitive_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
Definition: mask_add.c:806
static bool add_vertex_new(const bContext *C, Mask *mask, MaskLayer *mask_layer, const float co[2])
Definition: mask_add.c:394
static int add_vertex_handle_cyclic_at_point(bContext *C, Mask *mask, MaskSpline *spline, MaskSplinePoint *active_point, MaskSplinePoint *other_point, float co[2])
Definition: mask_add.c:449
static bool add_vertex_subdivide(const bContext *C, Mask *mask, const float co[2])
Definition: mask_add.c:238
void MASK_OT_add_vertex(wmOperatorType *ot)
Definition: mask_add.c:576
static int add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition: mask_add.c:562
static void finSelectedSplinePoint(MaskLayer *mask_layer, MaskSpline **spline, MaskSplinePoint **point, bool check_active)
Definition: mask_add.c:171
static void mask_spline_add_point_at_index(MaskSpline *spline, int point_index)
Definition: mask_add.c:221
void ED_mask_view_lock_state_restore_no_jump(const bContext *C, const MaskViewLockState *state)
Definition: mask_edit.c:216
void ED_mask_view_lock_state_store(const bContext *C, MaskViewLockState *state)
Definition: mask_edit.c:208
void ED_mask_select_flush_all(struct Mask *mask)
Definition: mask_select.c:145
bool ED_mask_find_nearest_diff_point(const struct bContext *C, struct Mask *mask, const float normal_co[2], int threshold, bool feather, float tangent[2], bool use_deform, bool use_project, struct MaskLayer **r_mask_layer, struct MaskSpline **r_spline, struct MaskSplinePoint **r_point, float *r_u, float *r_score)
struct Mask * ED_mask_new(struct bContext *C, const char *name)
Definition: mask_ops.c:41
void ED_mask_select_toggle_all(struct Mask *mask, int action)
Definition: mask_select.c:108
struct MaskLayer * ED_mask_layer_ensure(struct bContext *C, bool *r_added_mask)
Definition: mask_ops.c:71
struct MaskSplinePoint * ED_mask_point_find_nearest(const struct bContext *C, struct Mask *mask, const float normal_co[2], float threshold, struct MaskLayer **r_mask_layer, struct MaskSpline **r_spline, eMaskWhichHandle *r_which_handle, float *r_score)
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
Definition: math_float4.h:513
static void area(int d1, int d2, int e1, int e2, float weights[2])
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
Definition: rna_access.c:4980
float RNA_float_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:4957
void RNA_float_set_array(PointerRNA *ptr, const char *name, const float *values)
Definition: rna_access.c:4992
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, float default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
Definition: rna_define.c:3836
PropertyRNA * RNA_def_float_vector(StructOrFunctionRNA *cont_, const char *identifier, int len, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
Definition: rna_define.c:3862
uint8_t h1
float vec[3][3]
uint8_t h2
void * first
Definition: DNA_listBase.h:31
ListBase splines_shapes
char visibility_flag
ListBase splines
struct MaskSplinePoint * act_point
struct MaskSpline * act_spline
MaskParent parent
struct MaskSpline * next
MaskSplinePoint * points
struct RenderData r
int mval[2]
Definition: WM_types.h:684
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:919
const char * name
Definition: WM_types.h:888
const char * idname
Definition: WM_types.h:890
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:943
struct StructRNA * srna
Definition: WM_types.h:969
const char * description
Definition: WM_types.h:893
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:903
struct wmOperatorType * type
struct PointerRNA * ptr
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
wmOperatorType * ot
Definition: wm_files.c:3479