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