Blender V4.3
clip_draw.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10#include "DNA_movieclip_types.h"
11#include "DNA_scene_types.h"
12
13#include "MEM_guardedalloc.h"
14
16#include "IMB_imbuf.hh"
17#include "IMB_imbuf_types.hh"
18
19#include "BLI_math_base.h"
20#include "BLI_rect.h"
21#include "BLI_string.h"
22#include "BLI_utildefines.h"
23
24#include "BKE_context.hh"
25#include "BKE_image.hh"
26#include "BKE_movieclip.h"
27#include "BKE_tracking.h"
28
29#include "ED_clip.hh"
30#include "ED_gpencil_legacy.hh"
31#include "ED_mask.hh"
32#include "ED_screen.hh"
33#include "ED_util.hh"
34
35#include "BIF_glutil.hh"
36
37#include "GPU_immediate.hh"
38#include "GPU_immediate_util.hh"
39#include "GPU_matrix.hh"
40#include "GPU_state.hh"
41
42#include "WM_types.hh"
43
44#include "UI_resources.hh"
45#include "UI_view2d.hh"
46
47#include "BLF_api.hh"
48
49#include "clip_intern.hh" /* own include */
50
51/*********************** main area drawing *************************/
52
53static void draw_keyframe(int frame, int cfra, int sfra, float framelen, int width, uint pos)
54{
55 int height = (frame == cfra) ? 22 : 10;
56 int x = (frame - sfra) * framelen;
57
58 if (width == 1) {
60 immVertex2i(pos, x, 0);
61 immVertex2i(pos, x, height * UI_SCALE_FAC);
62 immEnd();
63 }
64 else {
65 immRecti(pos, x, 0, x + width, height * UI_SCALE_FAC);
66 }
67}
68
70 const MovieTrackingPlaneTrack *plane_track)
71{
72 if (track) {
73 return track->markersnr;
74 }
75 if (plane_track) {
76 return plane_track->markersnr;
77 }
78
79 return 0;
80}
81
83 const MovieTrackingPlaneTrack *plane_track,
84 const int marker_index)
85{
86 if (track) {
87 BLI_assert(marker_index < track->markersnr);
88 return track->markers[marker_index].framenr;
89 }
90 if (plane_track) {
91 BLI_assert(marker_index < plane_track->markersnr);
92 return plane_track->markers[marker_index].framenr;
93 }
94
95 return 0;
96}
97
99 const MovieTrackingPlaneTrack *plane_track,
100 const int marker_index)
101{
102 if (track) {
103 BLI_assert(marker_index < track->markersnr);
104 return (track->markers[marker_index].flag & MARKER_DISABLED) == 0;
105 }
106 if (plane_track) {
107 return true;
108 }
109
110 return false;
111}
112
114 const MovieTrackingPlaneTrack *plane_track,
115 const int marker_index)
116{
117 if (track) {
118 BLI_assert(marker_index < track->markersnr);
119 return (track->markers[marker_index].flag & MARKER_TRACKED) == 0;
120 }
121 if (plane_track) {
122 BLI_assert(marker_index < plane_track->markersnr);
123 return (plane_track->markers[marker_index].flag & PLANE_MARKER_TRACKED) == 0;
124 }
125
126 return false;
127}
128
129static void draw_movieclip_cache(SpaceClip *sc, ARegion *region, MovieClip *clip, Scene *scene)
130{
131 float x;
132 int *points, totseg, i, a;
133 float sfra = scene->r.sfra, efra = scene->r.efra, framelen = region->winx / (efra - sfra + 1);
134 const MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(&clip->tracking);
136
138
139 /* cache background */
141
142 /* cached segments -- could be useful to debug caching strategies */
143 BKE_movieclip_get_cache_segments(clip, &sc->user, &totseg, &points);
144 ED_region_cache_draw_cached_segments(region, totseg, points, sfra, efra);
145
149
150 /* track */
151 if (tracking_object->active_track || tracking_object->active_plane_track) {
152 const MovieTrackingTrack *active_track = tracking_object->active_track;
153 const MovieTrackingPlaneTrack *active_plane_track = tracking_object->active_plane_track;
154
155 for (i = sfra - clip->start_frame + 1, a = 0; i <= efra - clip->start_frame + 1; i++) {
156 int framenr;
157 const int markersnr = generic_track_get_markersnr(active_track, active_plane_track);
158
159 while (a < markersnr) {
160 int marker_framenr = generic_track_get_marker_framenr(active_track, active_plane_track, a);
161
162 if (marker_framenr >= i) {
163 break;
164 }
165
166 if (a < markersnr - 1 &&
167 generic_track_get_marker_framenr(active_track, active_plane_track, a + 1) > i)
168 {
169 break;
170 }
171
172 a++;
173 }
174
175 a = min_ii(a, markersnr - 1);
176
177 if (generic_track_is_marker_enabled(active_track, active_plane_track, a)) {
178 framenr = generic_track_get_marker_framenr(active_track, active_plane_track, a);
179
180 if (framenr != i) {
181 immUniformColor4ub(128, 128, 0, 96);
182 }
183 else if (generic_track_is_marker_keyframed(active_track, active_plane_track, a)) {
184 immUniformColor4ub(255, 255, 0, 196);
185 }
186 else {
187 immUniformColor4ub(255, 255, 0, 96);
188 }
189
191 (i - sfra + clip->start_frame - 1) * framelen,
192 0,
193 (i - sfra + clip->start_frame) * framelen,
194 4 * UI_SCALE_FAC);
195 }
196 }
197 }
198
199 /* failed frames */
201 int n = reconstruction->camnr;
202 MovieReconstructedCamera *cameras = reconstruction->cameras;
203
204 immUniformColor4ub(255, 0, 0, 96);
205
206 for (i = sfra, a = 0; i <= efra; i++) {
207 bool ok = false;
208
209 while (a < n) {
210 if (cameras[a].framenr == i) {
211 ok = true;
212 break;
213 }
214 if (cameras[a].framenr > i) {
215 break;
216 }
217
218 a++;
219 }
220
221 if (!ok) {
223 (i - sfra + clip->start_frame - 1) * framelen,
224 0,
225 (i - sfra + clip->start_frame) * framelen,
226 8 * UI_SCALE_FAC);
227 }
228 }
229 }
230
232
233 /* current frame */
234 x = (sc->user.framenr - sfra) / (efra - sfra + 1) * region->winx;
235
237 immRecti(pos, x, 0, x + ceilf(framelen), 8 * UI_SCALE_FAC);
238
240
242
245
246 /* solver keyframes */
247 immUniformColor4ub(175, 255, 0, 255);
249 tracking_object->keyframe1 + clip->start_frame - 1, scene->r.cfra, sfra, framelen, 2, pos);
251 tracking_object->keyframe2 + clip->start_frame - 1, scene->r.cfra, sfra, framelen, 2, pos);
252
254
255 /* movie clip animation */
256 if ((sc->mode == SC_MODE_MASKEDIT) && sc->mask_info.mask) {
257 ED_mask_draw_frames(sc->mask_info.mask, region, scene->r.cfra, sfra, efra);
258 }
259}
260
261static void draw_movieclip_notes(SpaceClip *sc, ARegion *region)
262{
264 MovieTracking *tracking = &clip->tracking;
265 char str[256] = {0};
266 bool full_redraw = false;
267
268 if (tracking->stats) {
269 STRNCPY(str, tracking->stats->message);
270 full_redraw = true;
271 }
272 else {
273 if (sc->flag & SC_LOCK_SELECTION) {
274 STRNCPY(str, "Locked");
275 }
276 }
277
278 if (str[0]) {
279 float fill_color[4] = {0.0f, 0.0f, 0.0f, 0.6f};
280 ED_region_info_draw(region, str, fill_color, full_redraw);
281 }
282}
283
284static void draw_movieclip_muted(ARegion *region, int width, int height, float zoomx, float zoomy)
285{
286 int x, y;
287
290
291 /* find window pixel coordinates of origin */
292 UI_view2d_view_to_region(&region->v2d, 0.0f, 0.0f, &x, &y);
293
294 immUniformColor3f(0.0f, 0.0f, 0.0f);
295 immRectf(pos, x, y, x + zoomx * width, y + zoomy * height);
296
298}
299
300static void draw_movieclip_buffer(const bContext *C,
301 SpaceClip *sc,
302 ARegion *region,
303 ImBuf *ibuf,
304 int width,
305 int height,
306 float zoomx,
307 float zoomy)
308{
310 bool use_filter = true;
311 int x, y;
312
313 /* find window pixel coordinates of origin */
314 UI_view2d_view_to_region(&region->v2d, 0.0f, 0.0f, &x, &y);
315
316 /* checkerboard for case alpha */
317 if (ibuf->planes == 32) {
319
320 imm_draw_box_checker_2d(x, y, x + zoomx * ibuf->x, y + zoomy * ibuf->y);
321 }
322
323 /* non-scaled proxy shouldn't use filtering */
324 if ((clip->flag & MCLIP_USE_PROXY) == 0 ||
326 {
327 use_filter = false;
328 }
329
330 ED_draw_imbuf_ctx(C, ibuf, x, y, use_filter, zoomx * width / ibuf->x, zoomy * height / ibuf->y);
331
332 if (ibuf->planes == 32) {
334 }
335
336 if (sc->flag & SC_SHOW_METADATA) {
337 rctf frame;
338 BLI_rctf_init(&frame, 0.0f, ibuf->x, 0.0f, ibuf->y);
340 x, y, ibuf, &frame, zoomx * width / ibuf->x, zoomy * height / ibuf->y);
341 }
342}
343
345 SpaceClip *sc, ARegion *region, int width, int height, float zoomx, float zoomy)
346{
347 int x, y;
349
350 /* find window pixel coordinates of origin */
351 UI_view2d_view_to_region(&region->v2d, 0.0f, 0.0f, &x, &y);
352
353 /* draw boundary border for frame if stabilization is enabled */
354 if (sc->flag & SC_SHOW_STABLE && clip->tracking.stabilization.flag & TRACKING_2D_STABILIZATION) {
355 const uint shdr_pos = GPU_vertformat_attr_add(
357
358 /* Exclusive OR allows to get orig value when second operand is 0,
359 * and negative of orig value when second operand is 1. */
361
364
365 GPU_matrix_scale_2f(zoomx, zoomy);
367
369
370 float viewport_size[4];
371 GPU_viewport_size_get_f(viewport_size);
373 "viewport_size", viewport_size[2] / UI_SCALE_FAC, viewport_size[3] / UI_SCALE_FAC);
374
375 immUniform1i("colors_len", 0); /* "simple" mode */
376 immUniformColor4f(1.0f, 1.0f, 1.0f, 0.0f);
377 immUniform1f("dash_width", 6.0f);
378 immUniform1f("udash_factor", 0.5f);
379
380 imm_draw_box_wire_2d(shdr_pos, 0.0f, 0.0f, width, height);
381
383
385
387 }
388}
389
390enum {
392};
393
395 float co[2];
397};
398
400 const MovieTrackingTrack *track,
401 const MovieTrackingMarker *marker,
402 TrackPathPoint *point)
403{
404 add_v2_v2v2(point->co, marker->pos, track->offset);
405 ED_clip_point_undistorted_pos(sc, point->co, point->co);
406 point->flag = 0;
407 if ((marker->flag & MARKER_TRACKED) == 0) {
408 point->flag |= PATH_POINT_FLAG_KEYFRAME;
409 }
410}
411
413 MovieTrackingTrack *track,
414 int direction,
415 TrackPathPoint *path)
416{
417 const int count = sc->path_length;
418 int current_frame = ED_space_clip_get_clip_frame_number(sc);
419 const MovieTrackingMarker *marker = BKE_tracking_marker_get_exact(track, current_frame);
420 /* Check whether there is marker at exact current frame.
421 * If not, we don't have anything to be put to path. */
422 if (marker == nullptr || (marker->flag & MARKER_DISABLED)) {
423 return 0;
424 }
425 /* Index inside of path array where we write data to. */
426 int point_index = count;
427 int path_length = 0;
428 for (int i = 0; i < count; ++i) {
429 marker_to_path_point(sc, track, marker, &path[point_index]);
430 /* Move to the next marker along the path segment. */
431 path_length++;
432 point_index += direction;
433 current_frame += direction;
434 marker = BKE_tracking_marker_get_exact(track, current_frame);
435 if (marker == nullptr || (marker->flag & MARKER_DISABLED)) {
436 /* Reached end of tracked segment. */
437 break;
438 }
439 }
440 return path_length;
441}
442
444 uint position_attribute,
445 const int start_point,
446 const int num_points)
447{
448 if (num_points == 0) {
449 return;
450 }
451 immBegin(GPU_PRIM_POINTS, num_points);
452 for (int i = 0; i < num_points; i++) {
453 const TrackPathPoint *point = &path[i + start_point];
454 immVertex2fv(position_attribute, point->co);
455 }
456 immEnd();
457}
458
460 uint position_attribute,
461 const int start_point,
462 const int num_points)
463{
464 immBeginAtMost(GPU_PRIM_POINTS, num_points);
465 for (int i = 0; i < num_points; i++) {
466 const TrackPathPoint *point = &path[i + start_point];
467 if (point->flag & PATH_POINT_FLAG_KEYFRAME) {
468 immVertex2fv(position_attribute, point->co);
469 }
470 }
471 immEnd();
472}
473
474static void draw_track_path_lines(const TrackPathPoint *path,
475 uint position_attribute,
476 const int start_point,
477 const int num_points)
478{
479 if (num_points < 2) {
480 return;
481 }
482 immBegin(GPU_PRIM_LINE_STRIP, num_points);
483 for (int i = 0; i < num_points; i++) {
484 const TrackPathPoint *point = &path[i + start_point];
485 immVertex2fv(position_attribute, point->co);
486 }
487 immEnd();
488}
489
490static void draw_track_path(SpaceClip *sc, MovieClip * /*clip*/, MovieTrackingTrack *track)
491{
492#define MAX_STATIC_PATH 64
493
494 const int count = sc->path_length;
495 TrackPathPoint path_static[(MAX_STATIC_PATH + 1) * 2];
496 TrackPathPoint *path;
497 const bool tiny = (sc->flag & SC_SHOW_TINY_MARKER) != 0;
498
499 if (count == 0) {
500 /* Early output, nothing to bother about here. */
501 return;
502 }
503
504 /* Try to use stack allocated memory when possibly, only use heap allocation
505 * for really long paths. */
506 path = (count < MAX_STATIC_PATH) ?
507 path_static :
508 MEM_cnew_array<TrackPathPoint>(sizeof(*path) * (count + 1) * 2, "path");
509 /* Collect path information. */
510 const int num_points_before = track_to_path_segment(sc, track, -1, path);
511 const int num_points_after = track_to_path_segment(sc, track, 1, path);
512 if (num_points_before == 0 && num_points_after == 0) {
513 return;
514 }
515
516 int num_all_points = num_points_before + num_points_after;
517 /* If both leading and trailing parts of the path are there the center point is counted twice. */
518 if (num_points_before != 0 && num_points_after != 0) {
519 num_all_points -= 1;
520 }
521
522 const int path_start_index = count - num_points_before + 1;
523 const int path_center_index = count;
524
525 const uint position_attribute = GPU_vertformat_attr_add(
528
529 /* Draw path outline. */
530 if (!tiny) {
532 if (TRACK_VIEW_SELECTED(sc, track)) {
533 GPU_point_size(5.0f);
534 draw_track_path_points(path, position_attribute, path_start_index, num_all_points);
535 GPU_point_size(7.0f);
536 draw_track_path_keyframe_points(path, position_attribute, path_start_index, num_all_points);
537 }
538 /* Draw darker outline for actual path, all line segments at once. */
539 GPU_line_width(3.0f);
540 draw_track_path_lines(path, position_attribute, path_start_index, num_all_points);
541 }
542
543 /* Draw all points. */
544 GPU_point_size(3.0f);
546 draw_track_path_points(path, position_attribute, path_start_index, num_points_before);
548 draw_track_path_points(path, position_attribute, path_center_index, num_points_after);
549
550 /* Connect points with color coded segments. */
553 draw_track_path_lines(path, position_attribute, path_start_index, num_points_before);
555 draw_track_path_lines(path, position_attribute, path_center_index, num_points_after);
556
557 /* Draw all bigger points corresponding to keyframes. */
558 GPU_point_size(5.0f);
560 draw_track_path_keyframe_points(path, position_attribute, path_start_index, num_points_before);
562 draw_track_path_keyframe_points(path, position_attribute, path_center_index, num_points_after);
563
564 if (path != path_static) {
565 MEM_freeN(path);
566 }
567
569
570#undef MAX_STATIC_PATH
571}
572
574 const MovieTrackingTrack *track,
575 const MovieTrackingMarker *marker,
576 const float marker_pos[2],
577 int width,
578 int height,
579 uint position)
580{
581 int tiny = sc->flag & SC_SHOW_TINY_MARKER;
582 bool show_search = false;
583 float px[2];
584
585 px[0] = 1.0f / width / sc->zoom;
586 px[1] = 1.0f / height / sc->zoom;
587
588 GPU_line_width(tiny ? 1.0f : 3.0f);
589
591
592 if ((marker->flag & MARKER_DISABLED) == 0) {
593 float pos[2];
594 float p[2];
595
596 add_v2_v2v2(pos, marker->pos, track->offset);
597
599
600 sub_v2_v2v2(p, pos, marker_pos);
601
603 marker->pattern_corners[0],
604 marker->pattern_corners[1],
605 marker->pattern_corners[2],
606 marker->pattern_corners[3]))
607 {
608 GPU_point_size(tiny ? 3.0f : 4.0f);
609
611 immVertex2f(position, pos[0], pos[1]);
612 immEnd();
613 }
614 else {
616
617 immVertex2f(position, pos[0] + px[0] * 2, pos[1]);
618 immVertex2f(position, pos[0] + px[0] * 8, pos[1]);
619
620 immVertex2f(position, pos[0] - px[0] * 2, pos[1]);
621 immVertex2f(position, pos[0] - px[0] * 8, pos[1]);
622
623 immVertex2f(position, pos[0], pos[1] - px[1] * 2);
624 immVertex2f(position, pos[0], pos[1] - px[1] * 8);
625
626 immVertex2f(position, pos[0], pos[1] + px[1] * 2);
627 immVertex2f(position, pos[0], pos[1] + px[1] * 8);
628
629 immEnd();
630 }
631 }
632
633 /* pattern and search outline */
635 GPU_matrix_translate_2fv(marker_pos);
636
637 if (sc->flag & SC_SHOW_MARKER_PATTERN) {
639 immVertex2fv(position, marker->pattern_corners[0]);
640 immVertex2fv(position, marker->pattern_corners[1]);
641 immVertex2fv(position, marker->pattern_corners[2]);
642 immVertex2fv(position, marker->pattern_corners[3]);
643 immEnd();
644 }
645
646 show_search = (TRACK_VIEW_SELECTED(sc, track) && ((marker->flag & MARKER_DISABLED) == 0 ||
647 (sc->flag & SC_SHOW_MARKER_PATTERN) == 0)) !=
648 0;
649
650 if (sc->flag & SC_SHOW_MARKER_SEARCH && show_search) {
651 imm_draw_box_wire_2d(position,
652 marker->search_min[0],
653 marker->search_min[1],
654 marker->search_max[0],
655 marker->search_max[1]);
656 }
657
659}
660
661static void track_colors(const MovieTrackingTrack *track, int act, float r_col[3], float r_scol[3])
662{
663 if (track->flag & TRACK_CUSTOMCOLOR) {
664 if (act) {
666 }
667 else {
668 copy_v3_v3(r_scol, track->color);
669 }
670
671 mul_v3_v3fl(r_col, track->color, 0.5f);
672 }
673 else {
675
676 if (act) {
678 }
679 else {
681 }
682 }
683}
684
686 const MovieTrackingMarker *marker,
687 const bool is_track_active,
688 const bool is_area_selected,
689 const float color[3],
690 const float selected_color[3])
691{
692 if (track->flag & TRACK_LOCKED) {
693 if (is_track_active) {
695 }
696 else if (is_area_selected) {
698 }
699 else {
701 }
702 }
703 else if (marker->flag & MARKER_DISABLED) {
704 if (is_track_active) {
706 }
707 else if (is_area_selected) {
709 }
710 else {
712 }
713 }
714 else {
715 immUniformColor3fv(is_area_selected ? selected_color : color);
716 }
717}
718
720 const MovieTrackingTrack *track,
721 const MovieTrackingMarker *marker,
722 const float marker_pos[2],
723 int width,
724 int height,
725 int act,
726 int sel,
727 const uint shdr_pos)
728{
729 int tiny = sc->flag & SC_SHOW_TINY_MARKER;
730 bool show_search = false;
731 float col[3], scol[3];
732 float px[2];
733
734 track_colors(track, act, col, scol);
735
736 px[0] = 1.0f / width / sc->zoom;
737 px[1] = 1.0f / height / sc->zoom;
738
739 GPU_line_width(1.0f);
740
741 /* Since we are switching solid and dashed lines in rather complex logic here,
742 * just always go with dashed shader. */
744
746
747 float viewport_size[4];
748 GPU_viewport_size_get_f(viewport_size);
749 immUniform2f("viewport_size", viewport_size[2] / UI_SCALE_FAC, viewport_size[3] / UI_SCALE_FAC);
750
751 immUniform1i("colors_len", 0); /* "simple" mode */
752
753 /* marker position and offset position */
754 if ((track->flag & SELECT) == sel && (marker->flag & MARKER_DISABLED) == 0) {
755 float pos[2], p[2];
756
757 if (track->flag & TRACK_LOCKED) {
758 if (act) {
760 }
761 else if (track->flag & SELECT) {
763 }
764 else {
766 }
767 }
768 else {
769 immUniformColor3fv((track->flag & SELECT) ? scol : col);
770 }
771
772 add_v2_v2v2(pos, marker->pos, track->offset);
774
775 sub_v2_v2v2(p, pos, marker_pos);
776
778 marker->pattern_corners[0],
779 marker->pattern_corners[1],
780 marker->pattern_corners[2],
781 marker->pattern_corners[3]))
782 {
783 GPU_point_size(tiny ? 1.0f : 2.0f);
784
785 immUniform1f("udash_factor", 2.0f); /* Solid "line" */
786
788 immVertex2f(shdr_pos, pos[0], pos[1]);
789 immEnd();
790 }
791 else {
792 immUniform1f("udash_factor", 2.0f); /* Solid line */
793
795
796 immVertex2f(shdr_pos, pos[0] + px[0] * 3, pos[1]);
797 immVertex2f(shdr_pos, pos[0] + px[0] * 7, pos[1]);
798
799 immVertex2f(shdr_pos, pos[0] - px[0] * 3, pos[1]);
800 immVertex2f(shdr_pos, pos[0] - px[0] * 7, pos[1]);
801
802 immVertex2f(shdr_pos, pos[0], pos[1] - px[1] * 3);
803 immVertex2f(shdr_pos, pos[0], pos[1] - px[1] * 7);
804
805 immVertex2f(shdr_pos, pos[0], pos[1] + px[1] * 3);
806 immVertex2f(shdr_pos, pos[0], pos[1] + px[1] * 7);
807
808 immEnd();
809
810 immUniformColor4f(1.0f, 1.0f, 1.0f, 0.0f);
811 immUniform1f("dash_width", 6.0f);
812 immUniform1f("udash_factor", 0.5f);
813
815
817 immVertex2fv(shdr_pos, pos);
818 immVertex2fv(shdr_pos, marker_pos);
819 immEnd();
820
822 }
823 }
824
825 /* pattern */
827 GPU_matrix_translate_2fv(marker_pos);
828
829 set_draw_marker_area_color(track, marker, act, track->pat_flag & SELECT, col, scol);
830
831 if (tiny) {
832 immUniform1f("dash_width", 6.0f);
833 immUniform1f("udash_factor", 0.5f);
834 }
835 else {
836 immUniform1f("udash_factor", 2.0f); /* Solid line */
837 }
838
839 if ((track->pat_flag & SELECT) == sel && (sc->flag & SC_SHOW_MARKER_PATTERN)) {
841 immVertex2fv(shdr_pos, marker->pattern_corners[0]);
842 immVertex2fv(shdr_pos, marker->pattern_corners[1]);
843 immVertex2fv(shdr_pos, marker->pattern_corners[2]);
844 immVertex2fv(shdr_pos, marker->pattern_corners[3]);
845 immEnd();
846 }
847
848 /* search */
849 show_search = (TRACK_VIEW_SELECTED(sc, track) && ((marker->flag & MARKER_DISABLED) == 0 ||
850 (sc->flag & SC_SHOW_MARKER_PATTERN) == 0)) !=
851 0;
852
853 if ((track->search_flag & SELECT) == sel && (sc->flag & SC_SHOW_MARKER_SEARCH) && show_search) {
854 set_draw_marker_area_color(track, marker, act, track->search_flag & SELECT, col, scol);
855
856 imm_draw_box_wire_2d(shdr_pos,
857 marker->search_min[0],
858 marker->search_min[1],
859 marker->search_max[0],
860 marker->search_max[1]);
861 }
862
864
865 /* Restore default shader */
867
870 BLI_assert(pos == shdr_pos);
872
874}
875
877{
878 float len_sq = FLT_MAX;
879
880 for (int i = 0; i < 4; i++) {
881 int next = (i + 1) % 4;
882 float cur_len = len_squared_v2v2(marker->pattern_corners[i], marker->pattern_corners[next]);
883 len_sq = min_ff(cur_len, len_sq);
884 }
885
886 return sqrtf(len_sq);
887}
888
890 float x, float y, float dx, float dy, int outline, const float px[2], uint pos)
891{
892 float tdx, tdy;
893
894 tdx = dx;
895 tdy = dy;
896
897 if (outline) {
898 tdx += px[0];
899 tdy += px[1];
900 }
901
902 immRectf(pos, x - tdx, y - tdy, x + tdx, y + tdy);
903}
904
906 float x, float y, float dx, float dy, int outline, const float px[2], uint pos)
907{
908 float tdx, tdy;
909
910 tdx = dx * 2.0f;
911 tdy = dy * 2.0f;
912
913 if (outline) {
914 tdx += px[0];
915 tdy += px[1];
916 }
917
919 immVertex2f(pos, x, y);
920 immVertex2f(pos, x - tdx, y);
921 immVertex2f(pos, x, y + tdy);
922 immEnd();
923}
924
926 const MovieTrackingTrack *track,
927 const MovieTrackingMarker *marker,
928 const float marker_pos[2],
929 int outline,
930 int sel,
931 int act,
932 int width,
933 int height,
934 uint pos)
935{
936 float dx, dy, patdx, patdy, searchdx, searchdy;
937 int tiny = sc->flag & SC_SHOW_TINY_MARKER;
938 float col[3], scol[3], px[2], side;
939
940 if ((tiny && outline) || (marker->flag & MARKER_DISABLED)) {
941 return;
942 }
943
944 if (!TRACK_VIEW_SELECTED(sc, track) || track->flag & TRACK_LOCKED) {
945 return;
946 }
947
948 track_colors(track, act, col, scol);
949
950 if (outline) {
952 }
953
955 GPU_matrix_translate_2fv(marker_pos);
956
957 dx = 6.0f / width / sc->zoom;
958 dy = 6.0f / height / sc->zoom;
959
960 side = get_shortest_pattern_side(marker);
961 patdx = min_ff(dx * 2.0f / 3.0f, side / 6.0f) * UI_SCALE_FAC;
962 patdy = min_ff(dy * 2.0f / 3.0f, side * width / height / 6.0f) * UI_SCALE_FAC;
963
964 searchdx = min_ff(dx, (marker->search_max[0] - marker->search_min[0]) / 6.0f) * UI_SCALE_FAC;
965 searchdy = min_ff(dy, (marker->search_max[1] - marker->search_min[1]) / 6.0f) * UI_SCALE_FAC;
966
967 px[0] = 1.0f / sc->zoom / width / sc->scale;
968 px[1] = 1.0f / sc->zoom / height / sc->scale;
969
970 if ((sc->flag & SC_SHOW_MARKER_SEARCH) && ((track->search_flag & SELECT) == sel || outline)) {
971 if (!outline) {
972 immUniformColor3fv((track->search_flag & SELECT) ? scol : col);
973 }
974
975 /* search offset square */
977 marker->search_min[0], marker->search_max[1], searchdx, searchdy, outline, px, pos);
978
979 /* search re-sizing triangle */
981 marker->search_max[0], marker->search_min[1], searchdx, searchdy, outline, px, pos);
982 }
983
984 if ((sc->flag & SC_SHOW_MARKER_PATTERN) && ((track->pat_flag & SELECT) == sel || outline)) {
985 float pat_min[2], pat_max[2];
986 // float dx = 12.0f / width, dy = 12.0f / height; /*UNUSED*/
987 float tilt_ctrl[2];
988
989 if (!outline) {
990 immUniformColor3fv((track->pat_flag & SELECT) ? scol : col);
991 }
992
993 /* pattern's corners sliding squares */
994 for (int i = 0; i < 4; i++) {
996 marker->pattern_corners[i][1],
997 patdx / 1.5f,
998 patdy / 1.5f,
999 outline,
1000 px,
1001 pos);
1002 }
1003
1004 /* ** sliders to control overall pattern ** */
1005 add_v2_v2v2(tilt_ctrl, marker->pattern_corners[1], marker->pattern_corners[2]);
1006
1007 BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max);
1008
1009 GPU_line_width(outline ? 3.0f : 1.0f);
1010
1012 immVertex2f(pos, 0.0f, 0.0f);
1013 immVertex2fv(pos, tilt_ctrl);
1014 immEnd();
1015
1016 /* slider to control pattern tilt */
1017 draw_marker_slide_square(tilt_ctrl[0], tilt_ctrl[1], patdx, patdy, outline, px, pos);
1018 }
1019
1021}
1022
1024 const MovieTrackingTrack *track,
1025 const MovieTrackingMarker *marker,
1026 const float marker_pos[2],
1027 int act,
1028 int width,
1029 int height,
1030 float zoomx,
1031 float zoomy)
1032{
1033 char str[128] = {0}, state[64] = {0};
1034 float dx = 0.0f, dy = 0.0f, fontsize, pos[3];
1035 uiStyle *style = static_cast<uiStyle *>(U.uistyles.first);
1036 int fontid = style->widget.uifont_id;
1037
1038 if (!TRACK_VIEW_SELECTED(sc, track)) {
1039 return;
1040 }
1041
1042 BLF_size(fontid, 11.0f * UI_SCALE_FAC);
1043 fontsize = BLF_height_max(fontid);
1044
1045 if (marker->flag & MARKER_DISABLED) {
1046 if (act) {
1048 }
1049 else {
1050 uchar color[4];
1052 BLF_color4ubv(fontid, color);
1053 }
1054 }
1055 else {
1057 }
1058
1059 if ((sc->flag & SC_SHOW_MARKER_SEARCH) &&
1060 ((marker->flag & MARKER_DISABLED) == 0 || (sc->flag & SC_SHOW_MARKER_PATTERN) == 0))
1061 {
1062 dx = marker->search_min[0];
1063 dy = marker->search_min[1];
1064 }
1065 else if (sc->flag & SC_SHOW_MARKER_PATTERN) {
1066 float pat_min[2], pat_max[2];
1067
1068 BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max);
1069 dx = pat_min[0];
1070 dy = pat_min[1];
1071 }
1072
1073 pos[0] = (marker_pos[0] + dx) * width;
1074 pos[1] = (marker_pos[1] + dy) * height;
1075 pos[2] = 0.0f;
1076
1077 mul_m4_v3(sc->stabmat, pos);
1078
1079 pos[0] = pos[0] * zoomx;
1080 pos[1] = pos[1] * zoomy - fontsize;
1081
1082 if (marker->flag & MARKER_DISABLED) {
1083 STRNCPY(state, "disabled");
1084 }
1085 else if (marker->framenr != ED_space_clip_get_clip_frame_number(sc)) {
1086 STRNCPY(state, "estimated");
1087 }
1088 else if (marker->flag & MARKER_TRACKED) {
1089 STRNCPY(state, "tracked");
1090 }
1091 else {
1092 STRNCPY(state, "keyframed");
1093 }
1094
1095 if (state[0]) {
1096 SNPRINTF(str, "%s: %s", track->name, state);
1097 }
1098 else {
1099 STRNCPY(str, track->name);
1100 }
1101
1102 BLF_position(fontid, pos[0], pos[1], 0.0f);
1103 BLF_draw(fontid, str, sizeof(str));
1104 pos[1] -= fontsize;
1105
1106 if (track->flag & TRACK_HAS_BUNDLE) {
1107 SNPRINTF(str, "Average error: %.2f px", track->error);
1108 BLF_position(fontid, pos[0], pos[1], 0.0f);
1109 BLF_draw(fontid, str, sizeof(str));
1110 pos[1] -= fontsize;
1111 }
1112
1113 if (track->flag & TRACK_LOCKED) {
1114 BLF_position(fontid, pos[0], pos[1], 0.0f);
1115 BLF_draw(fontid, "locked", 6);
1116 }
1117}
1118
1119static void plane_track_colors(bool is_active, float r_color[3], float r_selected_color[3])
1120{
1122
1123 UI_GetThemeColor3fv(is_active ? TH_ACT_MARKER : TH_SEL_MARKER, r_selected_color);
1124}
1125
1126static void getArrowEndPoint(const int width,
1127 const int height,
1128 const float zoom,
1129 const float start_corner[2],
1130 const float end_corner[2],
1131 float end_point[2])
1132{
1133 float direction[2];
1134 float max_length;
1135
1136 sub_v2_v2v2(direction, end_corner, start_corner);
1137
1138 direction[0] *= width;
1139 direction[1] *= height;
1140 max_length = normalize_v2(direction);
1141 mul_v2_fl(direction, min_ff(32.0f / zoom, max_length));
1142 direction[0] /= width;
1143 direction[1] /= height;
1144
1145 add_v2_v2v2(end_point, start_corner, direction);
1146}
1147
1148static void homogeneous_2d_to_gl_matrix(/*const*/ float matrix[3][3], float gl_matrix[4][4])
1149{
1150 gl_matrix[0][0] = matrix[0][0];
1151 gl_matrix[0][1] = matrix[0][1];
1152 gl_matrix[0][2] = 0.0f;
1153 gl_matrix[0][3] = matrix[0][2];
1154
1155 gl_matrix[1][0] = matrix[1][0];
1156 gl_matrix[1][1] = matrix[1][1];
1157 gl_matrix[1][2] = 0.0f;
1158 gl_matrix[1][3] = matrix[1][2];
1159
1160 gl_matrix[2][0] = 0.0f;
1161 gl_matrix[2][1] = 0.0f;
1162 gl_matrix[2][2] = 1.0f;
1163 gl_matrix[2][3] = 0.0f;
1164
1165 gl_matrix[3][0] = matrix[2][0];
1166 gl_matrix[3][1] = matrix[2][1];
1167 gl_matrix[3][2] = 0.0f;
1168 gl_matrix[3][3] = matrix[2][2];
1169}
1170
1172 MovieTrackingPlaneTrack *plane_track,
1173 MovieTrackingPlaneMarker *plane_marker)
1174{
1175 Image *image = plane_track->image;
1176 ImBuf *ibuf;
1177 void *lock;
1178
1179 if (image == nullptr) {
1180 return;
1181 }
1182
1183 ibuf = BKE_image_acquire_ibuf(image, nullptr, &lock);
1184
1185 if (ibuf) {
1186 void *cache_handle;
1187 uchar *display_buffer = IMB_display_buffer_acquire(
1188 ibuf, &scene->view_settings, &scene->display_settings, &cache_handle);
1189
1190 if (display_buffer) {
1191 float frame_corners[4][2] = {{0.0f, 0.0f}, {1.0f, 0.0f}, {1.0f, 1.0f}, {0.0f, 1.0f}};
1192 float perspective_matrix[3][3];
1193 float gl_matrix[4][4];
1194 bool transparent = false;
1196 frame_corners, plane_marker->corners, perspective_matrix);
1197
1198 homogeneous_2d_to_gl_matrix(perspective_matrix, gl_matrix);
1199
1200 if (plane_track->image_opacity != 1.0f || ibuf->planes == 32) {
1201 transparent = true;
1203 }
1204
1205 GPUTexture *texture = GPU_texture_create_2d("plane_marker_image",
1206 ibuf->x,
1207 ibuf->y,
1208 1,
1209 GPU_RGBA8,
1211 nullptr);
1212 GPU_texture_update(texture, GPU_DATA_UBYTE, display_buffer);
1213 GPU_texture_filter_mode(texture, false);
1214
1216 GPU_matrix_mul(gl_matrix);
1217
1218 GPUVertFormat *imm_format = immVertexFormat();
1220 uint texCoord = GPU_vertformat_attr_add(
1221 imm_format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
1222
1223 /* Use 3D image for correct display of planar tracked images. */
1225
1226 immBindTexture("image", texture);
1227 immUniformColor4f(1.0f, 1.0f, 1.0f, plane_track->image_opacity);
1228
1230
1231 immAttr2f(texCoord, 0.0f, 0.0f);
1232 immVertex3f(pos, 0.0f, 0.0f, 0.0f);
1233
1234 immAttr2f(texCoord, 1.0f, 0.0f);
1235 immVertex3f(pos, 1.0f, 0.0f, 0.0f);
1236
1237 immAttr2f(texCoord, 1.0f, 1.0f);
1238 immVertex3f(pos, 1.0f, 1.0f, 0.0f);
1239
1240 immAttr2f(texCoord, 0.0f, 1.0f);
1241 immVertex3f(pos, 0.0f, 1.0f, 0.0f);
1242
1243 immEnd();
1244
1246
1248
1249 GPU_texture_unbind(texture);
1250 GPU_texture_free(texture);
1251
1252 if (transparent) {
1254 }
1255 }
1256
1257 IMB_display_buffer_release(cache_handle);
1258 }
1259
1260 BKE_image_release_ibuf(image, ibuf, lock);
1261}
1262
1264 Scene *scene,
1265 MovieTrackingPlaneTrack *plane_track,
1266 MovieTrackingPlaneMarker *plane_marker,
1267 bool is_active_track,
1268 bool draw_outline,
1269 int width,
1270 int height)
1271{
1272 bool tiny = (sc->flag & SC_SHOW_TINY_MARKER) != 0;
1273 bool is_selected_track = (plane_track->flag & SELECT) != 0;
1274 const bool has_image = plane_track->image != nullptr &&
1275 BKE_image_has_ibuf(plane_track->image, nullptr);
1276 const bool draw_plane_quad = !has_image || plane_track->image_opacity == 0.0f;
1277 float px[2];
1278 float color[3], selected_color[3];
1279
1280 px[0] = 1.0f / width / sc->zoom;
1281 px[1] = 1.0f / height / sc->zoom;
1282
1283 /* Draw image */
1284 if (draw_outline == false) {
1285 draw_plane_marker_image(scene, plane_track, plane_marker);
1286 }
1287
1288 if (draw_plane_quad || is_selected_track) {
1289 const uint shdr_pos = GPU_vertformat_attr_add(
1291
1293
1294 float viewport_size[4];
1295 GPU_viewport_size_get_f(viewport_size);
1297 "viewport_size", viewport_size[2] / UI_SCALE_FAC, viewport_size[3] / UI_SCALE_FAC);
1298
1299 immUniform1i("colors_len", 0); /* "simple" mode */
1300
1301 if (is_selected_track) {
1302 plane_track_colors(is_active_track, color, selected_color);
1303 }
1304
1305 if (draw_plane_quad) {
1306 const bool stipple = !draw_outline && tiny;
1307 const bool thick = draw_outline && !tiny;
1308
1309 GPU_line_width(thick ? 3.0f : 1.0f);
1310
1311 if (stipple) {
1312 immUniform1f("dash_width", 6.0f);
1313 immUniform1f("udash_factor", 0.5f);
1314 }
1315 else {
1316 immUniform1f("udash_factor", 2.0f); /* Solid line */
1317 }
1318
1319 if (draw_outline) {
1321 }
1322 else {
1323 immUniformColor3fv(is_selected_track ? selected_color : color);
1324 }
1325
1326 /* Draw rectangle itself. */
1328 immVertex2fv(shdr_pos, plane_marker->corners[0]);
1329 immVertex2fv(shdr_pos, plane_marker->corners[1]);
1330 immVertex2fv(shdr_pos, plane_marker->corners[2]);
1331 immVertex2fv(shdr_pos, plane_marker->corners[3]);
1332 immEnd();
1333
1334 /* Draw axis. */
1335 if (!draw_outline) {
1336 float end_point[2];
1337
1338 immUniformColor3f(1.0f, 0.0f, 0.0f);
1339
1341
1342 getArrowEndPoint(width,
1343 height,
1344 sc->zoom,
1345 plane_marker->corners[0],
1346 plane_marker->corners[1],
1347 end_point);
1348 immVertex2fv(shdr_pos, plane_marker->corners[0]);
1349 immVertex2fv(shdr_pos, end_point);
1350
1351 immEnd();
1352
1353 immUniformColor3f(0.0f, 1.0f, 0.0f);
1354
1356
1357 getArrowEndPoint(width,
1358 height,
1359 sc->zoom,
1360 plane_marker->corners[0],
1361 plane_marker->corners[3],
1362 end_point);
1363 immVertex2fv(shdr_pos, plane_marker->corners[0]);
1364 immVertex2fv(shdr_pos, end_point);
1365
1366 immEnd();
1367 }
1368 }
1370
1371 /* Draw sliders. */
1372 if (is_selected_track) {
1374
1375 if (draw_outline) {
1377 }
1378 else {
1379 immUniformColor3fv(selected_color);
1380 }
1381
1382 for (int i = 0; i < 4; i++) {
1383 draw_marker_slide_square(plane_marker->corners[i][0],
1384 plane_marker->corners[i][1],
1385 3.0f * px[0],
1386 3.0f * px[1],
1387 draw_outline,
1388 px,
1389 shdr_pos);
1390 }
1392 }
1393 }
1394}
1395
1397 Scene *scene,
1398 MovieTrackingPlaneTrack *plane_track,
1399 MovieTrackingPlaneMarker *plane_marker,
1400 int width,
1401 int height)
1402{
1403 draw_plane_marker_ex(sc, scene, plane_track, plane_marker, false, true, width, height);
1404}
1405
1407 Scene *scene,
1408 MovieTrackingPlaneTrack *plane_track,
1409 MovieTrackingPlaneMarker *plane_marker,
1410 bool is_active_track,
1411 int width,
1412 int height)
1413{
1415 sc, scene, plane_track, plane_marker, is_active_track, false, width, height);
1416}
1417
1419 Scene *scene,
1420 MovieTrackingPlaneTrack *plane_track,
1421 int framenr,
1422 bool is_active_track,
1423 int width,
1424 int height)
1425{
1426 MovieTrackingPlaneMarker *plane_marker;
1427
1428 plane_marker = BKE_tracking_plane_marker_get(plane_track, framenr);
1429
1430 draw_plane_marker_outline(sc, scene, plane_track, plane_marker, width, height);
1431 draw_plane_marker(sc, scene, plane_track, plane_marker, is_active_track, width, height);
1432}
1433
1434/* Draw all kind of tracks. */
1436 Scene *scene,
1437 ARegion *region,
1438 MovieClip *clip,
1439 int width,
1440 int height,
1441 float zoomx,
1442 float zoomy)
1443{
1444 float x, y;
1445 /*const*/ MovieTracking *tracking = &clip->tracking;
1446 /*const*/ MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(tracking);
1447 /*const*/ MovieTrackingTrack *active_track = tracking_object->active_track;
1448 /*const*/ MovieTrackingPlaneTrack *active_plane_track = tracking_object->active_plane_track;
1449 const int framenr = ED_space_clip_get_clip_frame_number(sc);
1450 const int undistort = sc->user.render_flag & MCLIP_PROXY_RENDER_UNDISTORT;
1451 float *marker_pos = nullptr, *fp, *active_pos = nullptr, cur_pos[2];
1452
1453 /* ** find window pixel coordinates of origin ** */
1454
1455 /* UI_view2d_view_to_region_no_clip return integer values, this could
1456 * lead to 1px flickering when view is locked to selection during playback.
1457 * to avoid this flickering, calculate base point in the same way as it happens
1458 * in UI_view2d_view_to_region_no_clip, but do it in floats here */
1459
1460 UI_view2d_view_to_region_fl(&region->v2d, 0.0f, 0.0f, &x, &y);
1461
1464
1466 GPU_matrix_scale_2f(zoomx, zoomy);
1468 GPU_matrix_scale_2f(width, height);
1469
1470 /* Draw plane tracks */
1471 LISTBASE_FOREACH (MovieTrackingPlaneTrack *, plane_track, &tracking_object->plane_tracks) {
1472 if ((plane_track->flag & PLANE_TRACK_HIDDEN) == 0) {
1474 sc, scene, plane_track, framenr, plane_track == active_plane_track, width, height);
1475 }
1476 }
1477
1479 int count = 0;
1480
1481 /* count */
1482 LISTBASE_FOREACH (MovieTrackingTrack *, track, &tracking_object->tracks) {
1483 if (track->flag & TRACK_HIDDEN) {
1484 continue;
1485 }
1486
1487 const MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
1488
1489 if (ED_space_clip_marker_is_visible(sc, tracking_object, track, marker)) {
1490 count++;
1491 }
1492 }
1493
1494 /* undistort */
1495 if (count) {
1496 marker_pos = MEM_cnew_array<float>(2 * count, "draw_tracking_tracks marker_pos");
1497
1498 fp = marker_pos;
1499 LISTBASE_FOREACH (MovieTrackingTrack *, track, &tracking_object->tracks) {
1500 if (track->flag & TRACK_HIDDEN) {
1501 continue;
1502 }
1503
1504 const MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
1505
1506 if (ED_space_clip_marker_is_visible(sc, tracking_object, track, marker)) {
1507 ED_clip_point_undistorted_pos(sc, marker->pos, fp);
1508
1509 if (track == active_track) {
1510 active_pos = fp;
1511 }
1512
1513 fp += 2;
1514 }
1515 }
1516 }
1517 }
1518
1519 if (sc->flag & SC_SHOW_TRACK_PATH) {
1520 LISTBASE_FOREACH (MovieTrackingTrack *, track, &tracking_object->tracks) {
1521 if ((track->flag & TRACK_HIDDEN) == 0) {
1522 draw_track_path(sc, clip, track);
1523 }
1524 }
1525 }
1526
1527 const uint position = GPU_vertformat_attr_add(
1529
1531
1532 /* markers outline and non-selected areas */
1533 fp = marker_pos;
1534 LISTBASE_FOREACH (MovieTrackingTrack *, track, &tracking_object->tracks) {
1535 if (track->flag & TRACK_HIDDEN) {
1536 continue;
1537 }
1538
1539 const MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
1540
1541 if (ED_space_clip_marker_is_visible(sc, tracking_object, track, marker)) {
1542 copy_v2_v2(cur_pos, fp ? fp : marker->pos);
1543
1544 draw_marker_outline(sc, track, marker, cur_pos, width, height, position);
1545 draw_marker_areas(sc, track, marker, cur_pos, width, height, 0, 0, position);
1546 draw_marker_slide_zones(sc, track, marker, cur_pos, 1, 0, 0, width, height, position);
1547 draw_marker_slide_zones(sc, track, marker, cur_pos, 0, 0, 0, width, height, position);
1548
1549 if (fp) {
1550 fp += 2;
1551 }
1552 }
1553 }
1554
1555 /* selected areas only, so selection wouldn't be overlapped by non-selected areas */
1556 fp = marker_pos;
1557 LISTBASE_FOREACH (MovieTrackingTrack *, track, &tracking_object->tracks) {
1558 if (track->flag & TRACK_HIDDEN) {
1559 continue;
1560 }
1561 const int act = track == active_track;
1562 const MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
1563
1564 if (ED_space_clip_marker_is_visible(sc, tracking_object, track, marker)) {
1565 if (!act) {
1566 copy_v2_v2(cur_pos, fp ? fp : marker->pos);
1567
1568 draw_marker_areas(sc, track, marker, cur_pos, width, height, 0, 1, position);
1569 draw_marker_slide_zones(sc, track, marker, cur_pos, 0, 1, 0, width, height, position);
1570 }
1571
1572 if (fp) {
1573 fp += 2;
1574 }
1575 }
1576 }
1577
1578 /* active marker would be displayed on top of everything else */
1579 if (active_track && (active_track->flag & TRACK_HIDDEN) == 0) {
1580 const MovieTrackingMarker *marker = BKE_tracking_marker_get(active_track, framenr);
1581
1582 if (ED_space_clip_marker_is_visible(sc, tracking_object, active_track, marker)) {
1583 copy_v2_v2(cur_pos, active_pos ? active_pos : marker->pos);
1584
1585 draw_marker_areas(sc, active_track, marker, cur_pos, width, height, 1, 1, position);
1586 draw_marker_slide_zones(sc, active_track, marker, cur_pos, 0, 1, 1, width, height, position);
1587 }
1588 }
1589
1590 if (sc->flag & SC_SHOW_BUNDLES) {
1591 float pos[4], vec[4], mat[4][4], aspy;
1592
1593 GPU_point_size(3.0f);
1594
1595 aspy = 1.0f / clip->tracking.camera.pixel_aspect;
1596 BKE_tracking_get_projection_matrix(tracking, tracking_object, framenr, width, height, mat);
1597
1598 LISTBASE_FOREACH (MovieTrackingTrack *, track, &tracking_object->tracks) {
1599 if (track->flag & TRACK_HIDDEN || (track->flag & TRACK_HAS_BUNDLE) == 0) {
1600 continue;
1601 }
1602
1603 const MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
1604
1605 if (ED_space_clip_marker_is_visible(sc, tracking_object, track, marker)) {
1606 float npos[2];
1607 copy_v3_v3(vec, track->bundle_pos);
1608 vec[3] = 1;
1609
1610 mul_v4_m4v4(pos, mat, vec);
1611
1612 pos[0] = (pos[0] / (pos[3] * 2.0f) + 0.5f) * width;
1613 pos[1] = (pos[1] / (pos[3] * 2.0f) + 0.5f) * height * aspy;
1614
1615 BKE_tracking_distort_v2(tracking, width, height, pos, npos);
1616
1617 if (npos[0] >= 0.0f && npos[1] >= 0.0f && npos[0] <= width && npos[1] <= height * aspy) {
1618 vec[0] = (marker->pos[0] + track->offset[0]) * width;
1619 vec[1] = (marker->pos[1] + track->offset[1]) * height * aspy;
1620
1621 sub_v2_v2(vec, npos);
1622
1623 if (len_squared_v2(vec) < (3.0f * 3.0f)) {
1624 immUniformColor3f(0.0f, 1.0f, 0.0f);
1625 }
1626 else {
1627 immUniformColor3f(1.0f, 0.0f, 0.0f);
1628 }
1629
1631
1632 if (undistort) {
1633 immVertex2f(position, pos[0] / width, pos[1] / (height * aspy));
1634 }
1635 else {
1636 immVertex2f(position, npos[0] / width, npos[1] / (height * aspy));
1637 }
1638
1639 immEnd();
1640 }
1641 }
1642 }
1643 }
1644
1646
1648
1649 if (sc->flag & SC_SHOW_NAMES) {
1650 /* scaling should be cleared before drawing texts, otherwise font would also be scaled */
1651 fp = marker_pos;
1652 LISTBASE_FOREACH (MovieTrackingTrack *, track, &tracking_object->tracks) {
1653 if (track->flag & TRACK_HIDDEN) {
1654 continue;
1655 }
1656
1657 const MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
1658
1659 if (ED_space_clip_marker_is_visible(sc, tracking_object, track, marker)) {
1660 const int act = track == active_track;
1661
1662 copy_v2_v2(cur_pos, fp ? fp : marker->pos);
1663
1664 draw_marker_texts(sc, track, marker, cur_pos, act, width, height, zoomx, zoomy);
1665
1666 if (fp) {
1667 fp += 2;
1668 }
1669 }
1670 }
1671 }
1672
1674
1675 if (marker_pos) {
1676 MEM_freeN(marker_pos);
1677 }
1678}
1679
1681 ARegion *region,
1682 MovieClip *clip,
1683 int width,
1684 int height,
1685 float zoomx,
1686 float zoomy)
1687{
1688 float x, y;
1689 const int n = 10;
1690 float tpos[2], grid[11][11][2];
1691 MovieTracking *tracking = &clip->tracking;
1692 bGPdata *gpd = nullptr;
1693 float aspy = 1.0f / tracking->camera.pixel_aspect;
1694 float dx = float(width) / n, dy = float(height) / n * aspy;
1695 float offsx = 0.0f, offsy = 0.0f;
1696
1697 if (!tracking->camera.focal) {
1698 return;
1699 }
1700
1701 if ((sc->flag & SC_SHOW_GRID) == 0 && (sc->flag & SC_MANUAL_CALIBRATION) == 0) {
1702 return;
1703 }
1704
1705 UI_view2d_view_to_region_fl(&region->v2d, 0.0f, 0.0f, &x, &y);
1706
1709 GPU_matrix_scale_2f(zoomx, zoomy);
1711 GPU_matrix_scale_2f(width, height);
1712
1713 uint position = GPU_vertformat_attr_add(
1715
1717
1718 /* grid */
1719 if (sc->flag & SC_SHOW_GRID) {
1720 float val[4][2], idx[4][2];
1721 float min[2], max[2];
1722
1723 for (int a = 0; a < 4; a++) {
1724 if (a < 2) {
1725 val[a][a % 2] = FLT_MAX;
1726 }
1727 else {
1728 val[a][a % 2] = -FLT_MAX;
1729 }
1730 }
1731
1732 for (int i = 0; i <= n; i++) {
1733 for (int j = 0; j <= n; j++) {
1734 if (i == 0 || j == 0 || i == n || j == n) {
1735 const float pos[2] = {dx * j, dy * i};
1736 BKE_tracking_distort_v2(tracking, width, height, pos, tpos);
1737
1738 for (int a = 0; a < 4; a++) {
1739 int ok;
1740
1741 if (a < 2) {
1742 ok = tpos[a % 2] < val[a][a % 2];
1743 }
1744 else {
1745 ok = tpos[a % 2] > val[a][a % 2];
1746 }
1747
1748 if (ok) {
1749 copy_v2_v2(val[a], tpos);
1750 idx[a][0] = j;
1751 idx[a][1] = i;
1752 }
1753 }
1754 }
1755 }
1756 }
1757
1758 INIT_MINMAX2(min, max);
1759
1760 for (int a = 0; a < 4; a++) {
1761 const float pos[2] = {idx[a][0] * dx, idx[a][1] * dy};
1762
1763 BKE_tracking_undistort_v2(tracking, width, height, pos, tpos);
1764
1765 minmax_v2v2_v2(min, max, tpos);
1766 }
1767
1768 dx = (max[0] - min[0]) / n;
1769 dy = (max[1] - min[1]) / n;
1770
1771 for (int i = 0; i <= n; i++) {
1772 for (int j = 0; j <= n; j++) {
1773 const float pos[2] = {min[0] + dx * j, min[1] + dy * i};
1774
1775 BKE_tracking_distort_v2(tracking, width, height, pos, grid[i][j]);
1776
1777 grid[i][j][0] /= width;
1778 grid[i][j][1] /= height * aspy;
1779 }
1780 }
1781
1782 immUniformColor3f(1.0f, 0.0f, 0.0f);
1783
1784 for (int i = 0; i <= n; i++) {
1786
1787 for (int j = 0; j <= n; j++) {
1788 immVertex2fv(position, grid[i][j]);
1789 }
1790
1791 immEnd();
1792 }
1793
1794 for (int j = 0; j <= n; j++) {
1796
1797 for (int i = 0; i <= n; i++) {
1798 immVertex2fv(position, grid[i][j]);
1799 }
1800
1801 immEnd();
1802 }
1803 }
1804
1805 if (sc->gpencil_src != SC_GPENCIL_SRC_TRACK) {
1806 gpd = clip->gpd;
1807 }
1808
1809 if (sc->flag & SC_MANUAL_CALIBRATION && gpd) {
1810 bGPDlayer *layer = static_cast<bGPDlayer *>(gpd->layers.first);
1811
1812 while (layer) {
1813 bGPDframe *frame = static_cast<bGPDframe *>(layer->frames.first);
1814
1815 if (layer->flag & GP_LAYER_HIDE) {
1816 layer = layer->next;
1817 continue;
1818 }
1819
1820 immUniformColor4fv(layer->color);
1821
1822 GPU_line_width(layer->thickness);
1823 GPU_point_size(float(layer->thickness + 2));
1824
1825 while (frame) {
1826 bGPDstroke *stroke = static_cast<bGPDstroke *>(frame->strokes.first);
1827
1828 while (stroke) {
1829 if (stroke->flag & GP_STROKE_2DSPACE) {
1830 if (stroke->totpoints > 1) {
1831 for (int i = 0; i < stroke->totpoints - 1; i++) {
1832 float pos[2], npos[2], dpos[2], len;
1833 int steps;
1834
1835 pos[0] = (stroke->points[i].x + offsx) * width;
1836 pos[1] = (stroke->points[i].y + offsy) * height * aspy;
1837
1838 npos[0] = (stroke->points[i + 1].x + offsx) * width;
1839 npos[1] = (stroke->points[i + 1].y + offsy) * height * aspy;
1840
1841 len = len_v2v2(pos, npos);
1842 steps = ceil(len / 5.0f);
1843
1844 /* we want to distort only long straight lines */
1845 if (stroke->totpoints == 2) {
1846 BKE_tracking_undistort_v2(tracking, width, height, pos, pos);
1847 BKE_tracking_undistort_v2(tracking, width, height, npos, npos);
1848 }
1849
1850 sub_v2_v2v2(dpos, npos, pos);
1851 mul_v2_fl(dpos, 1.0f / steps);
1852
1854
1855 for (int j = 0; j <= steps; j++) {
1856 BKE_tracking_distort_v2(tracking, width, height, pos, tpos);
1857 immVertex2f(position, tpos[0] / width, tpos[1] / (height * aspy));
1858
1859 add_v2_v2(pos, dpos);
1860 }
1861
1862 immEnd();
1863 }
1864 }
1865 else if (stroke->totpoints == 1) {
1867 immVertex2f(position, stroke->points[0].x + offsx, stroke->points[0].y + offsy);
1868 immEnd();
1869 }
1870 }
1871
1872 stroke = stroke->next;
1873 }
1874
1875 frame = frame->next;
1876 }
1877
1878 layer = layer->next;
1879 }
1880 }
1881
1883
1885}
1886
1887void clip_draw_main(const bContext *C, SpaceClip *sc, ARegion *region)
1888{
1890 Scene *scene = CTX_data_scene(C);
1891 ImBuf *ibuf = nullptr;
1892 int width, height;
1893 float zoomx, zoomy;
1894
1895 ED_space_clip_get_size(sc, &width, &height);
1896 ED_space_clip_get_zoom(sc, region, &zoomx, &zoomy);
1897
1898 /* if no clip, nothing to do */
1899 if (!clip) {
1900 ED_region_grid_draw(region, zoomx, zoomy, 0.0f, 0.0f);
1901 return;
1902 }
1903
1904 if (sc->flag & SC_SHOW_STABLE) {
1905 float translation[2];
1906 float aspect = clip->tracking.camera.pixel_aspect;
1907 float smat[4][4], ismat[4][4];
1908
1909 if ((sc->flag & SC_MUTE_FOOTAGE) == 0) {
1910 ibuf = ED_space_clip_get_stable_buffer(sc, sc->loc, &sc->scale, &sc->angle);
1911 }
1912
1913 if (ibuf != nullptr && width != ibuf->x) {
1914 mul_v2_v2fl(translation, sc->loc, float(width) / ibuf->x);
1915 }
1916 else {
1917 copy_v2_v2(translation, sc->loc);
1918 }
1919
1921 width, height, aspect, translation, sc->scale, sc->angle, sc->stabmat);
1922
1923 unit_m4(smat);
1924 smat[0][0] = 1.0f / width;
1925 smat[1][1] = 1.0f / height;
1926 invert_m4_m4(ismat, smat);
1927
1928 mul_m4_series(sc->unistabmat, smat, sc->stabmat, ismat);
1929 }
1930 else if ((sc->flag & SC_MUTE_FOOTAGE) == 0) {
1931 ibuf = ED_space_clip_get_buffer(sc);
1932
1933 zero_v2(sc->loc);
1934 sc->scale = 1.0f;
1935 unit_m4(sc->stabmat);
1936 unit_m4(sc->unistabmat);
1937 }
1938
1939 if (ibuf) {
1940 draw_movieclip_buffer(C, sc, region, ibuf, width, height, zoomx, zoomy);
1941 IMB_freeImBuf(ibuf);
1942 }
1943 else if (sc->flag & SC_MUTE_FOOTAGE) {
1944 draw_movieclip_muted(region, width, height, zoomx, zoomy);
1945 }
1946 else {
1947 ED_region_grid_draw(region, zoomx, zoomy, 0.0f, 0.0f);
1948 }
1949
1950 if (width && height) {
1951 draw_stabilization_border(sc, region, width, height, zoomx, zoomy);
1952 draw_tracking_tracks(sc, scene, region, clip, width, height, zoomx, zoomy);
1953 draw_distortion(sc, region, clip, width, height, zoomx, zoomy);
1954 }
1955}
1956
1958{
1959 Scene *scene = CTX_data_scene(C);
1961 if (clip) {
1962 draw_movieclip_cache(sc, region, clip, scene);
1963 draw_movieclip_notes(sc, region);
1964 }
1965}
1966
1968{
1971
1972 if (!clip) {
1973 return;
1974 }
1975
1976 if (onlyv2d) {
1977 bool is_track_source = sc->gpencil_src == SC_GPENCIL_SRC_TRACK;
1978 /* if manual calibration is used then grease pencil data
1979 * associated with the clip is already drawn in draw_distortion
1980 */
1981 if ((sc->flag & SC_MANUAL_CALIBRATION) == 0 || is_track_source) {
1984
1985 if (is_track_source) {
1986 const MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(
1987 &clip->tracking);
1988 MovieTrackingTrack *active_track = tracking_object->active_track;
1989
1990 if (active_track) {
1991 const int framenr = ED_space_clip_get_clip_frame_number(sc);
1992 MovieTrackingMarker *marker = BKE_tracking_marker_get(active_track, framenr);
1993
1995 }
1996 }
1997
1999
2001 }
2002 }
2003 else {
2004 ED_annotation_draw_view2d(C, false);
2005 }
2006}
void ED_draw_imbuf_ctx(const bContext *C, ImBuf *ibuf, float x, float y, bool use_filter, float zoom_x, float zoom_y)
Definition glutil.cc:603
Scene * CTX_data_scene(const bContext *C)
SpaceClip * CTX_wm_space_clip(const bContext *C)
ImBuf * BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **r_lock)
void BKE_image_release_ibuf(Image *ima, ImBuf *ibuf, void *lock)
bool BKE_image_has_ibuf(Image *ima, ImageUser *iuser)
void BKE_movieclip_get_cache_segments(struct MovieClip *clip, const struct MovieClipUser *user, int *r_totseg, int **r_points)
void BKE_tracking_stabilization_data_to_mat4(int width, int height, float aspect, float translation[2], float scale, float angle, float mat[4][4])
struct MovieTrackingMarker * BKE_tracking_marker_get(struct MovieTrackingTrack *track, int framenr)
Definition tracking.cc:1358
struct MovieTrackingObject * BKE_tracking_object_get_active(const struct MovieTracking *tracking)
struct MovieTrackingMarker * BKE_tracking_marker_get_exact(struct MovieTrackingTrack *track, int framenr)
Definition tracking.cc:1391
void BKE_tracking_distort_v2(struct MovieTracking *tracking, int image_width, int image_height, const float co[2], float r_co[2])
Definition tracking.cc:2421
#define TRACK_VIEW_SELECTED(sc, track)
void BKE_tracking_marker_pattern_minmax(const struct MovieTrackingMarker *marker, float min[2], float max[2])
struct MovieTrackingPlaneMarker * BKE_tracking_plane_marker_get(struct MovieTrackingPlaneTrack *plane_track, int framenr)
Definition tracking.cc:1791
void BKE_tracking_get_projection_matrix(struct MovieTracking *tracking, struct MovieTrackingObject *tracking_object, int framenr, int winx, int winy, float mat[4][4])
Definition tracking.cc:386
void BKE_tracking_undistort_v2(struct MovieTracking *tracking, int image_width, int image_height, const float co[2], float r_co[2])
Definition tracking.cc:2448
void BKE_tracking_homography_between_two_quads(float reference_corners[4][2], float corners[4][2], float H[3][3])
void BLF_size(int fontid, float size)
Definition blf.cc:426
void BLF_draw(int fontid, const char *str, size_t str_len, ResultBLF *r_info=nullptr) ATTR_NONNULL(2)
Definition blf.cc:568
int BLF_height_max(int fontid) ATTR_WARN_UNUSED_RESULT
Definition blf.cc:828
void BLF_color4ubv(int fontid, const unsigned char rgba[4])
Definition blf.cc:435
void BLF_position(int fontid, float x, float y, float z)
Definition blf.cc:371
#define BLI_assert(a)
Definition BLI_assert.h:50
#define LISTBASE_FOREACH(type, var, list)
MINLINE int min_ii(int a, int b)
MINLINE float min_ff(float a, float b)
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])
void mul_v4_m4v4(float r[4], const float mat[4][4], const float v[4])
void unit_m4(float m[4][4])
Definition rct.c:1127
void mul_m4_v3(const float M[4][4], float r[3])
#define mul_m4_series(...)
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
MINLINE float len_squared_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT
MINLINE float len_squared_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void sub_v2_v2(float r[2], const float a[2])
MINLINE float len_v2v2(const float v1[2], const float v2[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void mul_v2_fl(float r[2], float f)
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void copy_v3_v3(float r[3], const float a[3])
void minmax_v2v2_v2(float min[2], float max[2], const float vec[2])
MINLINE void add_v2_v2(float r[2], const float a[2])
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 void zero_v2(float r[2])
MINLINE float normalize_v2(float n[2])
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
MINLINE void mul_v2_v2fl(float r[2], const float a[2], float f)
void BLI_rctf_init(struct rctf *rect, float xmin, float xmax, float ymin, float ymax)
Definition rct.c:408
#define STRNCPY(dst, src)
Definition BLI_string.h:593
#define SNPRINTF(dst, format,...)
Definition BLI_string.h:597
unsigned char uchar
unsigned int uint
#define INIT_MINMAX2(min, max)
#define UNUSED_VARS_NDEBUG(...)
#define ELEM(...)
@ MCLIP_PROXY_RENDER_SIZE_100
@ MCLIP_PROXY_RENDER_SIZE_FULL
@ MCLIP_PROXY_RENDER_UNDISTORT
@ MCLIP_USE_PROXY
@ SC_MODE_MASKEDIT
@ SC_SHOW_MARKER_SEARCH
@ SC_SHOW_NAMES
@ SC_SHOW_TINY_MARKER
@ SC_LOCK_SELECTION
@ SC_SHOW_METADATA
@ SC_SHOW_GRID
@ SC_SHOW_STABLE
@ SC_MUTE_FOOTAGE
@ SC_SHOW_BUNDLES
@ SC_SHOW_MARKER_PATTERN
@ SC_MANUAL_CALIBRATION
@ SC_SHOW_TRACK_PATH
@ SC_GPENCIL_SRC_TRACK
@ TRACKING_2D_STABILIZATION
@ TRACK_CUSTOMCOLOR
@ TRACK_HIDDEN
@ TRACK_LOCKED
@ TRACK_HAS_BUNDLE
@ PLANE_MARKER_TRACKED
@ TRACKING_RECONSTRUCTED
@ PLANE_TRACK_HIDDEN
@ MARKER_TRACKED
@ MARKER_DISABLED
#define UI_SCALE_FAC
MovieClip * ED_space_clip_get_clip(const SpaceClip *sc)
void ED_space_clip_get_size(const SpaceClip *sc, int *r_width, int *r_height)
void ED_space_clip_get_zoom(const SpaceClip *sc, const ARegion *region, float *r_zoomx, float *r_zoomy)
int ED_space_clip_get_clip_frame_number(const SpaceClip *sc)
void ED_clip_point_undistorted_pos(const SpaceClip *sc, const float co[2], float r_co[2])
ImBuf * ED_space_clip_get_buffer(const SpaceClip *sc)
ImBuf * ED_space_clip_get_stable_buffer(const SpaceClip *sc, float loc[2], float *scale, float *angle)
void ED_mask_draw_frames(Mask *mask, ARegion *region, int cfra, int sfra, int efra)
Definition mask_draw.cc:771
void ED_region_info_draw(ARegion *region, const char *text, const float fill_color[4], bool full_redraw)
Definition area.cc:3838
void ED_region_cache_draw_cached_segments(ARegion *region, int num_segments, const int *points, int sfra, int efra)
Definition area.cc:4060
void ED_region_cache_draw_background(ARegion *region)
Definition area.cc:4021
void ED_region_cache_draw_curfra_label(int framenr, float x, float y)
Definition area.cc:4035
void ED_region_grid_draw(ARegion *region, float zoomx, float zoomy, float x0, float y0)
Definition area.cc:3866
void ED_region_image_metadata_draw(int x, int y, ImBuf *ibuf, const rctf *frame, float zoomx, float zoomy)
Definition ed_draw.cc:876
void immEnd()
void immUnbindProgram()
void immUniform2f(const char *name, float x, float y)
void immUniformColor4f(float r, float g, float b, float a)
void immVertex2f(uint attr_id, float x, float y)
void immUniformThemeColor(int color_id)
void immUniformThemeColorShade(int color_id, int offset)
void immBindBuiltinProgram(eGPUBuiltinShader shader_id)
void immBindTexture(const char *name, GPUTexture *tex)
void immVertex3f(uint attr_id, float x, float y, float z)
void immVertex2fv(uint attr_id, const float data[2])
void immUniform1i(const char *name, int x)
void immBeginAtMost(GPUPrimType, uint max_vertex_len)
void immVertex2i(uint attr_id, int x, int y)
void immUniform1f(const char *name, float x)
void immUniformColor4ub(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
GPUVertFormat * immVertexFormat()
void immUniformColor4fv(const float rgba[4])
void immUniformColor3f(float r, float g, float b)
void immAttr2f(uint attr_id, float x, float y)
void immBegin(GPUPrimType, uint vertex_len)
void immUniformColor3fv(const float rgb[3])
void imm_draw_box_wire_2d(uint pos, float x1, float y1, float x2, float y2)
void imm_draw_box_checker_2d(float x1, float y1, float x2, float y2)
void immRecti(uint pos, int x1, int y1, int x2, int y2)
void immRectf(uint pos, float x1, float y1, float x2, float y2)
void GPU_matrix_translate_2fv(const float vec[2])
void GPU_matrix_scale_2f(float x, float y)
void GPU_matrix_push()
#define GPU_matrix_mul(x)
void GPU_matrix_pop()
void GPU_matrix_translate_2f(float x, float y)
@ GPU_PRIM_TRI_FAN
@ GPU_PRIM_LINE_LOOP
@ GPU_PRIM_LINES
@ GPU_PRIM_POINTS
@ GPU_PRIM_LINE_STRIP
@ GPU_PRIM_TRIS
@ GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR
@ GPU_SHADER_3D_UNIFORM_COLOR
@ GPU_SHADER_3D_IMAGE_COLOR
@ GPU_BLEND_NONE
Definition GPU_state.hh:85
@ GPU_BLEND_ALPHA
Definition GPU_state.hh:87
void GPU_blend(eGPUBlend blend)
Definition gpu_state.cc:42
void GPU_line_width(float width)
Definition gpu_state.cc:161
void GPU_logic_op_xor_set(bool enable)
Definition gpu_state.cc:88
void GPU_point_size(float size)
Definition gpu_state.cc:167
void GPU_viewport_size_get_f(float coords[4])
Definition gpu_state.cc:262
GPUTexture * GPU_texture_create_2d(const char *name, int width, int height, int mip_len, eGPUTextureFormat format, eGPUTextureUsage usage, const float *data)
void GPU_texture_free(GPUTexture *texture)
void GPU_texture_unbind(GPUTexture *texture)
@ GPU_DATA_UBYTE
@ GPU_TEXTURE_USAGE_SHADER_READ
void GPU_texture_filter_mode(GPUTexture *texture, bool use_filter)
void GPU_texture_update(GPUTexture *texture, eGPUDataFormat data_format, const void *data)
@ GPU_FETCH_FLOAT
@ GPU_FETCH_INT_TO_FLOAT
uint GPU_vertformat_attr_add(GPUVertFormat *, const char *name, GPUVertCompType, uint comp_len, GPUVertFetchMode)
@ GPU_COMP_F32
@ GPU_COMP_I32
unsigned char * IMB_display_buffer_acquire(ImBuf *ibuf, const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings, void **cache_handle)
void IMB_display_buffer_release(void *cache_handle)
Contains defines and structs used throughout the imbuf module.
Read Guarded memory(de)allocation.
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Brightness Control the brightness and contrast of the input color Vector Map input vector components with curves Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert Invert a color
void UI_GetThemeColor3fv(int colorid, float col[3])
@ TH_PATH_BEFORE
@ TH_MARKER_OUTLINE
@ TH_LOCK_MARKER
@ TH_PATH_AFTER
@ TH_DIS_MARKER
@ TH_CFRAME
@ TH_MARKER
@ TH_ACT_MARKER
@ TH_PATH_KEYFRAME_AFTER
@ TH_SEL_MARKER
@ TH_PATH_KEYFRAME_BEFORE
void UI_GetThemeColorShade4ubv(int colorid, int offset, unsigned char col[4])
void UI_FontThemeColor(int fontid, int colorid)
void UI_view2d_view_to_region_fl(const View2D *v2d, float x, float y, float *r_region_x, float *r_region_y) ATTR_NONNULL()
Definition view2d.cc:1734
void UI_view2d_view_to_region(const View2D *v2d, float x, float y, int *r_region_x, int *r_region_y) ATTR_NONNULL()
Definition view2d.cc:1718
void ED_annotation_draw_2dimage(const bContext *C)
void ED_annotation_draw_view2d(const bContext *C, bool onlyv2d)
volatile int lock
unsigned int U
Definition btGjkEpa3.h:78
static bool generic_track_is_marker_enabled(const MovieTrackingTrack *track, const MovieTrackingPlaneTrack *plane_track, const int marker_index)
Definition clip_draw.cc:98
static bool generic_track_is_marker_keyframed(const MovieTrackingTrack *track, const MovieTrackingPlaneTrack *plane_track, const int marker_index)
Definition clip_draw.cc:113
void clip_draw_cache_and_notes(const bContext *C, SpaceClip *sc, ARegion *region)
static void draw_movieclip_notes(SpaceClip *sc, ARegion *region)
Definition clip_draw.cc:261
static void draw_marker_slide_zones(SpaceClip *sc, const MovieTrackingTrack *track, const MovieTrackingMarker *marker, const float marker_pos[2], int outline, int sel, int act, int width, int height, uint pos)
Definition clip_draw.cc:925
static void draw_marker_outline(SpaceClip *sc, const MovieTrackingTrack *track, const MovieTrackingMarker *marker, const float marker_pos[2], int width, int height, uint position)
Definition clip_draw.cc:573
static void draw_movieclip_cache(SpaceClip *sc, ARegion *region, MovieClip *clip, Scene *scene)
Definition clip_draw.cc:129
static void draw_marker_texts(SpaceClip *sc, const MovieTrackingTrack *track, const MovieTrackingMarker *marker, const float marker_pos[2], int act, int width, int height, float zoomx, float zoomy)
static void draw_movieclip_muted(ARegion *region, int width, int height, float zoomx, float zoomy)
Definition clip_draw.cc:284
static void draw_track_path_points(const TrackPathPoint *path, uint position_attribute, const int start_point, const int num_points)
Definition clip_draw.cc:443
static void draw_plane_marker(SpaceClip *sc, Scene *scene, MovieTrackingPlaneTrack *plane_track, MovieTrackingPlaneMarker *plane_marker, bool is_active_track, int width, int height)
static void getArrowEndPoint(const int width, const int height, const float zoom, const float start_corner[2], const float end_corner[2], float end_point[2])
static void draw_marker_areas(SpaceClip *sc, const MovieTrackingTrack *track, const MovieTrackingMarker *marker, const float marker_pos[2], int width, int height, int act, int sel, const uint shdr_pos)
Definition clip_draw.cc:719
@ PATH_POINT_FLAG_KEYFRAME
Definition clip_draw.cc:391
static void draw_marker_slide_triangle(float x, float y, float dx, float dy, int outline, const float px[2], uint pos)
Definition clip_draw.cc:905
static float get_shortest_pattern_side(const MovieTrackingMarker *marker)
Definition clip_draw.cc:876
static void draw_track_path_keyframe_points(const TrackPathPoint *path, uint position_attribute, const int start_point, const int num_points)
Definition clip_draw.cc:459
void clip_draw_main(const bContext *C, SpaceClip *sc, ARegion *region)
static int track_to_path_segment(SpaceClip *sc, MovieTrackingTrack *track, int direction, TrackPathPoint *path)
Definition clip_draw.cc:412
#define MAX_STATIC_PATH
static void set_draw_marker_area_color(const MovieTrackingTrack *track, const MovieTrackingMarker *marker, const bool is_track_active, const bool is_area_selected, const float color[3], const float selected_color[3])
Definition clip_draw.cc:685
static void draw_plane_marker_ex(SpaceClip *sc, Scene *scene, MovieTrackingPlaneTrack *plane_track, MovieTrackingPlaneMarker *plane_marker, bool is_active_track, bool draw_outline, int width, int height)
static void draw_plane_track(SpaceClip *sc, Scene *scene, MovieTrackingPlaneTrack *plane_track, int framenr, bool is_active_track, int width, int height)
static void marker_to_path_point(SpaceClip *sc, const MovieTrackingTrack *track, const MovieTrackingMarker *marker, TrackPathPoint *point)
Definition clip_draw.cc:399
static void plane_track_colors(bool is_active, float r_color[3], float r_selected_color[3])
static void draw_distortion(SpaceClip *sc, ARegion *region, MovieClip *clip, int width, int height, float zoomx, float zoomy)
static void draw_track_path(SpaceClip *sc, MovieClip *, MovieTrackingTrack *track)
Definition clip_draw.cc:490
static void draw_tracking_tracks(SpaceClip *sc, Scene *scene, ARegion *region, MovieClip *clip, int width, int height, float zoomx, float zoomy)
static int generic_track_get_marker_framenr(const MovieTrackingTrack *track, const MovieTrackingPlaneTrack *plane_track, const int marker_index)
Definition clip_draw.cc:82
static void draw_keyframe(int frame, int cfra, int sfra, float framelen, int width, uint pos)
Definition clip_draw.cc:53
static void draw_movieclip_buffer(const bContext *C, SpaceClip *sc, ARegion *region, ImBuf *ibuf, int width, int height, float zoomx, float zoomy)
Definition clip_draw.cc:300
void clip_draw_grease_pencil(bContext *C, int onlyv2d)
static void draw_stabilization_border(SpaceClip *sc, ARegion *region, int width, int height, float zoomx, float zoomy)
Definition clip_draw.cc:344
static void draw_marker_slide_square(float x, float y, float dx, float dy, int outline, const float px[2], uint pos)
Definition clip_draw.cc:889
static void draw_track_path_lines(const TrackPathPoint *path, uint position_attribute, const int start_point, const int num_points)
Definition clip_draw.cc:474
static void homogeneous_2d_to_gl_matrix(float matrix[3][3], float gl_matrix[4][4])
static void draw_plane_marker_image(Scene *scene, MovieTrackingPlaneTrack *plane_track, MovieTrackingPlaneMarker *plane_marker)
static void track_colors(const MovieTrackingTrack *track, int act, float r_col[3], float r_scol[3])
Definition clip_draw.cc:661
static int generic_track_get_markersnr(const MovieTrackingTrack *track, const MovieTrackingPlaneTrack *plane_track)
Definition clip_draw.cc:69
static void draw_plane_marker_outline(SpaceClip *sc, Scene *scene, MovieTrackingPlaneTrack *plane_track, MovieTrackingPlaneMarker *plane_marker, int width, int height)
BLI_INLINE bool ED_space_clip_marker_is_visible(const SpaceClip *space_clip, const MovieTrackingObject *tracking_object, const MovieTrackingTrack *track, const MovieTrackingMarker *marker)
#define SELECT
#define ceilf(x)
#define sqrtf(x)
int len
draw_view in_light_buf[] float
RAYTRACE_GROUP_SIZE additional_info("eevee_shared", "eevee_gbuffer_data", "eevee_global_ubo", "eevee_sampling_data", "eevee_utility_texture", "eevee_hiz_data", "draw_view") .specialization_constant(Type RAYTRACE_GROUP_SIZE in_sh_0_tx in_sh_2_tx screen_normal_tx GPU_RGBA8
#define str(s)
uint col
void IMB_freeImBuf(ImBuf *)
int count
const ProjectiveReconstruction & reconstruction
Definition intersect.cc:198
void MEM_freeN(void *vmemh)
Definition mallocn.cc:105
ccl_device_inline float3 ceil(const float3 a)
static ulong * next
static ulong state[N]
static const int steps
#define min(a, b)
Definition sort.c:32
#define FLT_MAX
Definition stdcycles.h:14
unsigned char planes
void * first
struct Mask * mask
MovieTrackingPlaneTrack * active_plane_track
MovieTrackingReconstruction reconstruction
MovieTrackingTrack * active_track
MovieTrackingPlaneMarker * markers
MovieTrackingMarker * markers
struct MovieClipUser user
float stabmat[4][4]
float unistabmat[4][4]
MaskSpaceInfo mask_info
struct bGPDframe * next
struct bGPDstroke * next
uiFontStyle widget