Blender  V2.93
tracking_ops.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2011 Blender Foundation.
17  * All rights reserved.
18  */
19 
24 #include "MEM_guardedalloc.h"
25 
26 #include "DNA_screen_types.h"
27 #include "DNA_space_types.h"
28 
29 #include "BLI_blenlib.h"
30 #include "BLI_ghash.h"
31 #include "BLI_math.h"
32 #include "BLI_utildefines.h"
33 
34 #include "BKE_context.h"
35 #include "BKE_movieclip.h"
36 #include "BKE_report.h"
37 #include "BKE_tracking.h"
38 
39 #include "DEG_depsgraph.h"
40 
41 #include "WM_api.h"
42 #include "WM_types.h"
43 
44 #include "ED_clip.h"
45 #include "ED_screen.h"
46 
47 #include "RNA_access.h"
48 #include "RNA_define.h"
49 
50 #include "BLT_translation.h"
51 
52 #include "clip_intern.h"
53 #include "tracking_ops_intern.h"
54 
55 /********************** add marker operator *********************/
56 
57 static bool add_marker(const bContext *C, float x, float y)
58 {
61  MovieTracking *tracking = &clip->tracking;
62  ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
63  ListBase *plane_tracks_base = BKE_tracking_get_active_plane_tracks(tracking);
64  MovieTrackingTrack *track;
65  int width, height;
66  int framenr = ED_space_clip_get_clip_frame_number(sc);
67 
69 
70  if (width == 0 || height == 0) {
71  return false;
72  }
73 
74  track = BKE_tracking_track_add(tracking, tracksbase, x, y, framenr, width, height);
75 
76  BKE_tracking_track_select(tracksbase, track, TRACK_AREA_ALL, 0);
77  BKE_tracking_plane_tracks_deselect_all(plane_tracks_base);
78 
79  clip->tracking.act_track = track;
81 
82  return true;
83 }
84 
86 {
89  float pos[2];
90 
91  ClipViewLockState lock_state;
92  ED_clip_view_lock_state_store(C, &lock_state);
93 
94  RNA_float_get_array(op->ptr, "location", pos);
95 
96  if (!add_marker(C, pos[0], pos[1])) {
97  return OPERATOR_CANCELLED;
98  }
99 
101 
103 
104  return OPERATOR_FINISHED;
105 }
106 
107 static int add_marker_invoke(bContext *C, wmOperator *op, const wmEvent *event)
108 {
110  ARegion *region = CTX_wm_region(C);
111 
112  if (!RNA_struct_property_is_set(op->ptr, "location")) {
113  /* If location is not set, use mouse position as default. */
114  float co[2];
115  ED_clip_mouse_pos(sc, region, event->mval, co);
116  RNA_float_set_array(op->ptr, "location", co);
117  }
118 
119  return add_marker_exec(C, op);
120 }
121 
123 {
124  /* identifiers */
125  ot->name = "Add Marker";
126  ot->idname = "CLIP_OT_add_marker";
127  ot->description = "Place new marker at specified location";
128 
129  /* api callbacks */
133 
134  /* flags */
136 
137  /* properties */
139  "location",
140  2,
141  NULL,
142  -FLT_MAX,
143  FLT_MAX,
144  "Location",
145  "Location of marker on frame",
146  -1.0f,
147  1.0f);
148 }
149 
150 /********************** add marker operator *********************/
151 
153 {
154  ED_workspace_status_text(C, TIP_("Use LMB click to define location where place the marker"));
155 
156  /* Add modal handler for ESC. */
158 
159  return OPERATOR_RUNNING_MODAL;
160 }
161 
163 {
164  switch (event->type) {
165  case MOUSEMOVE:
166  return OPERATOR_RUNNING_MODAL;
167 
168  case LEFTMOUSE: {
170  MovieClip *clip = ED_space_clip_get_clip(sc);
171  ARegion *region = CTX_wm_region(C);
172  float pos[2];
173 
175 
177  region,
178  event->x - region->winrct.xmin,
179  event->y - region->winrct.ymin,
180  &pos[0],
181  &pos[1]);
182 
183  if (!add_marker(C, pos[0], pos[1])) {
184  return OPERATOR_CANCELLED;
185  }
186 
188  return OPERATOR_FINISHED;
189  }
190 
191  case EVT_ESCKEY:
193  return OPERATOR_CANCELLED;
194  }
195 
196  return OPERATOR_PASS_THROUGH;
197 }
198 
200 {
201  /* identifiers */
202  ot->name = "Add Marker at Click";
203  ot->idname = "CLIP_OT_add_marker_at_click";
204  ot->description = "Place new marker at the desired (clicked) position";
205 
206  /* api callbacks */
210 
211  /* flags */
213 }
214 
215 /********************** delete track operator *********************/
216 
218 {
220  MovieClip *clip = ED_space_clip_get_clip(sc);
221  MovieTracking *tracking = &clip->tracking;
222  bool changed = false;
223  /* Delete selected plane tracks. */
224  ListBase *plane_tracks_base = BKE_tracking_get_active_plane_tracks(tracking);
225  for (MovieTrackingPlaneTrack *plane_track = plane_tracks_base->first, *next_plane_track;
226  plane_track != NULL;
227  plane_track = next_plane_track) {
228  next_plane_track = plane_track->next;
229  if (PLANE_TRACK_VIEW_SELECTED(plane_track)) {
230  clip_delete_plane_track(C, clip, plane_track);
231  changed = true;
232  }
233  }
234  /* Remove selected point tracks (they'll also be removed from planes which
235  * uses them).
236  */
237  ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
238  for (MovieTrackingTrack *track = tracksbase->first, *next_track; track != NULL;
239  track = next_track) {
240  next_track = track->next;
241  if (TRACK_VIEW_SELECTED(sc, track)) {
242  clip_delete_track(C, clip, track);
243  changed = true;
244  }
245  }
246  if (changed) {
248  }
249  return OPERATOR_FINISHED;
250 }
251 
253 {
254  /* identifiers */
255  ot->name = "Delete Track";
256  ot->idname = "CLIP_OT_delete_track";
257  ot->description = "Delete selected tracks";
258 
259  /* api callbacks */
263 
264  /* flags */
266 }
267 
268 /********************** delete marker operator *********************/
269 
271 {
273  MovieClip *clip = ED_space_clip_get_clip(sc);
274  MovieTracking *tracking = &clip->tracking;
275  const int framenr = ED_space_clip_get_clip_frame_number(sc);
276  bool has_selection = false;
277  bool changed = false;
278 
279  ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
280  for (MovieTrackingTrack *track = tracksbase->first, *next_track; track != NULL;
281  track = next_track) {
282  next_track = track->next;
283  if (TRACK_VIEW_SELECTED(sc, track)) {
284  MovieTrackingMarker *marker = BKE_tracking_marker_get_exact(track, framenr);
285  if (marker != NULL) {
286  has_selection |= track->markersnr > 1;
287  clip_delete_marker(C, clip, track, marker);
288  changed = true;
289  }
290  }
291  }
292 
293  ListBase *plane_tracks_base = BKE_tracking_get_active_plane_tracks(tracking);
294  for (MovieTrackingPlaneTrack *plane_track = plane_tracks_base->first, *plane_track_next;
295  plane_track != NULL;
296  plane_track = plane_track_next) {
297  plane_track_next = plane_track->next;
298  if (PLANE_TRACK_VIEW_SELECTED(plane_track)) {
300  framenr);
301  if (plane_marker != NULL) {
302  if (plane_track->markersnr == 1) {
303  BKE_tracking_plane_track_free(plane_track);
304  BLI_freelinkN(plane_tracks_base, plane_track);
305  }
306  else {
307  BKE_tracking_plane_marker_delete(plane_track, framenr);
308  }
309  changed = true;
310  }
311  }
312  }
313 
314  if (!changed) {
315  return OPERATOR_CANCELLED;
316  }
317 
318  return OPERATOR_FINISHED;
319 }
320 
322 {
323  /* identifiers */
324  ot->name = "Delete Marker";
325  ot->idname = "CLIP_OT_delete_marker";
326  ot->description = "Delete marker for current frame from selected tracks";
327 
328  /* api callbacks */
332 
333  /* flags */
335 }
336 
337 /********************** slide marker operator *********************/
338 
339 enum {
344 };
345 
346 typedef struct {
347  short area, action;
350 
351  int mval[2];
352  int width, height;
353  float *min, *max, *pos, *offset, (*corners)[2];
354  float spos[2];
355 
356  bool lock, accurate;
357 
358  /* Data to restore on cancel. */
359  float old_search_min[2], old_search_max[2], old_pos[2], old_offset[2];
360  float old_corners[4][2];
361  float (*old_markers)[2];
363 
364 static void slide_marker_tilt_slider(const MovieTrackingMarker *marker, float r_slider[2])
365 {
366  add_v2_v2v2(r_slider, marker->pattern_corners[1], marker->pattern_corners[2]);
367  add_v2_v2(r_slider, marker->pos);
368 }
369 
371  MovieTrackingTrack *track,
372  MovieTrackingMarker *marker,
373  const wmEvent *event,
374  int area,
375  int corner,
376  int action,
377  int width,
378  int height)
379 {
380  SlideMarkerData *data = MEM_callocN(sizeof(SlideMarkerData), "slide marker data");
381  int framenr = ED_space_clip_get_clip_frame_number(sc);
382 
383  marker = BKE_tracking_marker_ensure(track, framenr);
384 
385  data->area = area;
386  data->action = action;
387  data->track = track;
388  data->marker = marker;
389 
390  if (area == TRACK_AREA_POINT) {
391  data->pos = marker->pos;
392  data->offset = track->offset;
393  }
394  else if (area == TRACK_AREA_PAT) {
395  if (action == SLIDE_ACTION_SIZE) {
396  data->corners = marker->pattern_corners;
397  }
398  else if (action == SLIDE_ACTION_OFFSET) {
399  data->pos = marker->pos;
400  data->offset = track->offset;
401  data->old_markers = MEM_callocN(sizeof(*data->old_markers) * track->markersnr,
402  "slide marekrs");
403  for (int a = 0; a < track->markersnr; a++) {
404  copy_v2_v2(data->old_markers[a], track->markers[a].pos);
405  }
406  }
407  else if (action == SLIDE_ACTION_POS) {
408  data->corners = marker->pattern_corners;
409  data->pos = marker->pattern_corners[corner];
410  copy_v2_v2(data->spos, data->pos);
411  }
412  else if (action == SLIDE_ACTION_TILT_SIZE) {
413  data->corners = marker->pattern_corners;
414  slide_marker_tilt_slider(marker, data->spos);
415  }
416  }
417  else if (area == TRACK_AREA_SEARCH) {
418  data->min = marker->search_min;
419  data->max = marker->search_max;
420  }
421 
422  data->mval[0] = event->mval[0];
423  data->mval[1] = event->mval[1];
424 
425  data->width = width;
426  data->height = height;
427 
428  if (action == SLIDE_ACTION_SIZE) {
429  data->lock = true;
430  }
431 
432  /* Backup marker's settings. */
433  memcpy(data->old_corners, marker->pattern_corners, sizeof(data->old_corners));
434  copy_v2_v2(data->old_search_min, marker->search_min);
435  copy_v2_v2(data->old_search_max, marker->search_max);
436  copy_v2_v2(data->old_pos, marker->pos);
437  copy_v2_v2(data->old_offset, track->offset);
438 
439  return data;
440 }
441 
442 static float mouse_to_slide_zone_distance_squared(const float co[2],
443  const float slide_zone[2],
444  int width,
445  int height)
446 {
447  const float pixel_co[2] = {co[0] * width, co[1] * height},
448  pixel_slide_zone[2] = {slide_zone[0] * width, slide_zone[1] * height};
449  return square_f(pixel_co[0] - pixel_slide_zone[0]) + square_f(pixel_co[1] - pixel_slide_zone[1]);
450 }
451 
453  const MovieTrackingMarker *marker, const float co[2], int corner, int width, int height)
454 {
455  float side_zone[2];
456  if (corner == 0) {
457  side_zone[0] = marker->pos[0] + marker->search_max[0];
458  side_zone[1] = marker->pos[1] + marker->search_min[1];
459  }
460  else {
461  side_zone[0] = marker->pos[0] + marker->search_min[0];
462  side_zone[1] = marker->pos[1] + marker->search_max[1];
463  }
464  return mouse_to_slide_zone_distance_squared(co, side_zone, width, height);
465 }
466 
468  const MovieTrackingMarker *marker, const float co[2], int width, int height, int *r_corner)
469 {
470  float min_distance_squared = FLT_MAX;
471  for (int i = 0; i < 4; i++) {
472  float corner_co[2];
473  add_v2_v2v2(corner_co, marker->pattern_corners[i], marker->pos);
474  float distance_squared = mouse_to_slide_zone_distance_squared(co, corner_co, width, height);
475  if (distance_squared < min_distance_squared) {
476  min_distance_squared = distance_squared;
477  *r_corner = i;
478  }
479  }
480  return min_distance_squared;
481 }
482 
484  const MovieTrackingMarker *marker,
485  const float co[2],
486  int width,
487  int height)
488 {
489  float pos[2];
490  add_v2_v2v2(pos, marker->pos, track->offset);
492 }
493 
495  const float co[2],
496  int width,
497  int height)
498 {
499  float slider[2];
500  slide_marker_tilt_slider(marker, slider);
502 }
503 
504 static bool slide_check_corners(float (*corners)[2])
505 {
506  float cross = 0.0f;
507  const float p[2] = {0.0f, 0.0f};
508 
509  if (!isect_point_quad_v2(p, corners[0], corners[1], corners[2], corners[3])) {
510  return false;
511  }
512 
513  for (int i = 0; i < 4; i++) {
514  float v1[2], v2[2];
515 
516  int next = (i + 1) % 4;
517  int prev = (4 + i - 1) % 4;
518 
519  sub_v2_v2v2(v1, corners[i], corners[prev]);
520  sub_v2_v2v2(v2, corners[next], corners[i]);
521 
522  float cur_cross = cross_v2v2(v1, v2);
523 
524  if (fabsf(cur_cross) > FLT_EPSILON) {
525  if (cross == 0.0f) {
526  cross = cur_cross;
527  }
528  else if (cross * cur_cross < 0.0f) {
529  return false;
530  }
531  }
532  }
533 
534  return true;
535 }
536 
538  bContext *C, const wmEvent *event, int *r_area, int *r_action, int *r_corner)
539 {
540  const float distance_clip_squared = 12.0f * 12.0f;
542  ARegion *region = CTX_wm_region(C);
543 
544  MovieClip *clip = ED_space_clip_get_clip(sc);
545  MovieTrackingTrack *track;
546  int width, height;
547  float co[2];
548  ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking);
549  int framenr = ED_space_clip_get_clip_frame_number(sc);
550  float global_min_distance_squared = FLT_MAX;
551 
552  /* Sliding zone designator which is the closest to the mouse
553  * across all the tracks.
554  */
555  int min_action = -1, min_area = 0, min_corner = -1;
556  MovieTrackingTrack *min_track = NULL;
557 
559 
560  if (width == 0 || height == 0) {
561  return NULL;
562  }
563 
564  ED_clip_mouse_pos(sc, region, event->mval, co);
565 
566  track = tracksbase->first;
567  while (track) {
568  if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED) == 0) {
569  const MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
570  /* Sliding zone designator which is the closest to the mouse for
571  * the current tracks.
572  */
573  float min_distance_squared = FLT_MAX;
574  int action = -1, area = 0, corner = -1;
575 
576  if ((marker->flag & MARKER_DISABLED) == 0) {
577  float distance_squared;
578 
579  /* We start checking with whether the mouse is close enough
580  * to the pattern offset area.
581  */
582  distance_squared = mouse_to_offset_distance_squared(track, marker, co, width, height);
584  action = SLIDE_ACTION_POS;
585 
586  /* NOTE: All checks here are assuming there's no maximum distance
587  * limit, so checks are quite simple here.
588  * Actual distance clipping happens later once all the sliding
589  * zones are checked.
590  */
591  min_distance_squared = distance_squared;
592 
593  /* If search area is visible, check how close to its sliding
594  * zones mouse is.
595  */
596  if (sc->flag & SC_SHOW_MARKER_SEARCH) {
597  distance_squared = mouse_to_search_corner_distance_squared(marker, co, 1, width, height);
598  if (distance_squared < min_distance_squared) {
600  action = SLIDE_ACTION_OFFSET;
601  min_distance_squared = distance_squared;
602  }
603 
604  distance_squared = mouse_to_search_corner_distance_squared(marker, co, 0, width, height);
605  if (distance_squared < min_distance_squared) {
607  action = SLIDE_ACTION_SIZE;
608  min_distance_squared = distance_squared;
609  }
610  }
611 
612  /* If pattern area is visible, check which corner is closest to
613  * the mouse.
614  */
615  if (sc->flag & SC_SHOW_MARKER_PATTERN) {
616  int current_corner = -1;
618  marker, co, width, height, &current_corner);
619  if (distance_squared < min_distance_squared) {
621  action = SLIDE_ACTION_POS;
622  corner = current_corner;
623  min_distance_squared = distance_squared;
624  }
625 
626  /* Here we also check whether the mouse is actually closer to
627  * the widget which controls scale and tilt.
628  */
629  distance_squared = mouse_to_tilt_distance_squared(marker, co, width, height);
630  if (distance_squared < min_distance_squared) {
632  action = SLIDE_ACTION_TILT_SIZE;
633  min_distance_squared = distance_squared;
634  }
635  }
636 
637  if (min_distance_squared < global_min_distance_squared) {
638  min_area = area;
639  min_action = action;
640  min_corner = corner;
641  min_track = track;
642  global_min_distance_squared = min_distance_squared;
643  }
644  }
645  }
646 
647  track = track->next;
648  }
649 
650  if (global_min_distance_squared < distance_clip_squared / sc->zoom) {
651  if (r_area) {
652  *r_area = min_area;
653  }
654  if (r_action) {
655  *r_action = min_action;
656  }
657  if (r_corner) {
658  *r_corner = min_corner;
659  }
660  return min_track;
661  }
662  return NULL;
663 }
664 
665 static void *slide_marker_customdata(bContext *C, const wmEvent *event)
666 {
668  ARegion *region = CTX_wm_region(C);
669 
670  MovieTrackingTrack *track;
671  int width, height;
672  float co[2];
673  void *customdata = NULL;
674  int framenr = ED_space_clip_get_clip_frame_number(sc);
675  int area, action, corner;
676 
678 
679  if (width == 0 || height == 0) {
680  return NULL;
681  }
682 
683  ED_clip_mouse_pos(sc, region, event->mval, co);
684 
685  track = tracking_marker_check_slide(C, event, &area, &action, &corner);
686  if (track != NULL) {
687  MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
688  customdata = create_slide_marker_data(
689  sc, track, marker, event, area, corner, action, width, height);
690  }
691 
692  return customdata;
693 }
694 
695 static int slide_marker_invoke(bContext *C, wmOperator *op, const wmEvent *event)
696 {
697  SlideMarkerData *slidedata = slide_marker_customdata(C, event);
698  if (slidedata != NULL) {
700  MovieClip *clip = ED_space_clip_get_clip(sc);
701  MovieTracking *tracking = &clip->tracking;
702 
703  tracking->act_track = slidedata->track;
704  tracking->act_plane_track = NULL;
705 
706  op->customdata = slidedata;
707 
710 
712 
713  return OPERATOR_RUNNING_MODAL;
714  }
715 
716  return OPERATOR_PASS_THROUGH;
717 }
718 
720 {
721  MovieTrackingTrack *track = data->track;
722  MovieTrackingMarker *marker = data->marker;
723 
724  memcpy(marker->pattern_corners, data->old_corners, sizeof(marker->pattern_corners));
725  copy_v2_v2(marker->search_min, data->old_search_min);
726  copy_v2_v2(marker->search_max, data->old_search_max);
727  copy_v2_v2(marker->pos, data->old_pos);
728  copy_v2_v2(track->offset, data->old_offset);
729 
730  if (data->old_markers != NULL) {
731  for (int a = 0; a < data->track->markersnr; a++) {
732  copy_v2_v2(data->track->markers[a].pos, data->old_markers[a]);
733  }
734  }
735 }
736 
738 {
739  if (data->area == TRACK_AREA_POINT) {
741  MovieClip *clip = ED_space_clip_get_clip(sc);
742  MovieTracking *tracking = &clip->tracking;
743  ListBase *plane_tracks_base = BKE_tracking_get_active_plane_tracks(tracking);
744  int framenr = ED_space_clip_get_clip_frame_number(sc);
745 
746  for (MovieTrackingPlaneTrack *plane_track = plane_tracks_base->first; plane_track != NULL;
747  plane_track = plane_track->next) {
748  if ((plane_track->flag & PLANE_TRACK_AUTOKEY) == 0) {
749  if (BKE_tracking_plane_track_has_point_track(plane_track, data->track)) {
750  BKE_tracking_track_plane_from_existing_motion(plane_track, framenr);
751  }
752  }
753  }
754  }
755 }
756 
758 {
759  if (data->old_markers != NULL) {
760  MEM_freeN(data->old_markers);
761  }
762  MEM_freeN(data);
763 }
764 
765 static int slide_marker_modal(bContext *C, wmOperator *op, const wmEvent *event)
766 {
768  ARegion *region = CTX_wm_region(C);
769 
771  float dx, dy, mdelta[2];
772 
773  switch (event->type) {
774  case EVT_LEFTCTRLKEY:
775  case EVT_RIGHTCTRLKEY:
776  case EVT_LEFTSHIFTKEY:
777  case EVT_RIGHTSHIFTKEY:
778  if (data->action == SLIDE_ACTION_SIZE) {
779  if (ELEM(event->type, EVT_LEFTCTRLKEY, EVT_RIGHTCTRLKEY)) {
780  data->lock = event->val == KM_RELEASE;
781  }
782  }
783 
785  data->accurate = event->val == KM_PRESS;
786  }
788  case MOUSEMOVE:
789  mdelta[0] = event->mval[0] - data->mval[0];
790  mdelta[1] = event->mval[1] - data->mval[1];
791 
792  dx = mdelta[0] / data->width / sc->zoom;
793 
794  if (data->lock) {
795  dy = -dx / data->height * data->width;
796  }
797  else {
798  dy = mdelta[1] / data->height / sc->zoom;
799  }
800 
801  if (data->accurate) {
802  dx /= 5.0f;
803  dy /= 5.0f;
804  }
805 
806  if (data->area == TRACK_AREA_POINT) {
807  if (data->action == SLIDE_ACTION_OFFSET) {
808  data->offset[0] = data->old_offset[0] + dx;
809  data->offset[1] = data->old_offset[1] + dy;
810  }
811  else {
812  data->pos[0] = data->old_pos[0] + dx;
813  data->pos[1] = data->old_pos[1] + dy;
814  }
815 
817  DEG_id_tag_update(&sc->clip->id, 0);
818  }
819  else if (data->area == TRACK_AREA_PAT) {
820  if (data->action == SLIDE_ACTION_SIZE) {
821  float start[2], end[2];
822  float scale;
823 
824  ED_clip_point_stable_pos(sc, region, data->mval[0], data->mval[1], &start[0], &start[1]);
825 
826  sub_v2_v2(start, data->old_pos);
827 
828  if (len_squared_v2(start) != 0.0f) {
829  float mval[2];
830 
831  if (data->accurate) {
832  mval[0] = data->mval[0] + (event->mval[0] - data->mval[0]) / 5.0f;
833  mval[1] = data->mval[1] + (event->mval[1] - data->mval[1]) / 5.0f;
834  }
835  else {
836  mval[0] = event->mval[0];
837  mval[1] = event->mval[1];
838  }
839 
840  ED_clip_point_stable_pos(sc, region, mval[0], mval[1], &end[0], &end[1]);
841 
842  sub_v2_v2(end, data->old_pos);
843  scale = len_v2(end) / len_v2(start);
844 
845  if (scale > 0.0f) {
846  for (int a = 0; a < 4; a++) {
847  mul_v2_v2fl(data->corners[a], data->old_corners[a], scale);
848  }
849  }
850  }
851 
853  }
854  else if (data->action == SLIDE_ACTION_OFFSET) {
855  const float d[2] = {dx, dy};
856  for (int a = 0; a < data->track->markersnr; a++) {
857  add_v2_v2v2(data->track->markers[a].pos, data->old_markers[a], d);
858  }
859  sub_v2_v2v2(data->offset, data->old_offset, d);
860  }
861  else if (data->action == SLIDE_ACTION_POS) {
862  float spos[2];
863 
864  copy_v2_v2(spos, data->pos);
865 
866  data->pos[0] = data->spos[0] + dx;
867  data->pos[1] = data->spos[1] + dy;
868 
869  if (!slide_check_corners(data->corners)) {
870  copy_v2_v2(data->pos, spos);
871  }
872 
873  /* Currently only patterns are allowed to have such
874  * combination of event and data.
875  */
877  }
878  else if (data->action == SLIDE_ACTION_TILT_SIZE) {
879  float start[2], end[2];
880  float scale = 1.0f, angle = 0.0f;
881  float mval[2];
882 
883  if (data->accurate) {
884  mval[0] = data->mval[0] + (event->mval[0] - data->mval[0]) / 5.0f;
885  mval[1] = data->mval[1] + (event->mval[1] - data->mval[1]) / 5.0f;
886  }
887  else {
888  mval[0] = event->mval[0];
889  mval[1] = event->mval[1];
890  }
891 
892  sub_v2_v2v2(start, data->spos, data->old_pos);
893 
894  ED_clip_point_stable_pos(sc, region, mval[0], mval[1], &end[0], &end[1]);
895  sub_v2_v2(end, data->old_pos);
896 
897  if (len_squared_v2(start) != 0.0f) {
898  scale = len_v2(end) / len_v2(start);
899 
900  if (scale < 0.0f) {
901  scale = 0.0;
902  }
903  }
904 
905  angle = -angle_signed_v2v2(start, end);
906 
907  for (int a = 0; a < 4; a++) {
908  float vec[2];
909 
910  mul_v2_v2fl(data->corners[a], data->old_corners[a], scale);
911 
912  copy_v2_v2(vec, data->corners[a]);
913  vec[0] *= data->width;
914  vec[1] *= data->height;
915 
916  data->corners[a][0] = (vec[0] * cosf(angle) - vec[1] * sinf(angle)) / data->width;
917  data->corners[a][1] = (vec[1] * cosf(angle) + vec[0] * sinf(angle)) / data->height;
918  }
919 
921  }
922  }
923  else if (data->area == TRACK_AREA_SEARCH) {
924  if (data->action == SLIDE_ACTION_SIZE) {
925  data->min[0] = data->old_search_min[0] - dx;
926  data->max[0] = data->old_search_max[0] + dx;
927 
928  data->min[1] = data->old_search_min[1] + dy;
929  data->max[1] = data->old_search_max[1] - dy;
930 
932  }
933  else if (data->area == TRACK_AREA_SEARCH) {
934  const float d[2] = {dx, dy};
935  add_v2_v2v2(data->min, data->old_search_min, d);
936  add_v2_v2v2(data->max, data->old_search_max, d);
937  }
938 
940  }
941 
942  data->marker->flag &= ~MARKER_TRACKED;
943 
945 
946  break;
947 
948  case LEFTMOUSE:
949  if (event->val == KM_RELEASE) {
952 
954 
955  return OPERATOR_FINISHED;
956  }
957 
958  break;
959 
960  case EVT_ESCKEY:
962 
964 
966 
968 
969  return OPERATOR_CANCELLED;
970  }
971 
972  return OPERATOR_RUNNING_MODAL;
973 }
974 
976 {
977  /* identifiers */
978  ot->name = "Slide Marker";
979  ot->description = "Slide marker areas";
980  ot->idname = "CLIP_OT_slide_marker";
981 
982  /* api callbacks */
986 
987  /* flags */
989 
990  /* properties */
992  "offset",
993  2,
994  NULL,
995  -FLT_MAX,
996  FLT_MAX,
997  "Offset",
998  "Offset in floating-point units, 1.0 is the width and height of the image",
999  -FLT_MAX,
1000  FLT_MAX);
1001 }
1002 
1003 /********************** clear track operator *********************/
1004 
1006 {
1007  SpaceClip *sc = CTX_wm_space_clip(C);
1008  MovieClip *clip = ED_space_clip_get_clip(sc);
1009  MovieTracking *tracking = &clip->tracking;
1010  ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
1011  int action = RNA_enum_get(op->ptr, "action");
1012  const bool clear_active = RNA_boolean_get(op->ptr, "clear_active");
1013  int framenr = ED_space_clip_get_clip_frame_number(sc);
1014 
1015  if (clear_active) {
1017  if (track != NULL) {
1018  BKE_tracking_track_path_clear(track, framenr, action);
1019  }
1020  }
1021  else {
1022  for (MovieTrackingTrack *track = tracksbase->first; track != NULL; track = track->next) {
1023  if (TRACK_VIEW_SELECTED(sc, track)) {
1024  BKE_tracking_track_path_clear(track, framenr, action);
1025  }
1026  }
1027  }
1028 
1031 
1032  return OPERATOR_FINISHED;
1033 }
1034 
1036 {
1037  static const EnumPropertyItem clear_path_actions[] = {
1038  {TRACK_CLEAR_UPTO, "UPTO", 0, "Clear Up To", "Clear path up to current frame"},
1040  "REMAINED",
1041  0,
1042  "Clear Remained",
1043  "Clear path at remaining frames (after current)"},
1044  {TRACK_CLEAR_ALL, "ALL", 0, "Clear All", "Clear the whole path"},
1045  {0, NULL, 0, NULL, NULL},
1046  };
1047 
1048  /* identifiers */
1049  ot->name = "Clear Track Path";
1050  ot->description = "Clear tracks after/before current position or clear the whole track";
1051  ot->idname = "CLIP_OT_clear_track_path";
1052 
1053  /* api callbacks */
1056 
1057  /* flags */
1059 
1060  /* properties */
1061  RNA_def_enum(ot->srna,
1062  "action",
1063  clear_path_actions,
1065  "Action",
1066  "Clear action to execute");
1068  "clear_active",
1069  0,
1070  "Clear Active",
1071  "Clear active track only instead of all selected tracks");
1072 }
1073 
1074 /********************** disable markers operator *********************/
1075 
1076 enum {
1080 };
1081 
1083 {
1084  SpaceClip *sc = CTX_wm_space_clip(C);
1085  MovieClip *clip = ED_space_clip_get_clip(sc);
1086  MovieTracking *tracking = &clip->tracking;
1087  ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
1088  int action = RNA_enum_get(op->ptr, "action");
1089  int framenr = ED_space_clip_get_clip_frame_number(sc);
1090 
1091  for (MovieTrackingTrack *track = tracksbase->first; track != NULL; track = track->next) {
1092  if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED) == 0) {
1093  MovieTrackingMarker *marker = BKE_tracking_marker_ensure(track, framenr);
1094  switch (action) {
1095  case MARKER_OP_DISABLE:
1096  marker->flag |= MARKER_DISABLED;
1097  break;
1098  case MARKER_OP_ENABLE:
1099  marker->flag &= ~MARKER_DISABLED;
1100  break;
1101  case MARKER_OP_TOGGLE:
1102  marker->flag ^= MARKER_DISABLED;
1103  break;
1104  }
1105  }
1106  }
1107 
1108  DEG_id_tag_update(&clip->id, 0);
1109 
1111 
1112  return OPERATOR_FINISHED;
1113 }
1114 
1116 {
1117  static const EnumPropertyItem actions_items[] = {
1118  {MARKER_OP_DISABLE, "DISABLE", 0, "Disable", "Disable selected markers"},
1119  {MARKER_OP_ENABLE, "ENABLE", 0, "Enable", "Enable selected markers"},
1120  {MARKER_OP_TOGGLE, "TOGGLE", 0, "Toggle", "Toggle disabled flag for selected markers"},
1121  {0, NULL, 0, NULL, NULL},
1122  };
1123 
1124  /* identifiers */
1125  ot->name = "Disable Markers";
1126  ot->description = "Disable/enable selected markers";
1127  ot->idname = "CLIP_OT_disable_markers";
1128 
1129  /* api callbacks */
1132 
1133  /* flags */
1135 
1136  /* properties */
1137  RNA_def_enum(ot->srna, "action", actions_items, 0, "Action", "Disable action to execute");
1138 }
1139 
1140 /********************** set principal center operator *********************/
1141 
1143 {
1144  SpaceClip *sc = CTX_wm_space_clip(C);
1145  MovieClip *clip = ED_space_clip_get_clip(sc);
1146  int width, height;
1147 
1148  BKE_movieclip_get_size(clip, &sc->user, &width, &height);
1149 
1150  if (width == 0 || height == 0) {
1151  return OPERATOR_CANCELLED;
1152  }
1153 
1154  clip->tracking.camera.principal[0] = ((float)width) / 2.0f;
1155  clip->tracking.camera.principal[1] = ((float)height) / 2.0f;
1156 
1158 
1159  return OPERATOR_FINISHED;
1160 }
1161 
1163 {
1164  /* identifiers */
1165  ot->name = "Set Principal to Center";
1166  ot->description = "Set optical center to center of footage";
1167  ot->idname = "CLIP_OT_set_center_principal";
1168 
1169  /* api callbacks */
1172 
1173  /* flags */
1175 }
1176 
1177 /********************** hide tracks operator *********************/
1178 
1180 {
1181  SpaceClip *sc = CTX_wm_space_clip(C);
1182  MovieClip *clip = ED_space_clip_get_clip(sc);
1183  MovieTracking *tracking = &clip->tracking;
1184  int unselected;
1185 
1186  unselected = RNA_boolean_get(op->ptr, "unselected");
1187 
1188  /* Hide point tracks. */
1189  ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
1190  MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking);
1191  for (MovieTrackingTrack *track = tracksbase->first; track != NULL; track = track->next) {
1192  if (unselected == 0 && TRACK_VIEW_SELECTED(sc, track)) {
1193  track->flag |= TRACK_HIDDEN;
1194  }
1195  else if (unselected == 1 && !TRACK_VIEW_SELECTED(sc, track)) {
1196  track->flag |= TRACK_HIDDEN;
1197  }
1198  }
1199 
1200  if (act_track != NULL && act_track->flag & TRACK_HIDDEN) {
1201  clip->tracking.act_track = NULL;
1202  }
1203 
1204  /* Hide place tracks. */
1205  ListBase *plane_tracks_base = BKE_tracking_get_active_plane_tracks(tracking);
1206  MovieTrackingPlaneTrack *act_plane_track = BKE_tracking_plane_track_get_active(tracking);
1207  for (MovieTrackingPlaneTrack *plane_track = plane_tracks_base->first; plane_track != NULL;
1208  plane_track = plane_track->next) {
1209  if (unselected == 0 && plane_track->flag & SELECT) {
1210  plane_track->flag |= PLANE_TRACK_HIDDEN;
1211  }
1212  else if (unselected == 1 && (plane_track->flag & SELECT) == 0) {
1213  plane_track->flag |= PLANE_TRACK_HIDDEN;
1214  }
1215  }
1216  if (act_plane_track != NULL && act_plane_track->flag & TRACK_HIDDEN) {
1217  clip->tracking.act_plane_track = NULL;
1218  }
1219 
1222 
1223  return OPERATOR_FINISHED;
1224 }
1225 
1227 {
1228  /* identifiers */
1229  ot->name = "Hide Tracks";
1230  ot->description = "Hide selected tracks";
1231  ot->idname = "CLIP_OT_hide_tracks";
1232 
1233  /* api callbacks */
1236 
1237  /* flags */
1239 
1240  /* properties */
1241  RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected tracks");
1242 }
1243 
1244 /********************** hide tracks clear operator *********************/
1245 
1247 {
1248  SpaceClip *sc = CTX_wm_space_clip(C);
1249  MovieClip *clip = ED_space_clip_get_clip(sc);
1250  MovieTracking *tracking = &clip->tracking;
1251 
1252  /* Unhide point tracks. */
1253  ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
1254  for (MovieTrackingTrack *track = tracksbase->first; track != NULL; track = track->next) {
1255  track->flag &= ~TRACK_HIDDEN;
1256  }
1257 
1258  /* Unhide plane tracks. */
1259  ListBase *plane_tracks_base = BKE_tracking_get_active_plane_tracks(tracking);
1260  for (MovieTrackingPlaneTrack *plane_track = plane_tracks_base->first; plane_track != NULL;
1261  plane_track = plane_track->next) {
1262  plane_track->flag &= ~PLANE_TRACK_HIDDEN;
1263  }
1264 
1266 
1268 
1269  return OPERATOR_FINISHED;
1270 }
1271 
1273 {
1274  /* identifiers */
1275  ot->name = "Hide Tracks Clear";
1276  ot->description = "Clear hide selected tracks";
1277  ot->idname = "CLIP_OT_hide_tracks_clear";
1278 
1279  /* api callbacks */
1282 
1283  /* flags */
1285 }
1286 
1287 /********************** frame jump operator *********************/
1288 
1290 {
1291  SpaceClip *space_clip = CTX_wm_space_clip(C);
1292  return space_clip != NULL;
1293 }
1294 
1296 {
1298  SpaceClip *sc = CTX_wm_space_clip(C);
1299  MovieClip *clip = ED_space_clip_get_clip(sc);
1300  MovieTracking *tracking = &clip->tracking;
1301  int pos = RNA_enum_get(op->ptr, "position");
1302  int delta;
1303 
1304  if (pos <= 1) { /* jump to path */
1306  if (track == NULL) {
1307  return OPERATOR_CANCELLED;
1308  }
1309 
1310  delta = pos == 1 ? 1 : -1;
1311  while (sc->user.framenr + delta >= SFRA && sc->user.framenr + delta <= EFRA) {
1312  int framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, sc->user.framenr + delta);
1313  MovieTrackingMarker *marker = BKE_tracking_marker_get_exact(track, framenr);
1314 
1315  if (marker == NULL || marker->flag & MARKER_DISABLED) {
1316  break;
1317  }
1318 
1319  sc->user.framenr += delta;
1320  }
1321  }
1322  else { /* to failed frame */
1323  if (tracking->reconstruction.flag & TRACKING_RECONSTRUCTED) {
1324  int framenr = ED_space_clip_get_clip_frame_number(sc);
1326 
1327  delta = pos == 3 ? 1 : -1;
1328  framenr += delta;
1329 
1330  while (framenr + delta >= SFRA && framenr + delta <= EFRA) {
1332  tracking, object, framenr);
1333 
1334  if (cam == NULL) {
1336  break;
1337  }
1338 
1339  framenr += delta;
1340  }
1341  }
1342  }
1343 
1344  if (CFRA != sc->user.framenr) {
1345  CFRA = sc->user.framenr;
1347 
1349  }
1350 
1352 
1353  return OPERATOR_FINISHED;
1354 }
1355 
1357 {
1358  static const EnumPropertyItem position_items[] = {
1359  {0, "PATHSTART", 0, "Path Start", "Jump to start of current path"},
1360  {1, "PATHEND", 0, "Path End", "Jump to end of current path"},
1361  {2, "FAILEDPREV", 0, "Previous Failed", "Jump to previous failed frame"},
1362  {2, "FAILNEXT", 0, "Next Failed", "Jump to next failed frame"},
1363  {0, NULL, 0, NULL, NULL},
1364  };
1365 
1366  /* identifiers */
1367  ot->name = "Jump to Frame";
1368  ot->description = "Jump to special frame";
1369  ot->idname = "CLIP_OT_frame_jump";
1370 
1371  /* api callbacks */
1372  ot->exec = frame_jump_exec;
1373  ot->poll = frame_jump_poll;
1374 
1375  /* flags */
1377 
1378  /* properties */
1379  RNA_def_enum(ot->srna, "position", position_items, 0, "Position", "Position to jump to");
1380 }
1381 
1382 /********************** join tracks operator *********************/
1383 
1385 {
1386  SpaceClip *sc = CTX_wm_space_clip(C);
1387  MovieClip *clip = ED_space_clip_get_clip(sc);
1388  MovieTracking *tracking = &clip->tracking;
1389  MovieTrackingStabilization *stab = &tracking->stabilization;
1390  ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
1391  ListBase *plane_tracks_base = BKE_tracking_get_active_plane_tracks(tracking);
1392  bool update_stabilization = false;
1393 
1394  MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking);
1395  if (act_track == NULL) {
1396  BKE_report(op->reports, RPT_ERROR, "No active track to join to");
1397  return OPERATOR_CANCELLED;
1398  }
1399 
1400  GSet *point_tracks = BLI_gset_ptr_new(__func__);
1401 
1402  for (MovieTrackingTrack *track = tracksbase->first, *next_track; track != NULL;
1403  track = next_track) {
1404  next_track = track->next;
1405  if (TRACK_VIEW_SELECTED(sc, track) && track != act_track) {
1406  BKE_tracking_tracks_join(tracking, act_track, track);
1407 
1408  if (track->flag & TRACK_USE_2D_STAB) {
1409  update_stabilization = true;
1410  if ((act_track->flag & TRACK_USE_2D_STAB) == 0) {
1411  act_track->flag |= TRACK_USE_2D_STAB;
1412  }
1413  else {
1414  stab->tot_track--;
1415  }
1416  BLI_assert(0 <= stab->tot_track);
1417  }
1418  if (track->flag & TRACK_USE_2D_STAB_ROT) {
1419  update_stabilization = true;
1420  if ((act_track->flag & TRACK_USE_2D_STAB_ROT) == 0) {
1421  act_track->flag |= TRACK_USE_2D_STAB_ROT;
1422  }
1423  else {
1424  stab->tot_rot_track--;
1425  }
1426  BLI_assert(0 <= stab->tot_rot_track);
1427  }
1428 
1429  for (MovieTrackingPlaneTrack *plane_track = plane_tracks_base->first; plane_track != NULL;
1430  plane_track = plane_track->next) {
1431  if (BKE_tracking_plane_track_has_point_track(plane_track, track)) {
1432  BKE_tracking_plane_track_replace_point_track(plane_track, track, act_track);
1433  if ((plane_track->flag & PLANE_TRACK_AUTOKEY) == 0) {
1434  BLI_gset_insert(point_tracks, plane_track);
1435  }
1436  }
1437  }
1438 
1439  BKE_tracking_track_free(track);
1440  BLI_freelinkN(tracksbase, track);
1441  }
1442  }
1443 
1444  if (update_stabilization) {
1446  }
1447 
1448  GSetIterator gs_iter;
1449  int framenr = ED_space_clip_get_clip_frame_number(sc);
1450  GSET_ITER (gs_iter, point_tracks) {
1451  MovieTrackingPlaneTrack *plane_track = BLI_gsetIterator_getKey(&gs_iter);
1452  BKE_tracking_track_plane_from_existing_motion(plane_track, framenr);
1453  }
1454 
1455  BLI_gset_free(point_tracks, NULL);
1456  DEG_id_tag_update(&clip->id, 0);
1457 
1459 
1460  return OPERATOR_FINISHED;
1461 }
1462 
1464 {
1465  /* identifiers */
1466  ot->name = "Join Tracks";
1467  ot->description = "Join selected tracks";
1468  ot->idname = "CLIP_OT_join_tracks";
1469 
1470  /* api callbacks */
1473 
1474  /* flags */
1476 }
1477 
1478 /********************** Average tracks operator *********************/
1479 
1481 {
1482  SpaceClip *space_clip = CTX_wm_space_clip(C);
1483  MovieClip *clip = ED_space_clip_get_clip(space_clip);
1484  MovieTracking *tracking = &clip->tracking;
1485 
1486  /* Collect source tracks. */
1487  int num_source_tracks;
1489  tracking, &num_source_tracks);
1490  if (num_source_tracks == 0) {
1491  return OPERATOR_CANCELLED;
1492  }
1493 
1494  /* Create new empty track, which will be the averaged result.
1495  * Makes it simple to average all selection to it. */
1496  ListBase *tracks_list = BKE_tracking_get_active_tracks(tracking);
1497  MovieTrackingTrack *result_track = BKE_tracking_track_add_empty(tracking, tracks_list);
1498 
1499  /* Perform averaging. */
1500  BKE_tracking_tracks_average(result_track, source_tracks, num_source_tracks);
1501 
1502  const bool keep_original = RNA_boolean_get(op->ptr, "keep_original");
1503  if (!keep_original) {
1504  for (int i = 0; i < num_source_tracks; i++) {
1505  clip_delete_track(C, clip, source_tracks[i]);
1506  }
1507  }
1508 
1509  /* Update selection, making the result track active and selected. */
1510  /* TODO(sergey): Should become some sort of utility function available for all operators. */
1511 
1512  BKE_tracking_track_select(tracks_list, result_track, TRACK_AREA_ALL, 0);
1513  ListBase *plane_tracks_list = BKE_tracking_get_active_plane_tracks(tracking);
1514  BKE_tracking_plane_tracks_deselect_all(plane_tracks_list);
1515 
1516  clip->tracking.act_track = result_track;
1517  clip->tracking.act_plane_track = NULL;
1518 
1519  /* Inform the dependency graph and interface about changes. */
1520  DEG_id_tag_update(&clip->id, 0);
1522 
1523  /* Free memory. */
1524  MEM_freeN(source_tracks);
1525 
1526  return OPERATOR_FINISHED;
1527 }
1528 
1529 static int average_tracks_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
1530 {
1531  PropertyRNA *prop_keep_original = RNA_struct_find_property(op->ptr, "keep_original");
1532  if (!RNA_property_is_set(op->ptr, prop_keep_original)) {
1533  SpaceClip *space_clip = CTX_wm_space_clip(C);
1534  MovieClip *clip = ED_space_clip_get_clip(space_clip);
1535  MovieTracking *tracking = &clip->tracking;
1536 
1537  const int num_selected_tracks = BKE_tracking_count_selected_tracks_in_active_object(tracking);
1538 
1539  if (num_selected_tracks == 1) {
1540  RNA_property_boolean_set(op->ptr, prop_keep_original, false);
1541  }
1542  }
1543 
1544  return average_tracks_exec(C, op);
1545 }
1546 
1548 {
1549  /* Identifiers. */
1550  ot->name = "Average Tracks";
1551  ot->description = "Average selected tracks into active";
1552  ot->idname = "CLIP_OT_average_tracks";
1553 
1554  /* API callbacks. */
1558 
1559  /* Flags. */
1561 
1562  /* Properties. */
1563  PropertyRNA *prop;
1564 
1565  prop = RNA_def_boolean(ot->srna, "keep_original", 1, "Keep Original", "Keep original tracks");
1567 }
1568 
1569 /********************** lock tracks operator *********************/
1570 
1571 enum {
1575 };
1576 
1578 {
1579  SpaceClip *sc = CTX_wm_space_clip(C);
1580  MovieClip *clip = ED_space_clip_get_clip(sc);
1581  MovieTracking *tracking = &clip->tracking;
1582  ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
1583  int action = RNA_enum_get(op->ptr, "action");
1584 
1585  for (MovieTrackingTrack *track = tracksbase->first; track != NULL; track = track->next) {
1586  if (TRACK_VIEW_SELECTED(sc, track)) {
1587  switch (action) {
1588  case TRACK_ACTION_LOCK:
1589  track->flag |= TRACK_LOCKED;
1590  break;
1591  case TRACK_ACTION_UNLOCK:
1592  track->flag &= ~TRACK_LOCKED;
1593  break;
1594  case TRACK_ACTION_TOGGLE:
1595  track->flag ^= TRACK_LOCKED;
1596  break;
1597  }
1598  }
1599  }
1600 
1602 
1603  return OPERATOR_FINISHED;
1604 }
1605 
1607 {
1608  static const EnumPropertyItem actions_items[] = {
1609  {TRACK_ACTION_LOCK, "LOCK", 0, "Lock", "Lock selected tracks"},
1610  {TRACK_ACTION_UNLOCK, "UNLOCK", 0, "Unlock", "Unlock selected tracks"},
1611  {TRACK_ACTION_TOGGLE, "TOGGLE", 0, "Toggle", "Toggle locked flag for selected tracks"},
1612  {0, NULL, 0, NULL, NULL},
1613  };
1614 
1615  /* identifiers */
1616  ot->name = "Lock Tracks";
1617  ot->description = "Lock/unlock selected tracks";
1618  ot->idname = "CLIP_OT_lock_tracks";
1619 
1620  /* api callbacks */
1623 
1624  /* flags */
1626 
1627  /* properties */
1628  RNA_def_enum(ot->srna, "action", actions_items, 0, "Action", "Lock action to execute");
1629 }
1630 
1631 /********************** set keyframe operator *********************/
1632 
1633 enum {
1636 };
1637 
1639 {
1640  SpaceClip *sc = CTX_wm_space_clip(C);
1641  MovieClip *clip = ED_space_clip_get_clip(sc);
1642  MovieTracking *tracking = &clip->tracking;
1644  int keyframe = RNA_enum_get(op->ptr, "keyframe");
1645  int framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, sc->user.framenr);
1646 
1647  if (keyframe == SOLVER_KEYFRAME_A) {
1648  object->keyframe1 = framenr;
1649  }
1650  else {
1651  object->keyframe2 = framenr;
1652  }
1653 
1655 
1656  return OPERATOR_FINISHED;
1657 }
1658 
1660 {
1661  static const EnumPropertyItem keyframe_items[] = {
1662  {SOLVER_KEYFRAME_A, "KEYFRAME_A", 0, "Keyframe A", ""},
1663  {SOLVER_KEYFRAME_B, "KEYFRAME_B", 0, "Keyframe B", ""},
1664  {0, NULL, 0, NULL, NULL},
1665  };
1666 
1667  /* identifiers */
1668  ot->name = "Set Solver Keyframe";
1669  ot->description = "Set keyframe used by solver";
1670  ot->idname = "CLIP_OT_set_solver_keyframe";
1671 
1672  /* api callbacks */
1675 
1676  /* flags */
1678 
1679  /* properties */
1680  RNA_def_enum(ot->srna, "keyframe", keyframe_items, 0, "Keyframe", "Keyframe to set");
1681 }
1682 
1683 /********************** track copy color operator *********************/
1684 
1686 {
1687  SpaceClip *sc = CTX_wm_space_clip(C);
1688  MovieClip *clip = ED_space_clip_get_clip(sc);
1689  MovieTracking *tracking = &clip->tracking;
1690  ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
1691 
1692  MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking);
1693  if (act_track == NULL) {
1694  return OPERATOR_CANCELLED;
1695  }
1696 
1697  for (MovieTrackingTrack *track = tracksbase->first; track != NULL; track = track->next) {
1698  if (TRACK_VIEW_SELECTED(sc, track) && track != act_track) {
1699  track->flag &= ~TRACK_CUSTOMCOLOR;
1700  if (act_track->flag & TRACK_CUSTOMCOLOR) {
1701  copy_v3_v3(track->color, act_track->color);
1702  track->flag |= TRACK_CUSTOMCOLOR;
1703  }
1704  }
1705  }
1706 
1707  DEG_id_tag_update(&clip->id, 0);
1709 
1710  return OPERATOR_FINISHED;
1711 }
1712 
1714 {
1715  /* identifiers */
1716  ot->name = "Copy Color";
1717  ot->description = "Copy color to all selected tracks";
1718  ot->idname = "CLIP_OT_track_copy_color";
1719 
1720  /* api callbacks */
1723 
1724  /* flags */
1726 }
1727 
1728 /********************** clean tracks operator *********************/
1729 
1730 static bool is_track_clean(MovieTrackingTrack *track, int frames, int del)
1731 {
1732  bool ok = true;
1733  int prev = -1, count = 0;
1734  MovieTrackingMarker *markers = track->markers, *new_markers = NULL;
1735  int start_disabled = 0;
1736  int markersnr = track->markersnr;
1737 
1738  if (del) {
1739  new_markers = MEM_callocN(markersnr * sizeof(MovieTrackingMarker), "track cleaned markers");
1740  }
1741 
1742  for (int a = 0; a < markersnr; a++) {
1743  int end = 0;
1744 
1745  if (prev == -1) {
1746  if ((markers[a].flag & MARKER_DISABLED) == 0) {
1747  prev = a;
1748  }
1749  else {
1750  start_disabled = 1;
1751  }
1752  }
1753 
1754  if (prev >= 0) {
1755  end = a == markersnr - 1;
1756  end |= (a < markersnr - 1) && (markers[a].framenr != markers[a + 1].framenr - 1 ||
1757  markers[a].flag & MARKER_DISABLED);
1758  }
1759 
1760  if (end) {
1761  int segok = 1, len = 0;
1762 
1763  if (a != prev && markers[a].framenr != markers[a - 1].framenr + 1) {
1764  len = a - prev;
1765  }
1766  else if (markers[a].flag & MARKER_DISABLED) {
1767  len = a - prev;
1768  }
1769  else {
1770  len = a - prev + 1;
1771  }
1772 
1773  if (frames) {
1774  if (len < frames) {
1775  segok = 0;
1776  ok = 0;
1777 
1778  if (!del) {
1779  break;
1780  }
1781  }
1782  }
1783 
1784  if (del) {
1785  if (segok) {
1786  int t = len;
1787 
1788  if (markers[a].flag & MARKER_DISABLED) {
1789  t++;
1790  }
1791 
1792  /* Place disabled marker in front of current segment. */
1793  if (start_disabled) {
1794  memcpy(new_markers + count, markers + prev, sizeof(MovieTrackingMarker));
1795  new_markers[count].framenr--;
1796  new_markers[count].flag |= MARKER_DISABLED;
1797 
1798  count++;
1799  start_disabled = 0;
1800  }
1801 
1802  memcpy(new_markers + count, markers + prev, t * sizeof(MovieTrackingMarker));
1803  count += t;
1804  }
1805  else if (markers[a].flag & MARKER_DISABLED) {
1806  /* Current segment which would be deleted was finished by
1807  * disabled marker, so next segment should be started from
1808  * disabled marker.
1809  */
1810  start_disabled = 1;
1811  }
1812  }
1813 
1814  prev = -1;
1815  }
1816  }
1817 
1818  if (del && count == 0) {
1819  ok = 0;
1820  }
1821 
1822  if (del) {
1823  MEM_freeN(track->markers);
1824 
1825  if (count) {
1826  track->markers = new_markers;
1827  }
1828  else {
1829  track->markers = NULL;
1830  MEM_freeN(new_markers);
1831  }
1832 
1833  track->markersnr = count;
1834  }
1835 
1836  return ok;
1837 }
1838 
1840 {
1841  SpaceClip *sc = CTX_wm_space_clip(C);
1842  MovieClip *clip = ED_space_clip_get_clip(sc);
1843  MovieTracking *tracking = &clip->tracking;
1844  ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
1845  MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking);
1846  int frames = RNA_int_get(op->ptr, "frames");
1847  int action = RNA_enum_get(op->ptr, "action");
1848  float error = RNA_float_get(op->ptr, "error");
1849 
1850  if (error && action == TRACKING_CLEAN_DELETE_SEGMENT) {
1851  action = TRACKING_CLEAN_DELETE_TRACK;
1852  }
1853 
1854  for (MovieTrackingTrack *track = tracksbase->first, *next_track; track != NULL;
1855  track = next_track) {
1856  next_track = track->next;
1857 
1858  if ((track->flag & TRACK_HIDDEN) == 0 && (track->flag & TRACK_LOCKED) == 0) {
1859  bool ok;
1860 
1861  ok = (is_track_clean(track, frames, action == TRACKING_CLEAN_DELETE_SEGMENT)) &&
1862  ((error == 0.0f) || (track->flag & TRACK_HAS_BUNDLE) == 0 || (track->error < error));
1863 
1864  if (!ok) {
1865  if (action == TRACKING_CLEAN_SELECT) {
1867  }
1868  else if (action == TRACKING_CLEAN_DELETE_TRACK) {
1869  if (track == act_track) {
1870  clip->tracking.act_track = NULL;
1871  }
1872  BKE_tracking_track_free(track);
1873  BLI_freelinkN(tracksbase, track);
1874  track = NULL;
1875  }
1876 
1877  /* Happens when all tracking segments are not long enough. */
1878  if (track && track->markersnr == 0) {
1879  if (track == act_track) {
1880  clip->tracking.act_track = NULL;
1881  }
1882  BKE_tracking_track_free(track);
1883  BLI_freelinkN(tracksbase, track);
1884  }
1885  }
1886  }
1887  }
1888 
1889  DEG_id_tag_update(&clip->id, 0);
1891 
1893 
1894  return OPERATOR_FINISHED;
1895 }
1896 
1897 static int clean_tracks_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
1898 {
1899  SpaceClip *sc = CTX_wm_space_clip(C);
1900  MovieClip *clip = ED_space_clip_get_clip(sc);
1901 
1902  if (!RNA_struct_property_is_set(op->ptr, "frames")) {
1903  RNA_int_set(op->ptr, "frames", clip->tracking.settings.clean_frames);
1904  }
1905 
1906  if (!RNA_struct_property_is_set(op->ptr, "error")) {
1907  RNA_float_set(op->ptr, "error", clip->tracking.settings.clean_error);
1908  }
1909 
1910  if (!RNA_struct_property_is_set(op->ptr, "action")) {
1911  RNA_enum_set(op->ptr, "action", clip->tracking.settings.clean_action);
1912  }
1913 
1914  return clean_tracks_exec(C, op);
1915 }
1916 
1918 {
1919  static const EnumPropertyItem actions_items[] = {
1920  {TRACKING_CLEAN_SELECT, "SELECT", 0, "Select", "Select unclean tracks"},
1921  {TRACKING_CLEAN_DELETE_TRACK, "DELETE_TRACK", 0, "Delete Track", "Delete unclean tracks"},
1923  "DELETE_SEGMENTS",
1924  0,
1925  "Delete Segments",
1926  "Delete unclean segments of tracks"},
1927  {0, NULL, 0, NULL, NULL},
1928  };
1929 
1930  /* identifiers */
1931  ot->name = "Clean Tracks";
1932  ot->description = "Clean tracks with high error values or few frames";
1933  ot->idname = "CLIP_OT_clean_tracks";
1934 
1935  /* api callbacks */
1939 
1940  /* flags */
1942 
1943  /* properties */
1944  RNA_def_int(ot->srna,
1945  "frames",
1946  0,
1947  0,
1948  INT_MAX,
1949  "Tracked Frames",
1950  "Effect on tracks which are tracked less than "
1951  "specified amount of frames",
1952  0,
1953  INT_MAX);
1955  "error",
1956  0.0f,
1957  0.0f,
1958  FLT_MAX,
1959  "Reprojection Error",
1960  "Effect on tracks which have got larger reprojection error",
1961  0.0f,
1962  100.0f);
1963  RNA_def_enum(ot->srna, "action", actions_items, 0, "Action", "Cleanup action to execute");
1964 }
1965 
1966 /********************** add tracking object *********************/
1967 
1969 {
1970  SpaceClip *sc = CTX_wm_space_clip(C);
1971  MovieClip *clip = ED_space_clip_get_clip(sc);
1972  MovieTracking *tracking = &clip->tracking;
1973 
1974  BKE_tracking_object_add(tracking, "Object");
1975 
1978 
1979  return OPERATOR_FINISHED;
1980 }
1981 
1983 {
1984  /* identifiers */
1985  ot->name = "Add Tracking Object";
1986  ot->description = "Add new object for tracking";
1987  ot->idname = "CLIP_OT_tracking_object_new";
1988 
1989  /* api callbacks */
1992 
1993  /* flags */
1995 }
1996 
1997 /********************** remove tracking object *********************/
1998 
2000 {
2001  SpaceClip *sc = CTX_wm_space_clip(C);
2002  MovieClip *clip = ED_space_clip_get_clip(sc);
2003  MovieTracking *tracking = &clip->tracking;
2004  MovieTrackingObject *object;
2005 
2006  object = BKE_tracking_object_get_active(tracking);
2007 
2008  if (object->flag & TRACKING_OBJECT_CAMERA) {
2009  BKE_report(op->reports, RPT_WARNING, "Object used for camera tracking cannot be deleted");
2010  return OPERATOR_CANCELLED;
2011  }
2012 
2013  BKE_tracking_object_delete(tracking, object);
2014 
2017 
2018  return OPERATOR_FINISHED;
2019 }
2020 
2022 {
2023  /* identifiers */
2024  ot->name = "Remove Tracking Object";
2025  ot->description = "Remove object for tracking";
2026  ot->idname = "CLIP_OT_tracking_object_remove";
2027 
2028  /* api callbacks */
2031 
2032  /* flags */
2034 }
2035 
2036 /********************** copy tracks to clipboard operator *********************/
2037 
2039 {
2040  SpaceClip *sc = CTX_wm_space_clip(C);
2041  MovieClip *clip = ED_space_clip_get_clip(sc);
2042  MovieTracking *tracking = &clip->tracking;
2044 
2046 
2047  BKE_tracking_clipboard_copy_tracks(tracking, object);
2048 
2049  return OPERATOR_FINISHED;
2050 }
2051 
2053 {
2054  /* identifiers */
2055  ot->name = "Copy Tracks";
2056  ot->description = "Copy selected tracks to clipboard";
2057  ot->idname = "CLIP_OT_copy_tracks";
2058 
2059  /* api callbacks */
2062 
2063  /* flags */
2064  ot->flag = OPTYPE_REGISTER;
2065 }
2066 
2067 /********************* paste tracks from clipboard operator ********************/
2068 
2070 {
2073  }
2074 
2075  return 0;
2076 }
2077 
2079 {
2080  SpaceClip *sc = CTX_wm_space_clip(C);
2081  MovieClip *clip = ED_space_clip_get_clip(sc);
2082  MovieTracking *tracking = &clip->tracking;
2084  ListBase *tracks_base = BKE_tracking_object_get_tracks(tracking, object);
2085 
2086  BKE_tracking_tracks_deselect_all(tracks_base);
2087  BKE_tracking_clipboard_paste_tracks(tracking, object);
2088 
2090 
2091  return OPERATOR_FINISHED;
2092 }
2093 
2095 {
2096  /* identifiers */
2097  ot->name = "Paste Tracks";
2098  ot->description = "Paste tracks from clipboard";
2099  ot->idname = "CLIP_OT_paste_tracks";
2100 
2101  /* api callbacks */
2104 
2105  /* flags */
2107 }
2108 
2109 /********************** Insert track keyframe operator *********************/
2110 
2111 static void keyframe_set_flag(bContext *C, bool set)
2112 {
2113  SpaceClip *sc = CTX_wm_space_clip(C);
2114  MovieClip *clip = ED_space_clip_get_clip(sc);
2115  MovieTracking *tracking = &clip->tracking;
2116  int framenr = ED_space_clip_get_clip_frame_number(sc);
2117 
2118  ListBase *tracks_base = BKE_tracking_get_active_tracks(tracking);
2119  for (MovieTrackingTrack *track = tracks_base->first; track != NULL; track = track->next) {
2120  if (TRACK_VIEW_SELECTED(sc, track)) {
2121  if (set) {
2122  MovieTrackingMarker *marker = BKE_tracking_marker_ensure(track, framenr);
2123  marker->flag &= ~MARKER_TRACKED;
2124  }
2125  else {
2126  MovieTrackingMarker *marker = BKE_tracking_marker_get_exact(track, framenr);
2127  if (marker != NULL) {
2128  marker->flag |= MARKER_TRACKED;
2129  }
2130  }
2131  }
2132  }
2133 
2134  ListBase *plane_tracks_base = BKE_tracking_get_active_plane_tracks(tracking);
2135  for (MovieTrackingPlaneTrack *plane_track = plane_tracks_base->first; plane_track != NULL;
2136  plane_track = plane_track->next) {
2137  if (PLANE_TRACK_VIEW_SELECTED(plane_track)) {
2138  if (set) {
2139  MovieTrackingPlaneMarker *plane_marker = BKE_tracking_plane_marker_ensure(plane_track,
2140  framenr);
2141  if (plane_marker->flag & PLANE_MARKER_TRACKED) {
2142  plane_marker->flag &= ~PLANE_MARKER_TRACKED;
2143  BKE_tracking_track_plane_from_existing_motion(plane_track, plane_marker->framenr);
2144  }
2145  }
2146  else {
2148  framenr);
2149  if (plane_marker) {
2150  if ((plane_marker->flag & PLANE_MARKER_TRACKED) == 0) {
2151  plane_marker->flag |= PLANE_MARKER_TRACKED;
2153  plane_marker->framenr);
2154  }
2155  }
2156  }
2157  }
2158  }
2159 
2161 }
2162 
2164 {
2165  keyframe_set_flag(C, true);
2166  return OPERATOR_FINISHED;
2167 }
2168 
2170 {
2171  /* identifiers */
2172  ot->name = "Insert Keyframe";
2173  ot->description = "Insert a keyframe to selected tracks at current frame";
2174  ot->idname = "CLIP_OT_keyframe_insert";
2175 
2176  /* api callbacks */
2179 
2180  /* flags */
2182 }
2183 
2184 /********************** Delete track keyframe operator *********************/
2185 
2187 {
2188  keyframe_set_flag(C, false);
2189  return OPERATOR_FINISHED;
2190 }
2191 
2193 {
2194  /* identifiers */
2195  ot->name = "Delete Keyframe";
2196  ot->description = "Delete a keyframe from selected tracks at current frame";
2197  ot->idname = "CLIP_OT_keyframe_delete";
2198 
2199  /* api callbacks */
2202 
2203  /* flags */
2205 }
typedef float(TangentPoint)[2]
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1034
struct SpaceClip * CTX_wm_space_clip(const bContext *C)
Definition: context.c:899
struct ARegion * CTX_wm_region(const bContext *C)
Definition: context.c:725
float BKE_movieclip_remap_scene_to_clip_frame(const struct MovieClip *clip, float framenr)
void BKE_movieclip_get_size(struct MovieClip *clip, struct MovieClipUser *user, int *width, int *height)
Definition: movieclip.c:1540
float BKE_movieclip_remap_clip_to_scene_frame(const struct MovieClip *clip, float framenr)
void BKE_report(ReportList *reports, ReportType type, const char *message)
Definition: report.c:104
void BKE_tracking_plane_track_free(struct MovieTrackingPlaneTrack *plane_track)
Definition: tracking.c:1797
void BKE_tracking_plane_track_replace_point_track(struct MovieTrackingPlaneTrack *plane_track, struct MovieTrackingTrack *old_track, struct MovieTrackingTrack *new_track)
Definition: tracking.c:1893
struct MovieTrackingPlaneTrack * BKE_tracking_plane_track_get_active(struct MovieTracking *tracking)
Definition: tracking.c:1821
struct MovieTrackingPlaneMarker * BKE_tracking_plane_marker_ensure(struct MovieTrackingPlaneTrack *plane_track, int framenr)
Definition: tracking.c:2058
#define TRACK_AREA_ALL
Definition: BKE_tracking.h:524
#define CLAMP_SEARCH_POS
Definition: BKE_tracking.h:517
void BKE_tracking_tracks_average(struct MovieTrackingTrack *dst_track, struct MovieTrackingTrack **src_tracks, const int num_src_tracks)
Definition: tracking.c:1107
void BKE_tracking_plane_marker_delete(struct MovieTrackingPlaneTrack *plane_track, int framenr)
Definition: tracking.c:1960
void BKE_tracking_clipboard_paste_tracks(struct MovieTracking *tracking, struct MovieTrackingObject *object)
Definition: tracking.c:524
bool BKE_tracking_object_delete(struct MovieTracking *tracking, struct MovieTrackingObject *object)
Definition: tracking.c:2133
struct ListBase * BKE_tracking_get_active_tracks(struct MovieTracking *tracking)
Definition: tracking.c:365
void BKE_tracking_retrack_plane_from_existing_motion_at_segment(struct MovieTrackingPlaneTrack *plane_track, int start_frame)
#define PLANE_TRACK_VIEW_SELECTED(plane_track)
Definition: BKE_tracking.h:503
struct MovieTrackingObject * BKE_tracking_object_add(struct MovieTracking *tracking, const char *name)
Definition: tracking.c:2104
void BKE_tracking_plane_tracks_deselect_all(struct ListBase *plane_tracks_base)
Definition: tracking.c:1837
struct MovieReconstructedCamera * BKE_tracking_camera_get_reconstructed(struct MovieTracking *tracking, struct MovieTrackingObject *object, int framenr)
Definition: tracking.c:2357
void BKE_tracking_track_flag_set(struct MovieTrackingTrack *track, int area, int flag)
Definition: tracking.c:753
#define CLAMP_SEARCH_DIM
Definition: BKE_tracking.h:516
struct MovieTrackingMarker * BKE_tracking_marker_ensure(struct MovieTrackingTrack *track, int framenr)
Definition: tracking.c:1567
void BKE_tracking_tracks_join(struct MovieTracking *tracking, struct MovieTrackingTrack *dst_track, struct MovieTrackingTrack *src_track)
Definition: tracking.c:887
struct MovieTrackingTrack * BKE_tracking_track_get_active(struct MovieTracking *tracking)
Definition: tracking.c:1170
#define TRACK_CLEAR_ALL
Definition: BKE_tracking.h:512
void BKE_tracking_dopesheet_tag_update(struct MovieTracking *tracking)
Definition: tracking.c:3321
struct MovieTrackingMarker * BKE_tracking_marker_get_exact(struct MovieTrackingTrack *track, int framenr)
Definition: tracking.c:1556
void BKE_tracking_track_free(struct MovieTrackingTrack *track)
Definition: tracking.c:661
#define TRACK_CLEAR_UPTO
Definition: BKE_tracking.h:510
void BKE_tracking_track_plane_from_existing_motion(struct MovieTrackingPlaneTrack *plane_track, int start_frame)
void BKE_tracking_tracks_deselect_all(struct ListBase *tracksbase)
Definition: tracking.c:1372
void BKE_tracking_track_select(struct ListBase *tracksbase, struct MovieTrackingTrack *track, int area, bool extend)
Definition: tracking.c:1340
struct ListBase * BKE_tracking_get_active_plane_tracks(struct MovieTracking *tracking)
Definition: tracking.c:377
#define TRACK_AREA_SEARCH
Definition: BKE_tracking.h:522
#define TRACK_AREA_PAT
Definition: BKE_tracking.h:521
void BKE_tracking_track_path_clear(struct MovieTrackingTrack *track, int ref_frame, int action)
Definition: tracking.c:824
struct MovieTrackingTrack * BKE_tracking_track_add_empty(struct MovieTracking *tracking, struct ListBase *tracks_list)
Definition: tracking.c:548
struct MovieTrackingPlaneMarker * BKE_tracking_plane_marker_get_exact(struct MovieTrackingPlaneTrack *plane_track, int framenr)
Definition: tracking.c:2045
void BKE_tracking_clipboard_copy_tracks(struct MovieTracking *tracking, struct MovieTrackingObject *object)
Definition: tracking.c:493
#define TRACK_CLEAR_REMAINED
Definition: BKE_tracking.h:511
#define TRACK_AREA_POINT
Definition: BKE_tracking.h:520
#define TRACK_VIEW_SELECTED(sc, track)
Definition: BKE_tracking.h:497
int BKE_tracking_count_selected_tracks_in_active_object(struct MovieTracking *tracking)
Definition: tracking.c:710
struct ListBase * BKE_tracking_object_get_tracks(struct MovieTracking *tracking, struct MovieTrackingObject *object)
Definition: tracking.c:2218
bool BKE_tracking_clipboard_has_tracks(void)
Definition: tracking.c:514
bool BKE_tracking_plane_track_has_point_track(struct MovieTrackingPlaneTrack *plane_track, struct MovieTrackingTrack *track)
Definition: tracking.c:1844
struct MovieTrackingTrack * BKE_tracking_track_add(struct MovieTracking *tracking, struct ListBase *tracksbase, float x, float y, int framenr, int width, int height)
Definition: tracking.c:580
struct MovieTrackingMarker * BKE_tracking_marker_get(struct MovieTrackingTrack *track, int framenr)
Definition: tracking.c:1523
struct MovieTrackingTrack ** BKE_tracking_selected_tracks_in_active_object(struct MovieTracking *tracking, int *r_num_tracks)
Definition: tracking.c:716
#define CLAMP_PAT_DIM
Definition: BKE_tracking.h:514
void BKE_tracking_marker_clamp(struct MovieTrackingMarker *marker, int event)
Definition: tracking.c:1455
struct MovieTrackingObject * BKE_tracking_object_get_active(struct MovieTracking *tracking)
Definition: tracking.c:2198
#define BLI_assert(a)
Definition: BLI_assert.h:58
#define ATTR_FALLTHROUGH
struct GSet GSet
Definition: BLI_ghash.h:189
GSet * BLI_gset_ptr_new(const char *info)
void BLI_gset_insert(GSet *gs, void *key)
Definition: BLI_ghash.c:1147
#define GSET_ITER(gs_iter_, gset_)
Definition: BLI_ghash.h:268
void BLI_gset_free(GSet *gs, GSetKeyFreeFP keyfreefp)
Definition: BLI_ghash.c:1253
BLI_INLINE void * BLI_gsetIterator_getKey(GSetIterator *gsi)
Definition: BLI_ghash.h:255
void BLI_freelinkN(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:281
MINLINE float square_f(float a)
int isect_point_quad_v2(const float p[2], const float v1[2], const float v2[2], const float v3[2], const float v4[2])
Definition: math_geom.c:1616
MINLINE float len_squared_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void sub_v2_v2(float r[2], const float a[2])
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])
float angle_signed_v2v2(const float v1[2], const float v2[2]) ATTR_WARN_UNUSED_RESULT
Definition: math_vector.c:499
MINLINE float cross_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
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 len_v2(const float a[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void mul_v2_v2fl(float r[2], const float a[2], float f)
#define UNUSED(x)
#define ELEM(...)
#define TIP_(msgid)
void DEG_id_tag_update(struct ID *id, int flag)
@ ID_RECALC_COPY_ON_WRITE
Definition: DNA_ID.h:654
@ ID_RECALC_AUDIO_SEEK
Definition: DNA_ID.h:660
#define CFRA
#define SFRA
#define EFRA
@ SC_SHOW_MARKER_SEARCH
@ SC_SHOW_MARKER_PATTERN
@ TRACK_CUSTOMCOLOR
@ TRACK_HIDDEN
@ TRACK_LOCKED
@ TRACK_USE_2D_STAB
@ TRACK_HAS_BUNDLE
@ TRACK_USE_2D_STAB_ROT
@ TRACKING_OBJECT_CAMERA
@ PLANE_MARKER_TRACKED
@ TRACKING_RECONSTRUCTED
@ PLANE_TRACK_HIDDEN
@ PLANE_TRACK_AUTOKEY
@ MARKER_TRACKED
@ MARKER_DISABLED
@ TRACKING_CLEAN_DELETE_SEGMENT
@ TRACKING_CLEAN_SELECT
@ TRACKING_CLEAN_DELETE_TRACK
@ OPERATOR_CANCELLED
@ OPERATOR_FINISHED
@ OPERATOR_RUNNING_MODAL
@ OPERATOR_PASS_THROUGH
int ED_space_clip_get_clip_frame_number(struct SpaceClip *sc)
Definition: clip_editor.c:227
void ED_clip_view_lock_state_restore_no_jump(const struct bContext *C, const ClipViewLockState *state)
void ED_space_clip_get_size(struct SpaceClip *sc, int *width, int *height)
Definition: clip_editor.c:141
void ED_clip_mouse_pos(struct SpaceClip *sc, struct ARegion *region, const int mval[2], float co[2])
Definition: clip_editor.c:543
bool ED_space_clip_tracking_poll(struct bContext *C)
Definition: clip_editor.c:98
void ED_clip_point_stable_pos(struct SpaceClip *sc, struct ARegion *region, float x, float y, float *xr, float *yr)
Definition: clip_editor.c:480
struct MovieClip * ED_space_clip_get_clip(struct SpaceClip *sc)
Definition: clip_editor.c:572
void ED_clip_view_lock_state_store(const struct bContext *C, ClipViewLockState *state)
void ED_workspace_status_text(struct bContext *C, const char *str)
Definition: area.c:840
_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
_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 y
_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.
@ PROP_SKIP_SAVE
Definition: RNA_types.h:204
#define C
Definition: RandGen.cpp:39
#define NC_GEOM
Definition: WM_types.h:294
@ OPTYPE_BLOCKING
Definition: WM_types.h:157
@ OPTYPE_UNDO
Definition: WM_types.h:155
@ OPTYPE_GRAB_CURSOR_XY
Definition: WM_types.h:161
@ OPTYPE_REGISTER
Definition: WM_types.h:153
#define NA_EVALUATED
Definition: WM_types.h:463
#define ND_DISPLAY
Definition: WM_types.h:391
#define NC_MOVIECLIP
Definition: WM_types.h:298
#define NC_SCENE
Definition: WM_types.h:279
#define NA_EDITED
Definition: WM_types.h:462
#define KM_PRESS
Definition: WM_types.h:242
#define ND_FRAME
Definition: WM_types.h:334
#define ND_SELECT
Definition: WM_types.h:407
#define ND_TRANSFORM
Definition: WM_types.h:357
#define NC_OBJECT
Definition: WM_types.h:280
#define KM_RELEASE
Definition: WM_types.h:243
ATTR_WARN_UNUSED_RESULT const BMVert * v2
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
Definition: btVector3.h:356
void clip_delete_marker(struct bContext *C, struct MovieClip *clip, struct MovieTrackingTrack *track, struct MovieTrackingMarker *marker)
Definition: clip_utils.c:366
void clip_delete_track(struct bContext *C, struct MovieClip *clip, struct MovieTrackingTrack *track)
Definition: clip_utils.c:327
void clip_delete_plane_track(struct bContext *C, struct MovieClip *clip, struct MovieTrackingPlaneTrack *plane_track)
Definition: clip_utils.c:381
#define SELECT
Scene scene
uint pos
const vector< Marker > & markers
int count
#define sinf(x)
#define cosf(x)
#define fabsf(x)
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:45
static ulong * next
static void error(const char *str)
Definition: meshlaplacian.c:65
static unsigned a[3]
Definition: RandGen.cpp:92
static void area(int d1, int d2, int e1, int e2, float weights[2])
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:6655
void RNA_int_set(PointerRNA *ptr, const char *name, int value)
Definition: rna_access.c:6319
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
Definition: rna_access.c:866
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
Definition: rna_access.c:6378
int RNA_int_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6308
void RNA_property_boolean_set(PointerRNA *ptr, PropertyRNA *prop, bool value)
Definition: rna_access.c:2358
float RNA_float_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6355
void RNA_float_set(PointerRNA *ptr, const char *name, float value)
Definition: rna_access.c:6366
bool RNA_struct_property_is_set(PointerRNA *ptr, const char *identifier)
Definition: rna_access.c:6685
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6261
void RNA_enum_set(PointerRNA *ptr, const char *name, int value)
Definition: rna_access.c:6413
void RNA_float_set_array(PointerRNA *ptr, const char *name, const float *values)
Definition: rna_access.c:6390
int RNA_enum_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6402
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:3825
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3481
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:3851
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1512
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, int default_value, int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
Definition: rna_define.c:3585
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3771
#define min(a, b)
Definition: sort.c:51
void * first
Definition: DNA_listBase.h:47
struct MovieTracking tracking
MovieTrackingMarker * markers
struct MovieTrackingTrack * next
MovieTrackingReconstruction reconstruction
MovieTrackingPlaneTrack * act_plane_track
MovieTrackingTrack * act_track
MovieTrackingStabilization stabilization
MovieTrackingCamera camera
MovieTrackingSettings settings
MovieTrackingTrack * track
Definition: tracking_ops.c:348
MovieTrackingMarker * marker
Definition: tracking_ops.c:349
struct MovieClipUser user
struct MovieClip * clip
int ymin
Definition: DNA_vec_types.h:80
int xmin
Definition: DNA_vec_types.h:79
int y
Definition: WM_types.h:581
short val
Definition: WM_types.h:579
int mval[2]
Definition: WM_types.h:583
int x
Definition: WM_types.h:581
short type
Definition: WM_types.h:577
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:752
const char * name
Definition: WM_types.h:721
int(* modal)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:768
const char * idname
Definition: WM_types.h:723
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:776
struct StructRNA * srna
Definition: WM_types.h:802
const char * description
Definition: WM_types.h:726
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:736
struct ReportList * reports
struct PointerRNA * ptr
void CLIP_OT_paste_tracks(wmOperatorType *ot)
static int disable_markers_exec(bContext *C, wmOperator *op)
void CLIP_OT_delete_marker(wmOperatorType *ot)
Definition: tracking_ops.c:321
static float mouse_to_offset_distance_squared(const MovieTrackingTrack *track, const MovieTrackingMarker *marker, const float co[2], int width, int height)
Definition: tracking_ops.c:483
static int frame_jump_exec(bContext *C, wmOperator *op)
static int tracking_object_remove_exec(bContext *C, wmOperator *op)
static bool add_marker(const bContext *C, float x, float y)
Definition: tracking_ops.c:57
static bool slide_check_corners(float(*corners)[2])
Definition: tracking_ops.c:504
static int hide_tracks_exec(bContext *C, wmOperator *op)
static SlideMarkerData * create_slide_marker_data(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker, const wmEvent *event, int area, int corner, int action, int width, int height)
Definition: tracking_ops.c:370
void CLIP_OT_track_copy_color(wmOperatorType *ot)
static float mouse_to_slide_zone_distance_squared(const float co[2], const float slide_zone[2], int width, int height)
Definition: tracking_ops.c:442
void CLIP_OT_hide_tracks_clear(wmOperatorType *ot)
void CLIP_OT_keyframe_delete(wmOperatorType *ot)
void CLIP_OT_set_center_principal(wmOperatorType *ot)
static int add_marker_at_click_modal(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
Definition: tracking_ops.c:162
static float mouse_to_closest_pattern_corner_distance_squared(const MovieTrackingMarker *marker, const float co[2], int width, int height, int *r_corner)
Definition: tracking_ops.c:467
static int join_tracks_exec(bContext *C, wmOperator *op)
static void slide_marker_tilt_slider(const MovieTrackingMarker *marker, float r_slider[2])
Definition: tracking_ops.c:364
static int keyframe_delete_exec(bContext *C, wmOperator *UNUSED(op))
static bool frame_jump_poll(bContext *C)
static int slide_marker_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition: tracking_ops.c:695
@ TRACK_ACTION_TOGGLE
@ TRACK_ACTION_UNLOCK
@ TRACK_ACTION_LOCK
void CLIP_OT_hide_tracks(wmOperatorType *ot)
static void free_slide_data(SlideMarkerData *data)
Definition: tracking_ops.c:757
static float mouse_to_search_corner_distance_squared(const MovieTrackingMarker *marker, const float co[2], int corner, int width, int height)
Definition: tracking_ops.c:452
void CLIP_OT_set_solver_keyframe(wmOperatorType *ot)
void CLIP_OT_lock_tracks(wmOperatorType *ot)
static void * slide_marker_customdata(bContext *C, const wmEvent *event)
Definition: tracking_ops.c:665
static void keyframe_set_flag(bContext *C, bool set)
void CLIP_OT_average_tracks(wmOperatorType *ot)
static int mouse_to_tilt_distance_squared(const MovieTrackingMarker *marker, const float co[2], int width, int height)
Definition: tracking_ops.c:494
MovieTrackingTrack * tracking_marker_check_slide(bContext *C, const wmEvent *event, int *r_area, int *r_action, int *r_corner)
Definition: tracking_ops.c:537
static int track_copy_color_exec(bContext *C, wmOperator *UNUSED(op))
void CLIP_OT_tracking_object_new(wmOperatorType *ot)
void CLIP_OT_keyframe_insert(wmOperatorType *ot)
static int clean_tracks_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
@ MARKER_OP_TOGGLE
@ MARKER_OP_DISABLE
@ MARKER_OP_ENABLE
void CLIP_OT_copy_tracks(wmOperatorType *ot)
static void apply_mouse_slide(bContext *C, SlideMarkerData *data)
Definition: tracking_ops.c:737
static int average_tracks_exec(bContext *C, wmOperator *op)
static void cancel_mouse_slide(SlideMarkerData *data)
Definition: tracking_ops.c:719
void CLIP_OT_slide_marker(wmOperatorType *ot)
Definition: tracking_ops.c:975
static int add_marker_exec(bContext *C, wmOperator *op)
Definition: tracking_ops.c:85
void CLIP_OT_add_marker_at_click(wmOperatorType *ot)
Definition: tracking_ops.c:199
static int clear_track_path_exec(bContext *C, wmOperator *op)
void CLIP_OT_clean_tracks(wmOperatorType *ot)
static int add_marker_at_click_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
Definition: tracking_ops.c:152
void CLIP_OT_join_tracks(wmOperatorType *ot)
static int slide_marker_modal(bContext *C, wmOperator *op, const wmEvent *event)
Definition: tracking_ops.c:765
static int lock_tracks_exec(bContext *C, wmOperator *op)
static int set_center_principal_exec(bContext *C, wmOperator *UNUSED(op))
void CLIP_OT_delete_track(wmOperatorType *ot)
Definition: tracking_ops.c:252
void CLIP_OT_add_marker(wmOperatorType *ot)
Definition: tracking_ops.c:122
static int set_solver_keyframe_exec(bContext *C, wmOperator *op)
@ SOLVER_KEYFRAME_B
@ SOLVER_KEYFRAME_A
static bool paste_tracks_poll(bContext *C)
static int tracking_object_new_exec(bContext *C, wmOperator *UNUSED(op))
static int delete_track_exec(bContext *C, wmOperator *UNUSED(op))
Definition: tracking_ops.c:217
static int add_marker_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition: tracking_ops.c:107
static int paste_tracks_exec(bContext *C, wmOperator *UNUSED(op))
static int average_tracks_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int clean_tracks_exec(bContext *C, wmOperator *op)
static int delete_marker_exec(bContext *C, wmOperator *UNUSED(op))
Definition: tracking_ops.c:270
void CLIP_OT_tracking_object_remove(wmOperatorType *ot)
void CLIP_OT_disable_markers(wmOperatorType *ot)
@ SLIDE_ACTION_TILT_SIZE
Definition: tracking_ops.c:343
@ SLIDE_ACTION_POS
Definition: tracking_ops.c:340
@ SLIDE_ACTION_OFFSET
Definition: tracking_ops.c:342
@ SLIDE_ACTION_SIZE
Definition: tracking_ops.c:341
static int copy_tracks_exec(bContext *C, wmOperator *UNUSED(op))
static int keyframe_insert_exec(bContext *C, wmOperator *UNUSED(op))
static int hide_tracks_clear_exec(bContext *C, wmOperator *UNUSED(op))
static bool is_track_clean(MovieTrackingTrack *track, int frames, int del)
void CLIP_OT_clear_track_path(wmOperatorType *ot)
void CLIP_OT_frame_jump(wmOperatorType *ot)
void clip_tracking_hide_cursor(struct bContext *C)
void clip_tracking_show_cursor(struct bContext *C)
void clip_tracking_clear_invisible_track_selection(struct SpaceClip *sc, struct MovieClip *clip)
float max
__forceinline avxf cross(const avxf &a, const avxf &b)
Definition: util_avxf.h:119
uint len
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
@ EVT_RIGHTCTRLKEY
@ EVT_LEFTCTRLKEY
@ MOUSEMOVE
@ LEFTMOUSE
@ EVT_ESCKEY
@ EVT_RIGHTSHIFTKEY
@ EVT_LEFTSHIFTKEY
wmOperatorType * ot
Definition: wm_files.c:3156
int WM_operator_confirm(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))