Blender  V3.3
mask.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 <stddef.h>
9 #include <string.h>
10 
11 #include "CLG_log.h"
12 
13 #include "MEM_guardedalloc.h"
14 
15 #include "BLI_endian_switch.h"
16 #include "BLI_ghash.h"
17 #include "BLI_listbase.h"
18 #include "BLI_math.h"
19 #include "BLI_string.h"
20 #include "BLI_string_utils.h"
21 #include "BLI_utildefines.h"
22 
23 #include "BLT_translation.h"
24 
25 #include "DNA_defaults.h"
26 #include "DNA_mask_types.h"
27 
28 #include "BKE_animsys.h"
29 #include "BKE_curve.h"
30 #include "BKE_idtype.h"
31 
32 #include "BKE_anim_data.h"
33 #include "BKE_image.h"
34 #include "BKE_lib_id.h"
35 #include "BKE_lib_query.h"
36 #include "BKE_main.h"
37 #include "BKE_mask.h"
38 #include "BKE_movieclip.h"
39 #include "BKE_tracking.h"
40 
41 #include "DEG_depsgraph_build.h"
42 
43 #include "BLO_read_write.h"
44 
45 static CLG_LogRef LOG = {"bke.mask"};
46 
47 static void mask_copy_data(Main *UNUSED(bmain),
48  ID *id_dst,
49  const ID *id_src,
50  const int UNUSED(flag))
51 {
52  Mask *mask_dst = (Mask *)id_dst;
53  const Mask *mask_src = (const Mask *)id_src;
54 
55  BLI_listbase_clear(&mask_dst->masklayers);
56 
57  /* TODO: add unused flag to those as well. */
58  BKE_mask_layer_copy_list(&mask_dst->masklayers, &mask_src->masklayers);
59 
60  /* enable fake user by default */
61  id_fake_user_set(&mask_dst->id);
62 }
63 
64 static void mask_free_data(ID *id)
65 {
66  Mask *mask = (Mask *)id;
67 
68  /* free mask data */
69  BKE_mask_layer_free_list(&mask->masklayers);
70 }
71 
73 {
74  Mask *mask = (Mask *)id;
75 
76  LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
77  LISTBASE_FOREACH (MaskSpline *, mask_spline, &mask_layer->splines) {
78  for (int i = 0; i < mask_spline->tot_point; i++) {
79  MaskSplinePoint *point = &mask_spline->points[i];
81  }
82  }
83  }
84 }
85 
86 static void mask_blend_write(BlendWriter *writer, ID *id, const void *id_address)
87 {
88  Mask *mask = (Mask *)id;
89 
90  MaskLayer *masklay;
91 
92  BLO_write_id_struct(writer, Mask, id_address, &mask->id);
93  BKE_id_blend_write(writer, &mask->id);
94 
95  if (mask->adt) {
96  BKE_animdata_blend_write(writer, mask->adt);
97  }
98 
99  for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
100  MaskSpline *spline;
101  MaskLayerShape *masklay_shape;
102 
103  BLO_write_struct(writer, MaskLayer, masklay);
104 
105  for (spline = masklay->splines.first; spline; spline = spline->next) {
106  int i;
107 
108  void *points_deform = spline->points_deform;
109  spline->points_deform = NULL;
110 
111  BLO_write_struct(writer, MaskSpline, spline);
112  BLO_write_struct_array(writer, MaskSplinePoint, spline->tot_point, spline->points);
113 
114  spline->points_deform = points_deform;
115 
116  for (i = 0; i < spline->tot_point; i++) {
117  MaskSplinePoint *point = &spline->points[i];
118 
119  if (point->tot_uw) {
120  BLO_write_struct_array(writer, MaskSplinePointUW, point->tot_uw, point->uw);
121  }
122  }
123  }
124 
125  for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
126  masklay_shape = masklay_shape->next) {
127  BLO_write_struct(writer, MaskLayerShape, masklay_shape);
129  writer, masklay_shape->tot_vert * MASK_OBJECT_SHAPE_ELEM_SIZE, masklay_shape->data);
130  }
131  }
132 }
133 
134 static void mask_blend_read_data(BlendDataReader *reader, ID *id)
135 {
136  Mask *mask = (Mask *)id;
137  BLO_read_data_address(reader, &mask->adt);
138 
139  BLO_read_list(reader, &mask->masklayers);
140 
141  LISTBASE_FOREACH (MaskLayer *, masklay, &mask->masklayers) {
142  /* can't use newdataadr since it's a pointer within an array */
143  MaskSplinePoint *act_point_search = NULL;
144 
145  BLO_read_list(reader, &masklay->splines);
146 
147  LISTBASE_FOREACH (MaskSpline *, spline, &masklay->splines) {
148  MaskSplinePoint *points_old = spline->points;
149 
150  BLO_read_data_address(reader, &spline->points);
151 
152  for (int i = 0; i < spline->tot_point; i++) {
153  MaskSplinePoint *point = &spline->points[i];
154 
155  if (point->tot_uw) {
156  BLO_read_data_address(reader, &point->uw);
157  }
158  }
159 
160  /* detect active point */
161  if ((act_point_search == NULL) && (masklay->act_point >= points_old) &&
162  (masklay->act_point < points_old + spline->tot_point)) {
163  act_point_search = &spline->points[masklay->act_point - points_old];
164  }
165  }
166 
167  BLO_read_list(reader, &masklay->splines_shapes);
168 
169  LISTBASE_FOREACH (MaskLayerShape *, masklay_shape, &masklay->splines_shapes) {
170  BLO_read_data_address(reader, &masklay_shape->data);
171 
172  if (masklay_shape->tot_vert) {
173  if (BLO_read_requires_endian_switch(reader)) {
174  BLI_endian_switch_float_array(masklay_shape->data,
175  masklay_shape->tot_vert * sizeof(float) *
177  }
178  }
179  }
180 
181  BLO_read_data_address(reader, &masklay->act_spline);
182  masklay->act_point = act_point_search;
183  }
184 }
185 
186 static void lib_link_mask_parent(BlendLibReader *reader, Mask *mask, MaskParent *parent)
187 {
188  BLO_read_id_address(reader, mask->id.lib, &parent->id);
189 }
190 
191 static void mask_blend_read_lib(BlendLibReader *reader, ID *id)
192 {
193  Mask *mask = (Mask *)id;
194  LISTBASE_FOREACH (MaskLayer *, masklay, &mask->masklayers) {
195  MaskSpline *spline;
196 
197  spline = masklay->splines.first;
198  while (spline) {
199  for (int i = 0; i < spline->tot_point; i++) {
200  MaskSplinePoint *point = &spline->points[i];
201 
202  lib_link_mask_parent(reader, mask, &point->parent);
203  }
204 
205  lib_link_mask_parent(reader, mask, &spline->parent);
206 
207  spline = spline->next;
208  }
209  }
210 }
211 
212 static void expand_mask_parent(BlendExpander *expander, MaskParent *parent)
213 {
214  if (parent->id) {
215  BLO_expand(expander, parent->id);
216  }
217 }
218 
219 static void mask_blend_read_expand(BlendExpander *expander, ID *id)
220 {
221  Mask *mask = (Mask *)id;
222  LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
223  LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
224  for (int i = 0; i < spline->tot_point; i++) {
225  MaskSplinePoint *point = &spline->points[i];
226  expand_mask_parent(expander, &point->parent);
227  }
228 
229  expand_mask_parent(expander, &spline->parent);
230  }
231  }
232 }
233 
235  .id_code = ID_MSK,
236  .id_filter = FILTER_ID_MSK,
237  .main_listbase_index = INDEX_ID_MSK,
238  .struct_size = sizeof(Mask),
239  .name = "Mask",
240  .name_plural = "masks",
241  .translation_context = BLT_I18NCONTEXT_ID_MASK,
243  .asset_type_info = NULL,
244 
245  .init_data = NULL,
246  .copy_data = mask_copy_data,
247  .free_data = mask_free_data,
248  .make_local = NULL,
249  .foreach_id = mask_foreach_id,
250  .foreach_cache = NULL,
251  .foreach_path = NULL,
252  .owner_get = NULL,
253 
254  .blend_write = mask_blend_write,
255  .blend_read_data = mask_blend_read_data,
256  .blend_read_lib = mask_blend_read_lib,
257  .blend_read_expand = mask_blend_read_expand,
258 
259  .blend_read_undo_preserve = NULL,
260 
261  .lib_override_apply_post = NULL,
262 };
263 
264 static struct {
266  struct GHash *id_hash;
268 
270  MaskSplinePoint *points_array,
272 {
273  if (point == &points_array[spline->tot_point - 1]) {
274  if (spline->flag & MASK_SPLINE_CYCLIC) {
275  return &points_array[0];
276  }
277 
278  return NULL;
279  }
280 
281  return point + 1;
282 }
283 
285  MaskSplinePoint *points_array,
287 {
288  if (point == points_array) {
289  if (spline->flag & MASK_SPLINE_CYCLIC) {
290  return &points_array[spline->tot_point - 1];
291  }
292 
293  return NULL;
294  }
295 
296  return point - 1;
297 }
298 
300  MaskSplinePoint *points_array,
302 {
303  if (point == &points_array[spline->tot_point - 1]) {
304  if (spline->flag & MASK_SPLINE_CYCLIC) {
305  return &(points_array[0].bezt);
306  }
307 
308  return NULL;
309  }
310 
311  return &((point + 1))->bezt;
312 }
313 
315 {
316  return spline->points_deform ? spline->points_deform : spline->points;
317 }
318 
320  const MaskSplinePoint *point_ref)
321 {
322  if ((point_ref >= spline->points) && (point_ref < &spline->points[spline->tot_point])) {
323  return spline->points;
324  }
325 
326  if ((point_ref >= spline->points_deform) &&
327  (point_ref < &spline->points_deform[spline->tot_point])) {
328  return spline->points_deform;
329  }
330 
331  BLI_assert_msg(0, "wrong array");
332  return NULL;
333 }
334 
335 /* mask layers */
336 
337 MaskLayer *BKE_mask_layer_new(Mask *mask, const char *name)
338 {
339  MaskLayer *masklay = MEM_callocN(sizeof(MaskLayer), __func__);
340 
341  if (name && name[0]) {
342  BLI_strncpy(masklay->name, name, sizeof(masklay->name));
343  }
344  else {
345  strcpy(masklay->name, "MaskLayer");
346  }
347 
348  BLI_addtail(&mask->masklayers, masklay);
349 
351 
352  mask->masklay_tot++;
353 
354  masklay->blend = MASK_BLEND_MERGE_ADD;
355  masklay->alpha = 1.0f;
357 
358  return masklay;
359 }
360 
362 {
363  return BLI_findlink(&mask->masklayers, mask->masklay_act);
364 }
365 
367 {
368  mask->masklay_act = BLI_findindex(&mask->masklayers, masklay);
369 }
370 
372 {
373  BLI_remlink(&mask->masklayers, masklay);
374  BKE_mask_layer_free(masklay);
375 
376  mask->masklay_tot--;
377 
378  if (mask->masklay_act >= mask->masklay_tot) {
379  mask->masklay_act = mask->masklay_tot - 1;
380  }
381 }
382 
384 {
385  BLI_uniquename(&mask->masklayers,
386  masklay,
387  DATA_("MaskLayer"),
388  '.',
389  offsetof(MaskLayer, name),
390  sizeof(masklay->name));
391 }
392 
393 void BKE_mask_layer_rename(Mask *mask, MaskLayer *masklay, char *oldname, char *newname)
394 {
395  BLI_strncpy(masklay->name, newname, sizeof(masklay->name));
396 
398 
399  /* now fix animation paths */
400  BKE_animdata_fix_paths_rename_all(&mask->id, "layers", oldname, masklay->name);
401 }
402 
404 {
405  MaskLayer *masklay_new;
406  MaskSpline *spline;
407 
408  masklay_new = MEM_callocN(sizeof(MaskLayer), "new mask layer");
409 
410  BLI_strncpy(masklay_new->name, masklay->name, sizeof(masklay_new->name));
411 
412  masklay_new->alpha = masklay->alpha;
413  masklay_new->blend = masklay->blend;
414  masklay_new->blend_flag = masklay->blend_flag;
415  masklay_new->flag = masklay->flag;
416  masklay_new->falloff = masklay->falloff;
417  masklay_new->visibility_flag = masklay->visibility_flag;
418 
419  for (spline = masklay->splines.first; spline; spline = spline->next) {
420  MaskSpline *spline_new = BKE_mask_spline_copy(spline);
421 
422  BLI_addtail(&masklay_new->splines, spline_new);
423 
424  if (spline == masklay->act_spline) {
425  masklay_new->act_spline = spline_new;
426  }
427 
428  if (masklay->act_point >= spline->points &&
429  masklay->act_point < spline->points + spline->tot_point) {
430  const size_t point_index = masklay->act_point - spline->points;
431  masklay_new->act_point = spline_new->points + point_index;
432  }
433  }
434 
435  /* correct animation */
436  if (masklay->splines_shapes.first) {
437  MaskLayerShape *masklay_shape;
438  MaskLayerShape *masklay_shape_new;
439 
440  for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
441  masklay_shape = masklay_shape->next) {
442  masklay_shape_new = MEM_callocN(sizeof(MaskLayerShape), "new mask layer shape");
443 
444  masklay_shape_new->data = MEM_dupallocN(masklay_shape->data);
445  masklay_shape_new->tot_vert = masklay_shape->tot_vert;
446  masklay_shape_new->flag = masklay_shape->flag;
447  masklay_shape_new->frame = masklay_shape->frame;
448 
449  BLI_addtail(&masklay_new->splines_shapes, masklay_shape_new);
450  }
451  }
452 
453  return masklay_new;
454 }
455 
456 void BKE_mask_layer_copy_list(ListBase *masklayers_new, const ListBase *masklayers)
457 {
458  MaskLayer *layer;
459 
460  for (layer = masklayers->first; layer; layer = layer->next) {
461  MaskLayer *layer_new = BKE_mask_layer_copy(layer);
462 
463  BLI_addtail(masklayers_new, layer_new);
464  }
465 }
466 
467 /* splines */
468 
470 {
471  MaskSpline *spline;
472 
473  spline = MEM_callocN(sizeof(MaskSpline), "new mask spline");
474  BLI_addtail(&masklay->splines, spline);
475 
476  /* spline shall have one point at least */
477  spline->points = MEM_callocN(sizeof(MaskSplinePoint), "new mask spline point");
478  spline->tot_point = 1;
479 
480  /* cyclic shapes are more usually used */
481  /* Disable because its not so nice for drawing. could be done differently. */
482 #if 0
483  spline->flag |= MASK_SPLINE_CYCLIC;
484 #endif
485 
487 
488  BKE_mask_parent_init(&spline->parent);
489 
490  return spline;
491 }
492 
493 bool BKE_mask_spline_remove(MaskLayer *mask_layer, MaskSpline *spline)
494 {
495  if (BLI_remlink_safe(&mask_layer->splines, spline) == false) {
496  return false;
497  }
498 
499  BKE_mask_spline_free(spline);
500 
501  return true;
502 }
503 
505 {
506  const int tot_uw = point->tot_uw;
507  const int tot_uw_half = tot_uw / 2;
508 
509  float co_tmp[2];
510 
511  /* swap handles */
512  copy_v2_v2(co_tmp, point->bezt.vec[0]);
513  copy_v2_v2(point->bezt.vec[0], point->bezt.vec[2]);
514  copy_v2_v2(point->bezt.vec[2], co_tmp);
515  /* in this case the flags are unlikely to be different but swap anyway */
516  SWAP(uint8_t, point->bezt.f1, point->bezt.f3);
517  SWAP(uint8_t, point->bezt.h1, point->bezt.h2);
518 
519  /* swap UW's */
520  if (tot_uw > 1) {
521  /* count */
522  for (int i = 0; i < tot_uw_half; i++) {
523  MaskSplinePointUW *uw_a = &point->uw[i];
524  MaskSplinePointUW *uw_b = &point->uw[tot_uw - (i + 1)];
525  SWAP(MaskSplinePointUW, *uw_a, *uw_b);
526  }
527  }
528 
529  for (int i = 0; i < tot_uw; i++) {
530  MaskSplinePointUW *uw = &point->uw[i];
531  uw->u = 1.0f - uw->u;
532  }
533 }
534 
536 {
537  const int tot_point = spline->tot_point;
538  const int tot_point_half = tot_point / 2;
539  int i, i_prev;
540 
541  if (tot_point < 2) {
542  return;
543  }
544 
545  /* count */
546  for (i = 0; i < tot_point_half; i++) {
547  MaskSplinePoint *point_a = &spline->points[i];
548  MaskSplinePoint *point_b = &spline->points[tot_point - (i + 1)];
549  SWAP(MaskSplinePoint, *point_a, *point_b);
550  }
551 
552  /* correct UW's */
553  i_prev = tot_point - 1;
554  for (i = 0; i < tot_point; i++) {
555 
557 
558  SWAP(MaskSplinePointUW *, spline->points[i].uw, spline->points[i_prev].uw);
559  SWAP(int, spline->points[i].tot_uw, spline->points[i_prev].tot_uw);
560 
561  i_prev = i;
562  }
563 
564  /* correct animation */
565  if (masklay->splines_shapes.first) {
566  MaskLayerShape *masklay_shape;
567 
568  const int spline_index = BKE_mask_layer_shape_spline_to_index(masklay, spline);
569 
570  for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
571  masklay_shape = masklay_shape->next) {
572  MaskLayerShapeElem *fp_arr = (MaskLayerShapeElem *)masklay_shape->data;
573 
574  for (i = 0; i < tot_point_half; i++) {
575  MaskLayerShapeElem *fp_a = &fp_arr[spline_index + (i)];
576  MaskLayerShapeElem *fp_b = &fp_arr[spline_index + (tot_point - (i + 1))];
577  SWAP(MaskLayerShapeElem, *fp_a, *fp_b);
578  }
579  }
580  }
581 }
582 
585  float start_u,
586  const float co[2],
587  const eMaskSign sign)
588 {
589  const float proj_eps = 1e-3;
590  const float proj_eps_sq = proj_eps * proj_eps;
591  const int N = 1000;
592  float u = -1.0f, du = 1.0f / N, u1 = start_u, u2 = start_u;
593  float ang = -1.0f;
594 
595  BLI_assert(abs(sign) <= 1); /* (-1, 0, 1) */
596 
597  while (u1 > 0.0f || u2 < 1.0f) {
598  float n1[2], n2[2], co1[2], co2[2];
599  float v1[2], v2[2];
600  float ang1, ang2;
601 
602  if (u1 >= 0.0f) {
603  BKE_mask_point_segment_co(spline, point, u1, co1);
604  BKE_mask_point_normal(spline, point, u1, n1);
605  sub_v2_v2v2(v1, co, co1);
606 
607  if ((sign == MASK_PROJ_ANY) || ((sign == MASK_PROJ_NEG) && (dot_v2v2(v1, n1) <= 0.0f)) ||
608  ((sign == MASK_PROJ_POS) && (dot_v2v2(v1, n1) >= 0.0f))) {
609 
610  if (len_squared_v2(v1) > proj_eps_sq) {
611  ang1 = angle_v2v2(v1, n1);
612  if (ang1 > (float)M_PI_2) {
613  ang1 = (float)M_PI - ang1;
614  }
615 
616  if (ang < 0.0f || ang1 < ang) {
617  ang = ang1;
618  u = u1;
619  }
620  }
621  else {
622  u = u1;
623  break;
624  }
625  }
626  }
627 
628  if (u2 <= 1.0f) {
629  BKE_mask_point_segment_co(spline, point, u2, co2);
630  BKE_mask_point_normal(spline, point, u2, n2);
631  sub_v2_v2v2(v2, co, co2);
632 
633  if ((sign == MASK_PROJ_ANY) || ((sign == MASK_PROJ_NEG) && (dot_v2v2(v2, n2) <= 0.0f)) ||
634  ((sign == MASK_PROJ_POS) && (dot_v2v2(v2, n2) >= 0.0f))) {
635 
636  if (len_squared_v2(v2) > proj_eps_sq) {
637  ang2 = angle_v2v2(v2, n2);
638  if (ang2 > (float)M_PI_2) {
639  ang2 = (float)M_PI - ang2;
640  }
641 
642  if (ang2 < ang) {
643  ang = ang2;
644  u = u2;
645  }
646  }
647  else {
648  u = u2;
649  break;
650  }
651  }
652  }
653 
654  u1 -= du;
655  u2 += du;
656  }
657 
658  return u;
659 }
660 
661 /* point */
662 
664 {
665  const BezTriple *bezt = &point->bezt;
666 
667  if (bezt->h1 == bezt->h2 && bezt->h1 == HD_ALIGN) {
668  return MASK_HANDLE_MODE_STICK;
669  }
670 
672 }
673 
675  eMaskWhichHandle which_handle,
676  float r_handle[2])
677 {
678  const BezTriple *bezt = &point->bezt;
679 
680  if (which_handle == MASK_WHICH_HANDLE_STICK) {
681  float vec[2];
682 
683  sub_v2_v2v2(vec, bezt->vec[0], bezt->vec[1]);
684 
685  r_handle[0] = (bezt->vec[1][0] + vec[1]);
686  r_handle[1] = (bezt->vec[1][1] - vec[0]);
687  }
688  else if (which_handle == MASK_WHICH_HANDLE_LEFT) {
689  copy_v2_v2(r_handle, bezt->vec[0]);
690  }
691  else if (which_handle == MASK_WHICH_HANDLE_RIGHT) {
692  copy_v2_v2(r_handle, bezt->vec[2]);
693  }
694  else {
695  BLI_assert_msg(0, "Unknown handle passed to BKE_mask_point_handle");
696  }
697 }
698 
700  eMaskWhichHandle which_handle,
701  float loc[2],
702  bool keep_direction,
703  float orig_handle[2],
704  float orig_vec[3][3])
705 {
706  BezTriple *bezt = &point->bezt;
707 
708  if (which_handle == MASK_WHICH_HANDLE_STICK) {
709  float v1[2], v2[2], vec[2];
710  if (keep_direction) {
711  sub_v2_v2v2(v1, loc, orig_vec[1]);
712  sub_v2_v2v2(v2, orig_handle, orig_vec[1]);
713 
714  project_v2_v2v2(vec, v1, v2);
715 
716  if (dot_v2v2(v2, vec) > 0) {
717  float len = len_v2(vec);
718 
719  sub_v2_v2v2(v1, orig_vec[0], orig_vec[1]);
720 
721  mul_v2_fl(v1, len / len_v2(v1));
722 
723  add_v2_v2v2(bezt->vec[0], bezt->vec[1], v1);
724  sub_v2_v2v2(bezt->vec[2], bezt->vec[1], v1);
725  }
726  else {
727  copy_v3_v3(bezt->vec[0], bezt->vec[1]);
728  copy_v3_v3(bezt->vec[2], bezt->vec[1]);
729  }
730  }
731  else {
732  sub_v2_v2v2(v1, loc, bezt->vec[1]);
733 
734  v2[0] = -v1[1];
735  v2[1] = v1[0];
736 
737  add_v2_v2v2(bezt->vec[0], bezt->vec[1], v2);
738  sub_v2_v2v2(bezt->vec[2], bezt->vec[1], v2);
739  }
740  }
741  else if (which_handle == MASK_WHICH_HANDLE_LEFT) {
742  copy_v2_v2(bezt->vec[0], loc);
743  }
744  else if (which_handle == MASK_WHICH_HANDLE_RIGHT) {
745  copy_v2_v2(bezt->vec[2], loc);
746  }
747  else {
748  BLI_assert_msg(0, "unknown handle passed to BKE_mask_point_set_handle");
749  }
750 }
751 
752 void BKE_mask_point_segment_co(MaskSpline *spline, MaskSplinePoint *point, float u, float co[2])
753 {
755 
756  BezTriple *bezt = &point->bezt, *bezt_next;
757 
758  bezt_next = BKE_mask_spline_point_next_bezt(spline, points_array, point);
759 
760  if (!bezt_next) {
761  copy_v2_v2(co, bezt->vec[1]);
762  return;
763  }
764 
766  co, bezt->vec[1], bezt->vec[2], bezt_next->vec[0], bezt_next->vec[1], u);
767 }
768 
769 BLI_INLINE void orthogonal_direction_get(const float vec[2], float result[2])
770 {
771  result[0] = -vec[1];
772  result[1] = vec[0];
774 }
775 
776 void BKE_mask_point_normal(MaskSpline *spline, MaskSplinePoint *point, float u, float n[2])
777 {
778  /* TODO(sergey): This function will re-calculate loads of stuff again and again
779  * when differentiating feather points. This might be easily cached
780  * in the callee function for this case. */
781 
782  MaskSplinePoint *point_prev, *point_next;
783 
784  /* TODO(sergey): This actually depends on a resolution. */
785  const float du = 0.05f;
786 
787  BKE_mask_get_handle_point_adjacent(spline, point, &point_prev, &point_next);
788 
789  if (u - du < 0.0f && point_prev == NULL) {
790  float co[2], dir[2];
791  BKE_mask_point_segment_co(spline, point, u + du, co);
792  sub_v2_v2v2(dir, co, point->bezt.vec[1]);
793  orthogonal_direction_get(dir, n);
794  }
795  else if (u + du > 1.0f && point_next == NULL) {
796  float co[2], dir[2];
797  BKE_mask_point_segment_co(spline, point, u - du, co);
798  sub_v2_v2v2(dir, point->bezt.vec[1], co);
799  orthogonal_direction_get(dir, n);
800  }
801  else {
802  float prev_co[2], next_co[2], co[2];
803  float dir1[2], dir2[2], dir[2];
804 
805  if (u - du < 0.0f) {
806  BKE_mask_point_segment_co(spline, point_prev, 1.0f + (u - du), prev_co);
807  }
808  else {
809  BKE_mask_point_segment_co(spline, point, u - du, prev_co);
810  }
811 
812  BKE_mask_point_segment_co(spline, point, u, co);
813 
814  if (u + du > 1.0f) {
815  BKE_mask_point_segment_co(spline, point_next, u + du - 1.0f, next_co);
816  }
817  else {
818  BKE_mask_point_segment_co(spline, point, u + du, next_co);
819  }
820 
821  sub_v2_v2v2(dir1, co, prev_co);
822  sub_v2_v2v2(dir2, next_co, co);
823 
824  normalize_v2(dir1);
825  normalize_v2(dir2);
826  add_v2_v2v2(dir, dir1, dir2);
827 
828  orthogonal_direction_get(dir, n);
829  }
830 }
831 
832 static float mask_point_interp_weight(BezTriple *bezt, BezTriple *bezt_next, const float u)
833 {
834  return (bezt->weight * (1.0f - u)) + (bezt_next->weight * u);
835 }
836 
838 {
840  BezTriple *bezt = &point->bezt, *bezt_next;
841 
842  bezt_next = BKE_mask_spline_point_next_bezt(spline, points_array, point);
843 
844  if (!bezt_next) {
845  return bezt->weight;
846  }
847  if (u <= 0.0f) {
848  return bezt->weight;
849  }
850  if (u >= 1.0f) {
851  return bezt_next->weight;
852  }
853 
854  return mask_point_interp_weight(bezt, bezt_next, u);
855 }
856 
857 float BKE_mask_point_weight(MaskSpline *spline, MaskSplinePoint *point, const float u)
858 {
860  BezTriple *bezt = &point->bezt, *bezt_next;
861 
862  bezt_next = BKE_mask_spline_point_next_bezt(spline, points_array, point);
863 
864  if (!bezt_next) {
865  return bezt->weight;
866  }
867  if (u <= 0.0f) {
868  return bezt->weight;
869  }
870  if (u >= 1.0f) {
871  return bezt_next->weight;
872  }
873 
874  float cur_u = 0.0f, cur_w = 0.0f, next_u = 0.0f, next_w = 0.0f, fac; /* Quite warnings */
875 
876  for (int i = 0; i <= point->tot_uw; i++) {
877  if (i == 0) {
878  cur_u = 0.0f;
879  cur_w = 1.0f; /* mask_point_interp_weight will scale it */
880  }
881  else {
882  cur_u = point->uw[i - 1].u;
883  cur_w = point->uw[i - 1].w;
884  }
885 
886  if (i == point->tot_uw) {
887  next_u = 1.0f;
888  next_w = 1.0f; /* mask_point_interp_weight will scale it */
889  }
890  else {
891  next_u = point->uw[i].u;
892  next_w = point->uw[i].w;
893  }
894 
895  if (u >= cur_u && u <= next_u) {
896  break;
897  }
898  }
899 
900  fac = (u - cur_u) / (next_u - cur_u);
901 
902  cur_w *= mask_point_interp_weight(bezt, bezt_next, cur_u);
903  next_w *= mask_point_interp_weight(bezt, bezt_next, next_u);
904 
905  if (spline->weight_interp == MASK_SPLINE_INTERP_EASE) {
906  return cur_w + (next_w - cur_w) * (3.0f * fac * fac - 2.0f * fac * fac * fac);
907  }
908 
909  return (1.0f - fac) * cur_w + fac * next_w;
910 }
911 
913 {
914  if (point->tot_uw > 1) {
915  int idx = uw - point->uw;
916 
917  if (idx > 0 && point->uw[idx - 1].u > uw->u) {
918  while (idx > 0 && point->uw[idx - 1].u > point->uw[idx].u) {
919  SWAP(MaskSplinePointUW, point->uw[idx - 1], point->uw[idx]);
920  idx--;
921  }
922  }
923 
924  if (idx < point->tot_uw - 1 && point->uw[idx + 1].u < uw->u) {
925  while (idx < point->tot_uw - 1 && point->uw[idx + 1].u < point->uw[idx].u) {
926  SWAP(MaskSplinePointUW, point->uw[idx + 1], point->uw[idx]);
927  idx++;
928  }
929  }
930 
931  return &point->uw[idx];
932  }
933 
934  return uw;
935 }
936 
938 {
939  if (!point->uw) {
940  point->uw = MEM_mallocN(sizeof(*point->uw), "mask point uw");
941  }
942  else {
943  point->uw = MEM_reallocN(point->uw, (point->tot_uw + 1) * sizeof(*point->uw));
944  }
945 
946  point->uw[point->tot_uw].u = u;
947  point->uw[point->tot_uw].w = w;
948  point->uw[point->tot_uw].flag = 0;
949 
950  point->tot_uw++;
951 
952  BKE_mask_point_sort_uw(point, &point->uw[point->tot_uw - 1]);
953 }
954 
955 void BKE_mask_point_select_set(MaskSplinePoint *point, const bool do_select)
956 {
957  if (do_select) {
959  }
960  else {
962  }
963 
964  for (int i = 0; i < point->tot_uw; i++) {
965  if (do_select) {
966  point->uw[i].flag |= SELECT;
967  }
968  else {
969  point->uw[i].flag &= ~SELECT;
970  }
971  }
972 }
973 
975  const eMaskWhichHandle which_handle,
976  const bool do_select)
977 {
978  if (do_select) {
980  point->bezt.f1 |= SELECT;
981  point->bezt.f3 |= SELECT;
982  }
983  else if (which_handle == MASK_WHICH_HANDLE_LEFT) {
984  point->bezt.f1 |= SELECT;
985  }
986  else if (which_handle == MASK_WHICH_HANDLE_RIGHT) {
987  point->bezt.f3 |= SELECT;
988  }
989  else {
990  BLI_assert_msg(0, "Wrong which_handle passed to BKE_mask_point_select_set_handle");
991  }
992  }
993  else {
995  point->bezt.f1 &= ~SELECT;
996  point->bezt.f3 &= ~SELECT;
997  }
998  else if (which_handle == MASK_WHICH_HANDLE_LEFT) {
999  point->bezt.f1 &= ~SELECT;
1000  }
1001  else if (which_handle == MASK_WHICH_HANDLE_RIGHT) {
1002  point->bezt.f3 &= ~SELECT;
1003  }
1004  else {
1005  BLI_assert_msg(0, "Wrong which_handle passed to BKE_mask_point_select_set_handle");
1006  }
1007  }
1008 }
1009 
1010 /* only mask block itself */
1011 static Mask *mask_alloc(Main *bmain, const char *name)
1012 {
1013  Mask *mask;
1014 
1015  mask = BKE_libblock_alloc(bmain, ID_MSK, name, 0);
1016 
1017  id_fake_user_set(&mask->id);
1018 
1019  return mask;
1020 }
1021 
1022 Mask *BKE_mask_new(Main *bmain, const char *name)
1023 {
1024  Mask *mask;
1025  char mask_name[MAX_ID_NAME - 2];
1026 
1027  if (name && name[0]) {
1028  BLI_strncpy(mask_name, name, sizeof(mask_name));
1029  }
1030  else {
1031  strcpy(mask_name, "Mask");
1032  }
1033 
1034  mask = mask_alloc(bmain, mask_name);
1035 
1036  /* arbitrary defaults */
1037  mask->sfra = 1;
1038  mask->efra = 100;
1039 
1040  DEG_relations_tag_update(bmain);
1041 
1042  return mask;
1043 }
1044 
1046 {
1047  if (point->uw) {
1048  MEM_freeN(point->uw);
1049  }
1050 }
1051 
1053 {
1054  int i = 0;
1055 
1056  for (i = 0; i < spline->tot_point; i++) {
1058  point = &spline->points[i];
1060 
1061  if (spline->points_deform) {
1062  point = &spline->points_deform[i];
1064  }
1065  }
1066 
1067  MEM_freeN(spline->points);
1068 
1069  if (spline->points_deform) {
1070  MEM_freeN(spline->points_deform);
1071  }
1072 
1073  MEM_freeN(spline);
1074 }
1075 
1077 {
1078  MaskSpline *spline = splines->first;
1079  while (spline) {
1080  MaskSpline *next_spline = spline->next;
1081 
1082  BLI_remlink(splines, spline);
1083  BKE_mask_spline_free(spline);
1084 
1085  spline = next_spline;
1086  }
1087 }
1088 
1089 static MaskSplinePoint *mask_spline_points_copy(const MaskSplinePoint *points, int tot_point)
1090 {
1091  MaskSplinePoint *npoints = MEM_dupallocN(points);
1092 
1093  for (int i = 0; i < tot_point; i++) {
1094  MaskSplinePoint *point = &npoints[i];
1095 
1096  if (point->uw) {
1097  point->uw = MEM_dupallocN(point->uw);
1098  }
1099  }
1100 
1101  return npoints;
1102 }
1103 
1105 {
1106  MaskSpline *nspline = MEM_callocN(sizeof(MaskSpline), "new spline");
1107 
1108  *nspline = *spline;
1109 
1110  nspline->points_deform = NULL;
1111  nspline->points = mask_spline_points_copy(spline->points, spline->tot_point);
1112 
1113  if (spline->points_deform) {
1114  nspline->points_deform = mask_spline_points_copy(spline->points_deform, spline->tot_point);
1115  }
1116 
1117  return nspline;
1118 }
1119 
1121 {
1122  MaskLayerShape *masklay_shape;
1123  int tot_vert = BKE_mask_layer_shape_totvert(masklay);
1124 
1125  masklay_shape = MEM_mallocN(sizeof(MaskLayerShape), __func__);
1126  masklay_shape->frame = frame;
1127  masklay_shape->tot_vert = tot_vert;
1128  masklay_shape->data = MEM_mallocN(tot_vert * sizeof(float) * MASK_OBJECT_SHAPE_ELEM_SIZE,
1129  __func__);
1130 
1131  return masklay_shape;
1132 }
1133 
1135 {
1136  if (masklay_shape->data) {
1137  MEM_freeN(masklay_shape->data);
1138  }
1139 
1140  MEM_freeN(masklay_shape);
1141 }
1142 
1144 {
1145  MaskLayerShape *masklay_shape;
1146 
1147  /* free animation data */
1148  masklay_shape = masklay->splines_shapes.first;
1149  while (masklay_shape) {
1150  MaskLayerShape *next_masklay_shape = masklay_shape->next;
1151 
1152  BLI_remlink(&masklay->splines_shapes, masklay_shape);
1153  BKE_mask_layer_shape_free(masklay_shape);
1154 
1155  masklay_shape = next_masklay_shape;
1156  }
1157 }
1158 
1160 {
1161  /* free splines */
1163 
1164  /* free animation data */
1165  BKE_mask_layer_free_shapes(masklay);
1166 
1167  MEM_freeN(masklay);
1168 }
1169 
1171 {
1172  MaskLayer *masklay = masklayers->first;
1173 
1174  while (masklay) {
1175  MaskLayer *masklay_next = masklay->next;
1176 
1177  BLI_remlink(masklayers, masklay);
1178  BKE_mask_layer_free(masklay);
1179 
1180  masklay = masklay_next;
1181  }
1182 }
1183 
1184 void BKE_mask_coord_from_frame(float r_co[2], const float co[2], const float frame_size[2])
1185 {
1186  if (frame_size[0] == frame_size[1]) {
1187  r_co[0] = co[0];
1188  r_co[1] = co[1];
1189  }
1190  else if (frame_size[0] < frame_size[1]) {
1191  r_co[0] = ((co[0] - 0.5f) * (frame_size[0] / frame_size[1])) + 0.5f;
1192  r_co[1] = co[1];
1193  }
1194  else { /* (frame_size[0] > frame_size[1]) */
1195  r_co[0] = co[0];
1196  r_co[1] = ((co[1] - 0.5f) * (frame_size[1] / frame_size[0])) + 0.5f;
1197  }
1198 }
1199 
1201  MovieClipUser *user,
1202  float r_co[2],
1203  const float co[2])
1204 {
1205  float aspx, aspy;
1206  float frame_size[2];
1207 
1208  /* scaling for the clip */
1209  BKE_movieclip_get_size_fl(clip, user, frame_size);
1210  BKE_movieclip_get_aspect(clip, &aspx, &aspy);
1211 
1212  frame_size[1] *= (aspy / aspx);
1213 
1214  BKE_mask_coord_from_frame(r_co, co, frame_size);
1215 }
1216 
1217 void BKE_mask_coord_from_image(Image *image, ImageUser *iuser, float r_co[2], const float co[2])
1218 {
1219  float aspx, aspy;
1220  float frame_size[2];
1221 
1222  BKE_image_get_size_fl(image, iuser, frame_size);
1223  BKE_image_get_aspect(image, &aspx, &aspy);
1224 
1225  frame_size[1] *= (aspy / aspx);
1226 
1227  BKE_mask_coord_from_frame(r_co, co, frame_size);
1228 }
1229 
1230 void BKE_mask_coord_to_frame(float r_co[2], const float co[2], const float frame_size[2])
1231 {
1232  if (frame_size[0] == frame_size[1]) {
1233  r_co[0] = co[0];
1234  r_co[1] = co[1];
1235  }
1236  else if (frame_size[0] < frame_size[1]) {
1237  r_co[0] = ((co[0] - 0.5f) / (frame_size[0] / frame_size[1])) + 0.5f;
1238  r_co[1] = co[1];
1239  }
1240  else { /* (frame_size[0] > frame_size[1]) */
1241  r_co[0] = co[0];
1242  r_co[1] = ((co[1] - 0.5f) / (frame_size[1] / frame_size[0])) + 0.5f;
1243  }
1244 }
1245 
1247  MovieClipUser *user,
1248  float r_co[2],
1249  const float co[2])
1250 {
1251  float aspx, aspy;
1252  float frame_size[2];
1253 
1254  /* scaling for the clip */
1255  BKE_movieclip_get_size_fl(clip, user, frame_size);
1256  BKE_movieclip_get_aspect(clip, &aspx, &aspy);
1257 
1258  frame_size[1] *= (aspy / aspx);
1259 
1260  BKE_mask_coord_to_frame(r_co, co, frame_size);
1261 }
1262 
1263 void BKE_mask_coord_to_image(Image *image, ImageUser *iuser, float r_co[2], const float co[2])
1264 {
1265  float aspx, aspy;
1266  float frame_size[2];
1267 
1268  /* scaling for the clip */
1269  BKE_image_get_size_fl(image, iuser, frame_size);
1270  BKE_image_get_aspect(image, &aspx, &aspy);
1271 
1272  frame_size[1] *= (aspy / aspx);
1273 
1274  BKE_mask_coord_to_frame(r_co, co, frame_size);
1275 }
1276 
1278  float ctime,
1279  float parent_matrix[3][3])
1280 {
1281  MaskParent *parent = &point->parent;
1282 
1283  unit_m3(parent_matrix);
1284 
1285  if (!parent) {
1286  return;
1287  }
1288 
1289  if (parent->id_type == ID_MC) {
1290  if (parent->id) {
1291  MovieClip *clip = (MovieClip *)parent->id;
1292  MovieTracking *tracking = (MovieTracking *)&clip->tracking;
1293  MovieTrackingObject *ob = BKE_tracking_object_get_named(tracking, parent->parent);
1294 
1295  if (ob) {
1297  float clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, ctime);
1298  BKE_movieclip_user_set_frame(&user, ctime);
1299 
1300  if (parent->type == MASK_PARENT_POINT_TRACK) {
1302  tracking, ob, parent->sub_parent);
1303 
1304  if (track) {
1305  float marker_position[2], parent_co[2];
1306  BKE_tracking_marker_get_subframe_position(track, clip_framenr, marker_position);
1307  BKE_mask_coord_from_movieclip(clip, &user, parent_co, marker_position);
1308  sub_v2_v2v2(parent_matrix[2], parent_co, parent->parent_orig);
1309  }
1310  }
1311  else /* if (parent->type == MASK_PARENT_PLANE_TRACK) */ {
1313  tracking, ob, parent->sub_parent);
1314 
1315  if (plane_track) {
1316  float corners[4][2];
1317  float aspx, aspy;
1318  float frame_size[2], H[3][3], mask_from_clip_matrix[3][3], mask_to_clip_matrix[3][3];
1319 
1320  BKE_tracking_plane_marker_get_subframe_corners(plane_track, ctime, corners);
1322 
1323  unit_m3(mask_from_clip_matrix);
1324 
1325  BKE_movieclip_get_size_fl(clip, &user, frame_size);
1326  BKE_movieclip_get_aspect(clip, &aspx, &aspy);
1327 
1328  frame_size[1] *= (aspy / aspx);
1329  if (frame_size[0] == frame_size[1]) {
1330  /* pass */
1331  }
1332  else if (frame_size[0] < frame_size[1]) {
1333  mask_from_clip_matrix[0][0] = frame_size[1] / frame_size[0];
1334  mask_from_clip_matrix[2][0] = -0.5f * (frame_size[1] / frame_size[0]) + 0.5f;
1335  }
1336  else { /* (frame_size[0] > frame_size[1]) */
1337  mask_from_clip_matrix[1][1] = frame_size[1] / frame_size[0];
1338  mask_from_clip_matrix[2][1] = -0.5f * (frame_size[1] / frame_size[0]) + 0.5f;
1339  }
1340 
1341  invert_m3_m3(mask_to_clip_matrix, mask_from_clip_matrix);
1342  mul_m3_series(parent_matrix, mask_from_clip_matrix, H, mask_to_clip_matrix);
1343  }
1344  }
1345  }
1346  }
1347  }
1348 }
1349 
1351  MaskSplinePoint *point_prev,
1352  MaskSplinePoint *point_next)
1353 {
1354  BezTriple *bezt = &point->bezt;
1355  BezTriple *bezt_prev = NULL, *bezt_next = NULL;
1356  // int handle_type = bezt->h1;
1357 
1358  if (point_prev) {
1359  bezt_prev = &point_prev->bezt;
1360  }
1361 
1362  if (point_next) {
1363  bezt_next = &point_next->bezt;
1364  }
1365 
1366 #if 1
1367  if (bezt_prev || bezt_next) {
1368  BKE_nurb_handle_calc(bezt, bezt_prev, bezt_next, 0, 0);
1369  }
1370 #else
1371  if (handle_type == HD_VECT) {
1372  BKE_nurb_handle_calc(bezt, bezt_prev, bezt_next, 0, 0);
1373  }
1374  else if (handle_type == HD_AUTO) {
1375  BKE_nurb_handle_calc(bezt, bezt_prev, bezt_next, 0, 0);
1376  }
1377  else if (ELEM(handle_type, HD_ALIGN, HD_ALIGN_DOUBLESIDE)) {
1378  float v1[3], v2[3];
1379  float vec[3], h[3];
1380 
1381  sub_v3_v3v3(v1, bezt->vec[0], bezt->vec[1]);
1382  sub_v3_v3v3(v2, bezt->vec[2], bezt->vec[1]);
1383  add_v3_v3v3(vec, v1, v2);
1384 
1385  if (len_squared_v3(vec) > (1e-3f * 1e-3f)) {
1386  h[0] = vec[1];
1387  h[1] = -vec[0];
1388  h[2] = 0.0f;
1389  }
1390  else {
1391  copy_v3_v3(h, v1);
1392  }
1393 
1394  add_v3_v3v3(bezt->vec[0], bezt->vec[1], h);
1395  sub_v3_v3v3(bezt->vec[2], bezt->vec[1], h);
1396  }
1397 #endif
1398 }
1399 
1402  MaskSplinePoint **r_point_prev,
1403  MaskSplinePoint **r_point_next)
1404 {
1405  /* TODO: could avoid calling this at such low level. */
1407 
1408  *r_point_prev = mask_spline_point_prev(spline, points_array, point);
1409  *r_point_next = mask_spline_point_next(spline, points_array, point);
1410 }
1411 
1413 {
1414  float tvec_a[2], tvec_b[2];
1415 
1416  MaskSplinePoint *point_prev, *point_next;
1417 
1418  BKE_mask_get_handle_point_adjacent(spline, point, &point_prev, &point_next);
1419 
1420  if (point_prev) {
1421  sub_v2_v2v2(tvec_a, point->bezt.vec[1], point_prev->bezt.vec[1]);
1422  normalize_v2(tvec_a);
1423  }
1424  else {
1425  zero_v2(tvec_a);
1426  }
1427 
1428  if (point_next) {
1429  sub_v2_v2v2(tvec_b, point_next->bezt.vec[1], point->bezt.vec[1]);
1430  normalize_v2(tvec_b);
1431  }
1432  else {
1433  zero_v2(tvec_b);
1434  }
1435 
1436  add_v2_v2v2(t, tvec_a, tvec_b);
1437  normalize_v2(t);
1438 }
1439 
1441 {
1442  MaskSplinePoint *point_prev, *point_next;
1443 
1444  BKE_mask_get_handle_point_adjacent(spline, point, &point_prev, &point_next);
1445 
1446  mask_calc_point_handle(point, point_prev, point_next);
1447 }
1448 
1451  const float u)
1452 {
1453  /* TODO: make this interpolate between siblings - not always midpoint! */
1454  int length_tot = 0;
1455  float length_average = 0.0f;
1456  float weight_average = 0.0f;
1457 
1458  MaskSplinePoint *point_prev, *point_next;
1459 
1460  BLI_assert(u >= 0.0f && u <= 1.0f);
1461 
1462  BKE_mask_get_handle_point_adjacent(spline, point, &point_prev, &point_next);
1463 
1464  if (point_prev && point_next) {
1465  length_average = ((len_v2v2(point_prev->bezt.vec[0], point_prev->bezt.vec[1]) * (1.0f - u)) +
1466  (len_v2v2(point_next->bezt.vec[2], point_next->bezt.vec[1]) * u));
1467 
1468  weight_average = (point_prev->bezt.weight * (1.0f - u) + point_next->bezt.weight * u);
1469  length_tot = 1;
1470  }
1471  else {
1472  if (point_prev) {
1473  length_average += len_v2v2(point_prev->bezt.vec[0], point_prev->bezt.vec[1]);
1474  weight_average += point_prev->bezt.weight;
1475  length_tot++;
1476  }
1477 
1478  if (point_next) {
1479  length_average += len_v2v2(point_next->bezt.vec[2], point_next->bezt.vec[1]);
1480  weight_average += point_next->bezt.weight;
1481  length_tot++;
1482  }
1483  }
1484 
1485  if (length_tot) {
1486  length_average /= (float)length_tot;
1487  weight_average /= (float)length_tot;
1488 
1489  dist_ensure_v2_v2fl(point->bezt.vec[0], point->bezt.vec[1], length_average);
1490  dist_ensure_v2_v2fl(point->bezt.vec[2], point->bezt.vec[1], length_average);
1491  point->bezt.weight = weight_average;
1492  }
1493 }
1494 
1497  const bool do_recalc_length)
1498 {
1499  MaskSplinePoint *point_prev, *point_next;
1500  const char h_back[2] = {point->bezt.h1, point->bezt.h2};
1501  const float length_average = (do_recalc_length) ?
1502  0.0f /* dummy value */ :
1503  (len_v3v3(point->bezt.vec[0], point->bezt.vec[1]) +
1504  len_v3v3(point->bezt.vec[1], point->bezt.vec[2])) /
1505  2.0f;
1506 
1507  BKE_mask_get_handle_point_adjacent(spline, point, &point_prev, &point_next);
1508 
1509  point->bezt.h1 = HD_AUTO;
1510  point->bezt.h2 = HD_AUTO;
1511  mask_calc_point_handle(point, point_prev, point_next);
1512 
1513  point->bezt.h1 = h_back[0];
1514  point->bezt.h2 = h_back[1];
1515 
1516  /* preserve length by applying it back */
1517  if (do_recalc_length == false) {
1518  dist_ensure_v2_v2fl(point->bezt.vec[0], point->bezt.vec[1], length_average);
1519  dist_ensure_v2_v2fl(point->bezt.vec[2], point->bezt.vec[1], length_average);
1520  }
1521 }
1522 
1524 {
1525  MaskSpline *spline;
1526  for (spline = masklay->splines.first; spline; spline = spline->next) {
1527  for (int i = 0; i < spline->tot_point; i++) {
1528  BKE_mask_calc_handle_point(spline, &spline->points[i]);
1529  }
1530  }
1531 }
1532 
1534 {
1535  int allocated_points = (MEM_allocN_len(spline->points_deform) / sizeof(*spline->points_deform));
1536  // printf("SPLINE ALLOC %p %d\n", spline->points_deform, allocated_points);
1537 
1538  if (spline->points_deform == NULL || allocated_points != spline->tot_point) {
1539  // printf("alloc new deform spline\n");
1540 
1541  if (spline->points_deform) {
1542  for (int i = 0; i < allocated_points; i++) {
1543  MaskSplinePoint *point = &spline->points_deform[i];
1545  }
1546 
1547  MEM_freeN(spline->points_deform);
1548  }
1549 
1550  spline->points_deform = MEM_callocN(sizeof(*spline->points_deform) * spline->tot_point,
1551  __func__);
1552  }
1553  else {
1554  // printf("alloc spline done\n");
1555  }
1556 }
1557 
1558 void BKE_mask_layer_evaluate(MaskLayer *masklay, const float ctime, const bool do_newframe)
1559 {
1560  /* Animation if available. */
1561  if (do_newframe) {
1562  BKE_mask_layer_evaluate_animation(masklay, ctime);
1563  }
1564  /* Update deform. */
1565  BKE_mask_layer_evaluate_deform(masklay, ctime);
1566 }
1567 
1568 void BKE_mask_evaluate(Mask *mask, const float ctime, const bool do_newframe)
1569 {
1570  MaskLayer *masklay;
1571 
1572  for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
1573  BKE_mask_layer_evaluate(masklay, ctime, do_newframe);
1574  }
1575 }
1576 
1578 {
1579  parent->id_type = ID_MC;
1580 }
1581 
1582 /* *** own animation/shapekey implementation ***
1583  * BKE_mask_layer_shape_XXX */
1584 
1586 {
1587  int tot = 0;
1588  MaskSpline *spline;
1589 
1590  for (spline = masklay->splines.first; spline; spline = spline->next) {
1591  tot += spline->tot_point;
1592  }
1593 
1594  return tot;
1595 }
1596 
1598  float fp[MASK_OBJECT_SHAPE_ELEM_SIZE])
1599 {
1600  copy_v2_v2(&fp[0], bezt->vec[0]);
1601  copy_v2_v2(&fp[2], bezt->vec[1]);
1602  copy_v2_v2(&fp[4], bezt->vec[2]);
1603  fp[6] = bezt->weight;
1604  fp[7] = bezt->radius;
1605 }
1606 
1608  const float fp[MASK_OBJECT_SHAPE_ELEM_SIZE])
1609 {
1610  copy_v2_v2(bezt->vec[0], &fp[0]);
1611  copy_v2_v2(bezt->vec[1], &fp[2]);
1612  copy_v2_v2(bezt->vec[2], &fp[4]);
1613  bezt->weight = fp[6];
1614  bezt->radius = fp[7];
1615 }
1616 
1618 {
1619  int tot = BKE_mask_layer_shape_totvert(masklay);
1620 
1621  if (masklay_shape->tot_vert == tot) {
1622  float *fp = masklay_shape->data;
1623 
1624  MaskSpline *spline;
1625  for (spline = masklay->splines.first; spline; spline = spline->next) {
1626  for (int i = 0; i < spline->tot_point; i++) {
1627  mask_layer_shape_from_mask_point(&spline->points[i].bezt, fp);
1629  }
1630  }
1631  }
1632  else {
1633  CLOG_ERROR(&LOG,
1634  "vert mismatch %d != %d (frame %d)",
1635  masklay_shape->tot_vert,
1636  tot,
1637  masklay_shape->frame);
1638  }
1639 }
1640 
1642 {
1643  int tot = BKE_mask_layer_shape_totvert(masklay);
1644 
1645  if (masklay_shape->tot_vert == tot) {
1646  float *fp = masklay_shape->data;
1647 
1648  MaskSpline *spline;
1649  for (spline = masklay->splines.first; spline; spline = spline->next) {
1650  for (int i = 0; i < spline->tot_point; i++) {
1651  mask_layer_shape_to_mask_point(&spline->points[i].bezt, fp);
1653  }
1654  }
1655  }
1656  else {
1657  CLOG_ERROR(&LOG,
1658  "vert mismatch %d != %d (frame %d)",
1659  masklay_shape->tot_vert,
1660  tot,
1661  masklay_shape->frame);
1662  }
1663 }
1664 
1666  float target[2], const float a[2], const float b[2], const float t, const float s)
1667 {
1668  target[0] = s * a[0] + t * b[0];
1669  target[1] = s * a[1] + t * b[1];
1670 }
1671 
1673  MaskLayerShape *masklay_shape_a,
1674  MaskLayerShape *masklay_shape_b,
1675  const float fac)
1676 {
1677  int tot = BKE_mask_layer_shape_totvert(masklay);
1678  if (masklay_shape_a->tot_vert == tot && masklay_shape_b->tot_vert == tot) {
1679  const float *fp_a = masklay_shape_a->data;
1680  const float *fp_b = masklay_shape_b->data;
1681  const float ifac = 1.0f - fac;
1682 
1683  MaskSpline *spline;
1684  for (spline = masklay->splines.first; spline; spline = spline->next) {
1685  for (int i = 0; i < spline->tot_point; i++) {
1686  BezTriple *bezt = &spline->points[i].bezt;
1687  /* *** BKE_mask_layer_shape_from_mask - swapped *** */
1688  interp_v2_v2v2_flfl(bezt->vec[0], fp_a, fp_b, fac, ifac);
1689  fp_a += 2;
1690  fp_b += 2;
1691  interp_v2_v2v2_flfl(bezt->vec[1], fp_a, fp_b, fac, ifac);
1692  fp_a += 2;
1693  fp_b += 2;
1694  interp_v2_v2v2_flfl(bezt->vec[2], fp_a, fp_b, fac, ifac);
1695  fp_a += 2;
1696  fp_b += 2;
1697  bezt->weight = (fp_a[0] * ifac) + (fp_b[0] * fac);
1698  bezt->radius = (fp_a[1] * ifac) + (fp_b[1] * fac);
1699  fp_a += 2;
1700  fp_b += 2;
1701  }
1702  }
1703  }
1704  else {
1705  CLOG_ERROR(&LOG,
1706  "vert mismatch %d != %d != %d (frame %d - %d)",
1707  masklay_shape_a->tot_vert,
1708  masklay_shape_b->tot_vert,
1709  tot,
1710  masklay_shape_a->frame,
1711  masklay_shape_b->frame);
1712  }
1713 }
1714 
1716 {
1717  MaskLayerShape *masklay_shape;
1718 
1719  for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
1720  masklay_shape = masklay_shape->next) {
1721  if (frame == masklay_shape->frame) {
1722  return masklay_shape;
1723  }
1724  if (frame < masklay_shape->frame) {
1725  break;
1726  }
1727  }
1728 
1729  return NULL;
1730 }
1731 
1733  const float frame,
1734  MaskLayerShape **r_masklay_shape_a,
1735  MaskLayerShape **r_masklay_shape_b)
1736 {
1737  MaskLayerShape *masklay_shape;
1738 
1739  for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
1740  masklay_shape = masklay_shape->next) {
1741  if (frame == masklay_shape->frame) {
1742  *r_masklay_shape_a = masklay_shape;
1743  *r_masklay_shape_b = NULL;
1744  return 1;
1745  }
1746  if (frame < masklay_shape->frame) {
1747  if (masklay_shape->prev) {
1748  *r_masklay_shape_a = masklay_shape->prev;
1749  *r_masklay_shape_b = masklay_shape;
1750  return 2;
1751  }
1752 
1753  *r_masklay_shape_a = masklay_shape;
1754  *r_masklay_shape_b = NULL;
1755  return 1;
1756  }
1757  }
1758 
1759  if ((masklay_shape = masklay->splines_shapes.last)) {
1760  *r_masklay_shape_a = masklay_shape;
1761  *r_masklay_shape_b = NULL;
1762  return 1;
1763  }
1764 
1765  *r_masklay_shape_a = NULL;
1766  *r_masklay_shape_b = NULL;
1767 
1768  return 0;
1769 }
1770 
1772 {
1773  MaskLayerShape *masklay_shape;
1774 
1775  masklay_shape = BKE_mask_layer_shape_find_frame(masklay, frame);
1776 
1777  if (masklay_shape == NULL) {
1778  masklay_shape = BKE_mask_layer_shape_alloc(masklay, frame);
1779  BLI_addtail(&masklay->splines_shapes, masklay_shape);
1780  BKE_mask_layer_shape_sort(masklay);
1781  }
1782 
1783  return masklay_shape;
1784 }
1785 
1787 {
1788  MaskLayerShape *masklay_shape_copy;
1789 
1790  masklay_shape_copy = MEM_dupallocN(masklay_shape);
1791 
1792  if (LIKELY(masklay_shape_copy->data)) {
1793  masklay_shape_copy->data = MEM_dupallocN(masklay_shape_copy->data);
1794  }
1795 
1796  return masklay_shape_copy;
1797 }
1798 
1800 {
1801  BLI_remlink(&masklay->splines_shapes, masklay_shape);
1802 
1803  BKE_mask_layer_shape_free(masklay_shape);
1804 }
1805 
1806 static int mask_layer_shape_sort_cb(const void *masklay_shape_a_ptr,
1807  const void *masklay_shape_b_ptr)
1808 {
1809  const MaskLayerShape *masklay_shape_a = masklay_shape_a_ptr;
1810  const MaskLayerShape *masklay_shape_b = masklay_shape_b_ptr;
1811 
1812  if (masklay_shape_a->frame < masklay_shape_b->frame) {
1813  return -1;
1814  }
1815  if (masklay_shape_a->frame > masklay_shape_b->frame) {
1816  return 1;
1817  }
1818 
1819  return 0;
1820 }
1821 
1823 {
1825 }
1826 
1828  int index,
1829  MaskSpline **r_masklay_shape,
1830  int *r_index)
1831 {
1832  MaskSpline *spline;
1833 
1834  for (spline = masklay->splines.first; spline; spline = spline->next) {
1835  if (index < spline->tot_point) {
1836  *r_masklay_shape = spline;
1837  *r_index = index;
1838  return true;
1839  }
1840  index -= spline->tot_point;
1841  }
1842 
1843  return false;
1844 }
1845 
1847 {
1848  MaskSpline *spline_iter;
1849  int i_abs = 0;
1850  for (spline_iter = masklay->splines.first; spline_iter && spline_iter != spline;
1851  i_abs += spline_iter->tot_point, spline_iter = spline_iter->next) {
1852  /* pass */
1853  }
1854 
1855  return i_abs;
1856 }
1857 
1858 /* basic 2D interpolation functions, could make more comprehensive later */
1859 static void interp_weights_uv_v2_calc(float r_uv[2],
1860  const float pt[2],
1861  const float pt_a[2],
1862  const float pt_b[2])
1863 {
1864  const float segment_len = len_v2v2(pt_a, pt_b);
1865  if (segment_len == 0.0f) {
1866  r_uv[0] = 1.0f;
1867  r_uv[1] = 0.0f;
1868  return;
1869  }
1870 
1871  float pt_on_line[2];
1872  r_uv[0] = closest_to_line_v2(pt_on_line, pt, pt_a, pt_b);
1873 
1874  r_uv[1] = (len_v2v2(pt_on_line, pt) / segment_len) *
1875  /* This line only sets the sign. */
1876  ((line_point_side_v2(pt_a, pt_b, pt) < 0.0f) ? -1.0f : 1.0f);
1877 }
1878 
1879 static void interp_weights_uv_v2_apply(const float uv[2],
1880  float r_pt[2],
1881  const float pt_a[2],
1882  const float pt_b[2])
1883 {
1884  const float dvec[2] = {pt_b[0] - pt_a[0], pt_b[1] - pt_a[1]};
1885 
1886  /* u */
1887  madd_v2_v2v2fl(r_pt, pt_a, dvec, uv[0]);
1888 
1889  /* v */
1890  r_pt[0] += -dvec[1] * uv[1];
1891  r_pt[1] += dvec[0] * uv[1];
1892 }
1893 
1895  int index,
1896  bool do_init,
1897  bool do_init_interpolate)
1898 {
1899  MaskLayerShape *masklay_shape;
1900 
1901  /* spline index from masklay */
1902  MaskSpline *spline;
1903  int spline_point_index;
1904 
1905  if (BKE_mask_layer_shape_spline_from_index(masklay, index, &spline, &spline_point_index)) {
1906  /* sanity check */
1907  /* The point has already been removed in this array
1908  * so subtract one when comparing with the shapes. */
1909  int tot = BKE_mask_layer_shape_totvert(masklay) - 1;
1910 
1911  /* for interpolation */
1912  /* TODO: assumes closed curve for now. */
1913  float uv[3][2]; /* 3x 2D handles */
1914  const int pi_curr = spline_point_index;
1915  const int pi_prev = ((spline_point_index - 1) + spline->tot_point) % spline->tot_point;
1916  const int pi_next = (spline_point_index + 1) % spline->tot_point;
1917 
1918  const int index_offset = index - spline_point_index;
1919  /* const int pi_curr_abs = index; */
1920  const int pi_prev_abs = pi_prev + index_offset;
1921  const int pi_next_abs = pi_next + index_offset;
1922 
1923  if (do_init_interpolate) {
1924  for (int i = 0; i < 3; i++) {
1926  spline->points[pi_curr].bezt.vec[i],
1927  spline->points[pi_prev].bezt.vec[i],
1928  spline->points[pi_next].bezt.vec[i]);
1929  }
1930  }
1931 
1932  for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
1933  masklay_shape = masklay_shape->next) {
1934  if (tot == masklay_shape->tot_vert) {
1935  float *data_resized;
1936 
1937  masklay_shape->tot_vert++;
1938  data_resized = MEM_mallocN(
1939  masklay_shape->tot_vert * sizeof(float) * MASK_OBJECT_SHAPE_ELEM_SIZE, __func__);
1940  if (index > 0) {
1941  memcpy(data_resized,
1942  masklay_shape->data,
1943  index * sizeof(float) * MASK_OBJECT_SHAPE_ELEM_SIZE);
1944  }
1945 
1946  if (index != masklay_shape->tot_vert - 1) {
1947  memcpy(&data_resized[(index + 1) * MASK_OBJECT_SHAPE_ELEM_SIZE],
1948  masklay_shape->data + (index * MASK_OBJECT_SHAPE_ELEM_SIZE),
1949  (masklay_shape->tot_vert - (index + 1)) * sizeof(float) *
1951  }
1952 
1953  if (do_init) {
1954  float *fp = &data_resized[index * MASK_OBJECT_SHAPE_ELEM_SIZE];
1955 
1956  mask_layer_shape_from_mask_point(&spline->points[spline_point_index].bezt, fp);
1957 
1958  if (do_init_interpolate && spline->tot_point > 2) {
1959  for (int i = 0; i < 3; i++) {
1961  uv[i],
1962  &fp[i * 2],
1963  &data_resized[(pi_prev_abs * MASK_OBJECT_SHAPE_ELEM_SIZE) + (i * 2)],
1964  &data_resized[(pi_next_abs * MASK_OBJECT_SHAPE_ELEM_SIZE) + (i * 2)]);
1965  }
1966  }
1967  }
1968  else {
1969  memset(&data_resized[index * MASK_OBJECT_SHAPE_ELEM_SIZE],
1970  0,
1971  sizeof(float) * MASK_OBJECT_SHAPE_ELEM_SIZE);
1972  }
1973 
1974  MEM_freeN(masklay_shape->data);
1975  masklay_shape->data = data_resized;
1976  }
1977  else {
1978  CLOG_ERROR(&LOG,
1979  "vert mismatch %d != %d (frame %d)",
1980  masklay_shape->tot_vert,
1981  tot,
1982  masklay_shape->frame);
1983  }
1984  }
1985  }
1986 }
1987 
1989 {
1990  MaskLayerShape *masklay_shape;
1991 
1992  /* the point has already been removed in this array so add one when comparing with the shapes */
1993  int tot = BKE_mask_layer_shape_totvert(masklay);
1994 
1995  for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
1996  masklay_shape = masklay_shape->next) {
1997  if (tot == masklay_shape->tot_vert - count) {
1998  float *data_resized;
1999 
2000  masklay_shape->tot_vert -= count;
2001  data_resized = MEM_mallocN(
2002  masklay_shape->tot_vert * sizeof(float) * MASK_OBJECT_SHAPE_ELEM_SIZE, __func__);
2003  if (index > 0) {
2004  memcpy(data_resized,
2005  masklay_shape->data,
2006  index * sizeof(float) * MASK_OBJECT_SHAPE_ELEM_SIZE);
2007  }
2008 
2009  if (index != masklay_shape->tot_vert) {
2010  memcpy(&data_resized[index * MASK_OBJECT_SHAPE_ELEM_SIZE],
2011  masklay_shape->data + ((index + count) * MASK_OBJECT_SHAPE_ELEM_SIZE),
2012  (masklay_shape->tot_vert - index) * sizeof(float) * MASK_OBJECT_SHAPE_ELEM_SIZE);
2013  }
2014 
2015  MEM_freeN(masklay_shape->data);
2016  masklay_shape->data = data_resized;
2017  }
2018  else {
2019  CLOG_ERROR(&LOG,
2020  "vert mismatch %d != %d (frame %d)",
2021  masklay_shape->tot_vert - count,
2022  tot,
2023  masklay_shape->frame);
2024  }
2025  }
2026 }
2027 
2029 {
2030  return max_ii(1, mask->efra - mask->sfra);
2031 }
2032 
2033 /*********************** clipboard *************************/
2034 
2035 static void mask_clipboard_free_ex(bool final_free)
2036 {
2039  if (mask_clipboard.id_hash) {
2040  if (final_free) {
2042  }
2043  else {
2045  }
2046  }
2047 }
2048 
2050 {
2051  mask_clipboard_free_ex(true);
2052 }
2053 
2055 {
2056  MaskSpline *spline;
2057 
2058  /* Nothing to do if selection if disabled for the given layer. */
2059  if (mask_layer->visibility_flag & MASK_HIDE_SELECT) {
2060  return;
2061  }
2062 
2063  mask_clipboard_free_ex(false);
2064  if (mask_clipboard.id_hash == NULL) {
2065  mask_clipboard.id_hash = BLI_ghash_ptr_new("mask clipboard ID hash");
2066  }
2067 
2068  for (spline = mask_layer->splines.first; spline; spline = spline->next) {
2069  if (spline->flag & SELECT) {
2070  MaskSpline *spline_new = BKE_mask_spline_copy(spline);
2071  for (int i = 0; i < spline_new->tot_point; i++) {
2072  MaskSplinePoint *point = &spline_new->points[i];
2073  if (point->parent.id) {
2074  if (!BLI_ghash_lookup(mask_clipboard.id_hash, point->parent.id)) {
2075  int len = strlen(point->parent.id->name);
2076  char *name_copy = MEM_mallocN(len + 1, "mask clipboard ID name");
2077  strcpy(name_copy, point->parent.id->name);
2078  BLI_ghash_insert(mask_clipboard.id_hash, point->parent.id, name_copy);
2079  }
2080  }
2081  }
2082 
2083  BLI_addtail(&mask_clipboard.splines, spline_new);
2084  }
2085  }
2086 }
2087 
2089 {
2090  return BLI_listbase_is_empty(&mask_clipboard.splines);
2091 }
2092 
2094 {
2095  MaskSpline *spline;
2096 
2097  for (spline = mask_clipboard.splines.first; spline; spline = spline->next) {
2098  MaskSpline *spline_new = BKE_mask_spline_copy(spline);
2099 
2100  for (int i = 0; i < spline_new->tot_point; i++) {
2101  MaskSplinePoint *point = &spline_new->points[i];
2102  if (point->parent.id) {
2103  const char *id_name = BLI_ghash_lookup(mask_clipboard.id_hash, point->parent.id);
2104  ListBase *listbase;
2105 
2106  BLI_assert(id_name != NULL);
2107 
2108  listbase = which_libbase(bmain, GS(id_name));
2109  point->parent.id = BLI_findstring(listbase, id_name + 2, offsetof(ID, name) + 2);
2110  }
2111  }
2112 
2113  BLI_addtail(&mask_layer->splines, spline_new);
2114  }
2115 }
typedef float(TangentPoint)[2]
void BKE_animdata_blend_write(struct BlendWriter *writer, struct AnimData *adt)
Definition: anim_data.c:1421
void BKE_animdata_fix_paths_rename_all(struct ID *ref_id, const char *prefix, const char *oldName, const char *newName)
Definition: anim_data.c:1287
void BKE_nurb_handle_calc(struct BezTriple *bezt, struct BezTriple *prev, struct BezTriple *next, bool is_fcurve, char smoothing)
Definition: curve.cc:3978
@ IDTYPE_FLAGS_APPEND_IS_REUSABLE
Definition: BKE_idtype.h:39
void BKE_image_get_size_fl(struct Image *image, struct ImageUser *iuser, float r_size[2])
void BKE_image_get_aspect(struct Image *image, float *r_aspx, float *r_aspy)
void * BKE_libblock_alloc(struct Main *bmain, short type, const char *name, int flag) ATTR_WARN_UNUSED_RESULT
Definition: lib_id.c:1050
void id_fake_user_set(struct ID *id)
Definition: lib_id.c:343
void BKE_id_blend_write(struct BlendWriter *writer, struct ID *id)
Definition: lib_id.c:2008
@ IDWALK_CB_USER
Definition: BKE_lib_query.h:73
#define BKE_LIB_FOREACHID_PROCESS_ID(_data, _id, _cb_flag)
struct ListBase * which_libbase(struct Main *bmain, short type)
Definition: main.c:567
eMaskhandleMode
Definition: BKE_mask.h:39
@ MASK_HANDLE_MODE_INDIVIDUAL_HANDLES
Definition: BKE_mask.h:41
@ MASK_HANDLE_MODE_STICK
Definition: BKE_mask.h:40
void BKE_mask_layer_evaluate_deform(struct MaskLayer *masklay, float ctime)
eMaskWhichHandle
Definition: BKE_mask.h:31
@ MASK_WHICH_HANDLE_BOTH
Definition: BKE_mask.h:36
@ MASK_WHICH_HANDLE_RIGHT
Definition: BKE_mask.h:35
@ MASK_WHICH_HANDLE_LEFT
Definition: BKE_mask.h:34
@ MASK_WHICH_HANDLE_STICK
Definition: BKE_mask.h:33
#define MASKPOINT_SEL_ALL(p)
Definition: BKE_mask.h:305
eMaskSign
Definition: BKE_mask.h:94
@ MASK_PROJ_ANY
Definition: BKE_mask.h:96
@ MASK_PROJ_NEG
Definition: BKE_mask.h:95
@ MASK_PROJ_POS
Definition: BKE_mask.h:97
#define MASKPOINT_DESEL_ALL(p)
Definition: BKE_mask.h:312
void BKE_mask_layer_evaluate_animation(struct MaskLayer *masklay, float ctime)
void BKE_movieclip_get_aspect(struct MovieClip *clip, float *aspx, float *aspy)
Definition: movieclip.c:1588
float BKE_movieclip_remap_scene_to_clip_frame(const struct MovieClip *clip, float framenr)
void BKE_movieclip_user_set_frame(struct MovieClipUser *user, int framenr)
Definition: movieclip.c:1614
void BKE_movieclip_get_size_fl(struct MovieClip *clip, struct MovieClipUser *user, float size[2])
Definition: movieclip.c:1553
struct MovieTrackingTrack * BKE_tracking_track_get_named(struct MovieTracking *tracking, struct MovieTrackingObject *object, const char *name)
Definition: tracking.c:1038
struct MovieTrackingPlaneTrack * BKE_tracking_plane_track_get_named(struct MovieTracking *tracking, struct MovieTrackingObject *object, const char *name)
Definition: tracking.c:1703
struct MovieTrackingObject * BKE_tracking_object_get_named(struct MovieTracking *tracking, const char *name)
Definition: tracking.c:2077
void BKE_tracking_plane_marker_get_subframe_corners(struct MovieTrackingPlaneTrack *plane_track, float framenr, float corners[4][2])
Definition: tracking.c:1967
void BKE_tracking_marker_get_subframe_position(struct MovieTrackingTrack *track, float framenr, float pos[2])
Definition: tracking.c:1575
void BKE_tracking_homography_between_two_quads(float reference_corners[4][2], float corners[4][2], float H[3][3])
#define BLI_assert(a)
Definition: BLI_assert.h:46
#define BLI_assert_msg(a, msg)
Definition: BLI_assert.h:53
#define BLI_INLINE
void BLI_endian_switch_float_array(float *val, int size) ATTR_NONNULL(1)
Definition: endian_switch.c:51
void BLI_ghash_clear(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
Definition: BLI_ghash.c:858
void * BLI_ghash_lookup(const GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
Definition: BLI_ghash.c:734
void BLI_ghash_insert(GHash *gh, void *key, void *val)
Definition: BLI_ghash.c:710
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
Definition: BLI_ghash.c:863
GHash * BLI_ghash_ptr_new(const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
Definition: BLI_listbase.h:269
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:336
BLI_INLINE void BLI_listbase_clear(struct ListBase *lb)
Definition: BLI_listbase.h:273
bool BLI_remlink_safe(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:123
void void BLI_listbase_sort(struct ListBase *listbase, int(*cmp)(const void *, const void *)) ATTR_NONNULL(1
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:80
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:100
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_findstring(const struct ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE int max_ii(int a, int b)
#define M_PI_2
Definition: BLI_math_base.h:23
#define M_PI
Definition: BLI_math_base.h:20
float closest_to_line_v2(float r_close[2], const float p[2], const float l1[2], const float l2[2])
Definition: math_geom.c:3183
void unit_m3(float m[3][3])
Definition: math_matrix.c:40
bool invert_m3_m3(float R[3][3], const float A[3][3])
Definition: math_matrix.c:1180
#define mul_m3_series(...)
MINLINE float len_squared_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT
MINLINE float len_squared_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void madd_v2_v2v2fl(float r[2], const float a[2], const float b[2], float f)
float angle_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
Definition: math_vector.c:423
void interp_v2_v2v2v2v2_cubic(float p[2], const float v1[2], const float v2[2], const float v3[2], const float v4[2], float u)
Definition: math_vector.c:139
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void mul_v2_fl(float r[2], float f)
MINLINE void copy_v2_v2(float r[2], const float a[2])
void dist_ensure_v2_v2fl(float v1[2], const float v2[2], float dist)
Definition: math_vector.c:928
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void add_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE float line_point_side_v2(const float l1[2], const float l2[2], const float pt[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void zero_v2(float r[2])
MINLINE float dot_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
MINLINE float len_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
MINLINE float len_v2(const float a[2]) ATTR_WARN_UNUSED_RESULT
MINLINE float normalize_v2(float r[2])
void project_v2_v2v2(float out[2], const float p[2], const float v_proj[2])
Definition: math_vector.c:589
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
Definition: string.c:64
bool BLI_uniquename(struct ListBase *list, void *vlink, const char *defname, char delim, int name_offset, size_t name_len)
Definition: string_utils.c:309
#define SWAP(type, a, b)
#define UNUSED(x)
#define ELEM(...)
#define LIKELY(x)
#define BLO_read_data_address(reader, ptr_p)
#define BLO_write_id_struct(writer, struct_name, id_address, id)
#define BLO_write_struct(writer, struct_name, data_ptr)
void BLO_read_list(BlendDataReader *reader, struct ListBase *list)
Definition: readfile.c:5172
void BLO_write_float_array(BlendWriter *writer, uint num, const float *data_ptr)
Definition: writefile.c:1581
#define BLO_read_id_address(reader, lib, id_ptr_p)
#define BLO_write_struct_array(writer, struct_name, array_size, data_ptr)
#define BLO_expand(expander, id)
bool BLO_read_requires_endian_switch(BlendDataReader *reader)
Definition: readfile.c:5143
#define DATA_(msgid)
#define BLT_I18NCONTEXT_ID_MASK
#define CLOG_ERROR(clg_ref,...)
Definition: CLG_log.h:190
void DEG_relations_tag_update(struct Main *bmain)
@ INDEX_ID_MSK
Definition: DNA_ID.h:1006
#define MAX_ID_NAME
Definition: DNA_ID.h:337
#define FILTER_ID_MSK
Definition: DNA_ID.h:914
@ ID_MC
Definition: DNA_ID_enums.h:73
@ ID_MSK
Definition: DNA_ID_enums.h:74
@ HD_VECT
@ HD_AUTO
@ HD_ALIGN_DOUBLESIDE
@ HD_ALIGN
#define DNA_struct_default_get(struct_name)
Definition: DNA_defaults.h:29
#define MASK_HIDE_SELECT
struct Mask Mask
#define MASK_OBJECT_SHAPE_ELEM_SIZE
@ MASK_SPLINE_INTERP_EASE
@ MASK_LAYERFLAG_FILL_OVERLAP
@ MASK_LAYERFLAG_FILL_DISCRETE
@ MASK_SPLINE_CYCLIC
@ MASK_BLEND_MERGE_ADD
@ MASK_PARENT_POINT_TRACK
_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 GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble u2
_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 GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble u1
_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 GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble t
_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 GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble v1
Read Guarded memory(de)allocation.
#define MEM_reallocN(vmemh, len)
static void init_data(ModifierData *md)
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
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition: btQuadWord.h:119
std::string id_name(void *id)
#define SELECT
int len
Definition: draw_manager.c:108
depth_tx normal_tx diffuse_light_tx specular_light_tx volume_light_tx environment_tx ambient_occlusion_tx aov_value_tx in_weight_img image(1, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D_ARRAY, "out_weight_img") .image(3
int count
#define GS(x)
Definition: iris.c:225
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
void *(* MEM_dupallocN)(const void *vmemh)
Definition: mallocn.c:28
size_t(* MEM_allocN_len)(const void *vmemh)
Definition: mallocn.c:26
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:31
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:33
static void mask_blend_write(BlendWriter *writer, ID *id, const void *id_address)
Definition: mask.c:86
void BKE_mask_layer_shape_unlink(MaskLayer *masklay, MaskLayerShape *masklay_shape)
Definition: mask.c:1799
void BKE_mask_coord_from_movieclip(MovieClip *clip, MovieClipUser *user, float r_co[2], const float co[2])
Definition: mask.c:1200
void BKE_mask_calc_handle_point(MaskSpline *spline, MaskSplinePoint *point)
Definition: mask.c:1440
static MaskSplinePoint * mask_spline_point_next(MaskSpline *spline, MaskSplinePoint *points_array, MaskSplinePoint *point)
Definition: mask.c:269
void BKE_mask_layer_calc_handles(MaskLayer *masklay)
Definition: mask.c:1523
void BKE_mask_layer_shape_from_mask(MaskLayer *masklay, MaskLayerShape *masklay_shape)
Definition: mask.c:1617
MaskLayer * BKE_mask_layer_active(Mask *mask)
Definition: mask.c:361
float BKE_mask_point_weight(MaskSpline *spline, MaskSplinePoint *point, const float u)
Definition: mask.c:857
static void expand_mask_parent(BlendExpander *expander, MaskParent *parent)
Definition: mask.c:212
static void mask_layer_shape_to_mask_point(BezTriple *bezt, const float fp[MASK_OBJECT_SHAPE_ELEM_SIZE])
Definition: mask.c:1607
static int mask_layer_shape_sort_cb(const void *masklay_shape_a_ptr, const void *masklay_shape_b_ptr)
Definition: mask.c:1806
MaskSpline * BKE_mask_spline_copy(const MaskSpline *spline)
Definition: mask.c:1104
static void mask_copy_data(Main *UNUSED(bmain), ID *id_dst, const ID *id_src, const int UNUSED(flag))
Definition: mask.c:47
void BKE_mask_calc_handle_adjacent_interp(MaskSpline *spline, MaskSplinePoint *point, const float u)
Definition: mask.c:1449
Mask * BKE_mask_new(Main *bmain, const char *name)
Definition: mask.c:1022
static void lib_link_mask_parent(BlendLibReader *reader, Mask *mask, MaskParent *parent)
Definition: mask.c:186
BezTriple * BKE_mask_spline_point_next_bezt(MaskSpline *spline, MaskSplinePoint *points_array, MaskSplinePoint *point)
Definition: mask.c:299
static void mask_foreach_id(ID *id, LibraryForeachIDData *data)
Definition: mask.c:72
void BKE_mask_get_handle_point_adjacent(MaskSpline *spline, MaskSplinePoint *point, MaskSplinePoint **r_point_prev, MaskSplinePoint **r_point_next)
Definition: mask.c:1400
void BKE_mask_layer_unique_name(Mask *mask, MaskLayer *masklay)
Definition: mask.c:383
MaskSplinePoint * BKE_mask_spline_point_array(MaskSpline *spline)
Definition: mask.c:314
static MaskSplinePoint * mask_spline_point_prev(MaskSpline *spline, MaskSplinePoint *points_array, MaskSplinePoint *point)
Definition: mask.c:284
ListBase splines
Definition: mask.c:265
MaskLayerShape * BKE_mask_layer_shape_alloc(MaskLayer *masklay, const int frame)
Definition: mask.c:1120
void BKE_mask_layer_rename(Mask *mask, MaskLayer *masklay, char *oldname, char *newname)
Definition: mask.c:393
void BKE_mask_point_add_uw(MaskSplinePoint *point, float u, float w)
Definition: mask.c:937
void BKE_mask_clipboard_paste_to_layer(Main *bmain, MaskLayer *mask_layer)
Definition: mask.c:2093
BLI_INLINE void interp_v2_v2v2_flfl(float target[2], const float a[2], const float b[2], const float t, const float s)
Definition: mask.c:1665
void BKE_mask_point_normal(MaskSpline *spline, MaskSplinePoint *point, float u, float n[2])
Definition: mask.c:776
void BKE_mask_layer_shape_changed_remove(MaskLayer *masklay, int index, int count)
Definition: mask.c:1988
void BKE_mask_layer_free_list(ListBase *masklayers)
Definition: mask.c:1170
void BKE_mask_spline_direction_switch(MaskLayer *masklay, MaskSpline *spline)
Definition: mask.c:535
bool BKE_mask_spline_remove(MaskLayer *mask_layer, MaskSpline *spline)
Definition: mask.c:493
static void interp_weights_uv_v2_apply(const float uv[2], float r_pt[2], const float pt_a[2], const float pt_b[2])
Definition: mask.c:1879
void BKE_mask_point_select_set_handle(MaskSplinePoint *point, const eMaskWhichHandle which_handle, const bool do_select)
Definition: mask.c:974
int BKE_mask_layer_shape_find_frame_range(MaskLayer *masklay, const float frame, MaskLayerShape **r_masklay_shape_a, MaskLayerShape **r_masklay_shape_b)
Definition: mask.c:1732
MaskSpline * BKE_mask_spline_add(MaskLayer *masklay)
Definition: mask.c:469
void BKE_mask_layer_shape_sort(MaskLayer *masklay)
Definition: mask.c:1822
void BKE_mask_point_select_set(MaskSplinePoint *point, const bool do_select)
Definition: mask.c:955
void BKE_mask_parent_init(MaskParent *parent)
Definition: mask.c:1577
eMaskhandleMode BKE_mask_point_handles_mode_get(const MaskSplinePoint *point)
Definition: mask.c:663
void BKE_mask_point_handle(const MaskSplinePoint *point, eMaskWhichHandle which_handle, float r_handle[2])
Definition: mask.c:674
MaskSplinePointUW * BKE_mask_point_sort_uw(MaskSplinePoint *point, MaskSplinePointUW *uw)
Definition: mask.c:912
static void mask_blend_read_data(BlendDataReader *reader, ID *id)
Definition: mask.c:134
MaskLayerShape * BKE_mask_layer_shape_verify_frame(MaskLayer *masklay, const int frame)
Definition: mask.c:1771
void BKE_mask_layer_copy_list(ListBase *masklayers_new, const ListBase *masklayers)
Definition: mask.c:456
struct GHash * id_hash
Definition: mask.c:266
void BKE_mask_layer_shape_to_mask_interp(MaskLayer *masklay, MaskLayerShape *masklay_shape_a, MaskLayerShape *masklay_shape_b, const float fac)
Definition: mask.c:1672
void BKE_mask_point_segment_co(MaskSpline *spline, MaskSplinePoint *point, float u, float co[2])
Definition: mask.c:752
void BKE_mask_coord_to_image(Image *image, ImageUser *iuser, float r_co[2], const float co[2])
Definition: mask.c:1263
bool BKE_mask_layer_shape_spline_from_index(MaskLayer *masklay, int index, MaskSpline **r_masklay_shape, int *r_index)
Definition: mask.c:1827
void BKE_mask_point_set_handle(MaskSplinePoint *point, eMaskWhichHandle which_handle, float loc[2], bool keep_direction, float orig_handle[2], float orig_vec[3][3])
Definition: mask.c:699
void BKE_mask_point_parent_matrix_get(MaskSplinePoint *point, float ctime, float parent_matrix[3][3])
Definition: mask.c:1277
static void mask_layer_shape_from_mask_point(BezTriple *bezt, float fp[MASK_OBJECT_SHAPE_ELEM_SIZE])
Definition: mask.c:1597
float BKE_mask_point_weight_scalar(MaskSpline *spline, MaskSplinePoint *point, const float u)
Definition: mask.c:837
void BKE_mask_coord_to_frame(float r_co[2], const float co[2], const float frame_size[2])
Definition: mask.c:1230
MaskLayerShape * BKE_mask_layer_shape_duplicate(MaskLayerShape *masklay_shape)
Definition: mask.c:1786
void BKE_mask_layer_free(MaskLayer *masklay)
Definition: mask.c:1159
void BKE_mask_coord_to_movieclip(MovieClip *clip, MovieClipUser *user, float r_co[2], const float co[2])
Definition: mask.c:1246
MaskSplinePoint * BKE_mask_spline_point_array_from_point(MaskSpline *spline, const MaskSplinePoint *point_ref)
Definition: mask.c:319
void BKE_mask_layer_shape_to_mask(MaskLayer *masklay, MaskLayerShape *masklay_shape)
Definition: mask.c:1641
float BKE_mask_spline_project_co(MaskSpline *spline, MaskSplinePoint *point, float start_u, const float co[2], const eMaskSign sign)
Definition: mask.c:583
static float mask_point_interp_weight(BezTriple *bezt, BezTriple *bezt_next, const float u)
Definition: mask.c:832
void BKE_mask_coord_from_image(Image *image, ImageUser *iuser, float r_co[2], const float co[2])
Definition: mask.c:1217
void BKE_mask_layer_remove(Mask *mask, MaskLayer *masklay)
Definition: mask.c:371
int BKE_mask_layer_shape_totvert(MaskLayer *masklay)
Definition: mask.c:1585
static void mask_free_data(ID *id)
Definition: mask.c:64
BLI_INLINE void orthogonal_direction_get(const float vec[2], float result[2])
Definition: mask.c:769
void BKE_mask_layer_shape_free(MaskLayerShape *masklay_shape)
Definition: mask.c:1134
static void mask_blend_read_expand(BlendExpander *expander, ID *id)
Definition: mask.c:219
void BKE_mask_spline_ensure_deform(MaskSpline *spline)
Definition: mask.c:1533
void BKE_mask_spline_free(MaskSpline *spline)
Definition: mask.c:1052
void BKE_mask_layer_free_shapes(MaskLayer *masklay)
Free all animation keys for a mask layer.
Definition: mask.c:1143
int BKE_mask_layer_shape_spline_to_index(MaskLayer *masklay, MaskSpline *spline)
Definition: mask.c:1846
static CLG_LogRef LOG
Definition: mask.c:45
static void mask_calc_point_handle(MaskSplinePoint *point, MaskSplinePoint *point_prev, MaskSplinePoint *point_next)
Definition: mask.c:1350
int BKE_mask_get_duration(Mask *mask)
Definition: mask.c:2028
static void mask_clipboard_free_ex(bool final_free)
Definition: mask.c:2035
void BKE_mask_point_free(MaskSplinePoint *point)
Definition: mask.c:1045
IDTypeInfo IDType_ID_MSK
Definition: mask.c:234
void BKE_mask_layer_evaluate(MaskLayer *masklay, const float ctime, const bool do_newframe)
Definition: mask.c:1558
void BKE_mask_clipboard_free(void)
Definition: mask.c:2049
void BKE_mask_layer_active_set(Mask *mask, MaskLayer *masklay)
Definition: mask.c:366
static void mask_blend_read_lib(BlendLibReader *reader, ID *id)
Definition: mask.c:191
void BKE_mask_point_direction_switch(MaskSplinePoint *point)
Definition: mask.c:504
void BKE_mask_clipboard_copy_from_layer(MaskLayer *mask_layer)
Definition: mask.c:2054
static struct @94 mask_clipboard
void BKE_mask_spline_free_list(ListBase *splines)
Definition: mask.c:1076
bool BKE_mask_clipboard_is_empty(void)
Definition: mask.c:2088
static MaskSplinePoint * mask_spline_points_copy(const MaskSplinePoint *points, int tot_point)
Definition: mask.c:1089
static Mask * mask_alloc(Main *bmain, const char *name)
Definition: mask.c:1011
MaskLayer * BKE_mask_layer_copy(const MaskLayer *masklay)
Definition: mask.c:403
static void interp_weights_uv_v2_calc(float r_uv[2], const float pt[2], const float pt_a[2], const float pt_b[2])
Definition: mask.c:1859
MaskLayerShape * BKE_mask_layer_shape_find_frame(MaskLayer *masklay, const int frame)
Definition: mask.c:1715
void BKE_mask_coord_from_frame(float r_co[2], const float co[2], const float frame_size[2])
Definition: mask.c:1184
void BKE_mask_calc_tangent_polyline(MaskSpline *spline, MaskSplinePoint *point, float t[2])
Definition: mask.c:1412
void BKE_mask_layer_shape_changed_add(MaskLayer *masklay, int index, bool do_init, bool do_init_interpolate)
Definition: mask.c:1894
void BKE_mask_evaluate(Mask *mask, const float ctime, const bool do_newframe)
Definition: mask.c:1568
void BKE_mask_calc_handle_point_auto(MaskSpline *spline, MaskSplinePoint *point, const bool do_recalc_length)
Resets auto handles even for non-auto bezier points.
Definition: mask.c:1495
MaskLayer * BKE_mask_layer_new(Mask *mask, const char *name)
Definition: mask.c:337
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
Definition: math_float4.h:513
#define N
#define H(x, y, z)
static unsigned a[3]
Definition: RandGen.cpp:78
double sign(double arg)
Definition: utility.h:250
T abs(const T &a)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
unsigned char uint8_t
Definition: stdint.h:78
uint8_t h1
float vec[3][3]
uint8_t h2
short id_code
Definition: BKE_idtype.h:114
Definition: DNA_ID.h:368
void * last
Definition: DNA_listBase.h:31
void * first
Definition: DNA_listBase.h:31
Definition: BKE_main.h:121
struct MaskLayerShape * prev
struct MaskLayerShape * next
struct MaskLayer * next
ListBase splines_shapes
char visibility_flag
ListBase splines
struct MaskSplinePoint * act_point
char name[64]
struct MaskSpline * act_spline
char parent[64]
float parent_orig[2]
float parent_corners_orig[4][2]
char sub_parent[64]
MaskSplinePointUW * uw
MaskParent parent
MaskSplinePoint * points_deform
char weight_interp
struct MaskSpline * next
MaskSplinePoint * points
ListBase masklayers
struct MovieTracking tracking