Blender V5.0
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_utf8.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
149 immVertexFormat(), "pos", blender::gpu::VertAttrType::SFLOAT_32_32);
151
152 /* track */
153 if (tracking_object->active_track || tracking_object->active_plane_track) {
154 const MovieTrackingTrack *active_track = tracking_object->active_track;
155 const MovieTrackingPlaneTrack *active_plane_track = tracking_object->active_plane_track;
156
157 for (i = sfra - clip->start_frame + 1, a = 0; i <= efra - clip->start_frame + 1; i++) {
158 int framenr;
159 const int markersnr = generic_track_get_markersnr(active_track, active_plane_track);
160
161 while (a < markersnr) {
162 int marker_framenr = generic_track_get_marker_framenr(active_track, active_plane_track, a);
163
164 if (marker_framenr >= i) {
165 break;
166 }
167
168 if (a < markersnr - 1 &&
169 generic_track_get_marker_framenr(active_track, active_plane_track, a + 1) > i)
170 {
171 break;
172 }
173
174 a++;
175 }
176
177 a = min_ii(a, markersnr - 1);
178
179 if (generic_track_is_marker_enabled(active_track, active_plane_track, a)) {
180 framenr = generic_track_get_marker_framenr(active_track, active_plane_track, a);
181
182 if (framenr != i) {
183 immUniformColor4ub(128, 128, 0, 96);
184 }
185 else if (generic_track_is_marker_keyframed(active_track, active_plane_track, a)) {
186 immUniformColor4ub(255, 255, 0, 196);
187 }
188 else {
189 immUniformColor4ub(255, 255, 0, 96);
190 }
191
193 (i - sfra + clip->start_frame - 1) * framelen,
194 0,
195 (i - sfra + clip->start_frame) * framelen,
196 4 * UI_SCALE_FAC);
197 }
198 }
199 }
200
201 /* failed frames */
202 if (reconstruction->flag & TRACKING_RECONSTRUCTED) {
203 int n = reconstruction->camnr;
204 MovieReconstructedCamera *cameras = reconstruction->cameras;
205
206 immUniformColor4ub(255, 0, 0, 96);
207
208 for (i = sfra, a = 0; i <= efra; i++) {
209 bool ok = false;
210
211 while (a < n) {
212 if (cameras[a].framenr == i) {
213 ok = true;
214 break;
215 }
216 if (cameras[a].framenr > i) {
217 break;
218 }
219
220 a++;
221 }
222
223 if (!ok) {
225 (i - sfra + clip->start_frame - 1) * framelen,
226 0,
227 (i - sfra + clip->start_frame) * framelen,
228 8 * UI_SCALE_FAC);
229 }
230 }
231 }
232
234
235 /* current frame */
236 x = (sc->user.framenr - sfra) / (efra - sfra + 1) * region->winx;
237
239 immRectf(pos, x, 0, x + ceilf(framelen), 8 * UI_SCALE_FAC);
240
242
244 sc->user.framenr, x + roundf(framelen / 2), 8.0f * UI_SCALE_FAC);
245
247 immVertexFormat(), "pos", blender::gpu::VertAttrType::SFLOAT_32_32);
249
250 /* solver keyframes */
251 immUniformColor4ub(175, 255, 0, 255);
253 tracking_object->keyframe1 + clip->start_frame - 1, scene->r.cfra, sfra, framelen, 2, pos);
255 tracking_object->keyframe2 + clip->start_frame - 1, scene->r.cfra, sfra, framelen, 2, pos);
256
258
259 /* movie clip animation */
260 if ((sc->mode == SC_MODE_MASKEDIT) && sc->mask_info.mask) {
261 ED_mask_draw_frames(sc->mask_info.mask, region, scene->r.cfra, sfra, efra);
262 }
263}
264
265static void draw_movieclip_notes(SpaceClip *sc, ARegion *region)
266{
268 MovieTracking *tracking = &clip->tracking;
269 char str[256] = {0};
270 bool full_redraw = false;
271
272 if (tracking->stats) {
273 STRNCPY_UTF8(str, tracking->stats->message);
274 full_redraw = true;
275 }
276 else {
277 if (sc->flag & SC_LOCK_SELECTION) {
278 STRNCPY_UTF8(str, "Locked");
279 }
280 }
281
282 if (str[0]) {
283 float fill_color[4] = {0.0f, 0.0f, 0.0f, 0.6f};
284 ED_region_info_draw(region, str, fill_color, full_redraw);
285 }
286}
287
288static void draw_movieclip_muted(ARegion *region, int width, int height, float zoomx, float zoomy)
289{
290 int x, y;
291
293 immVertexFormat(), "pos", blender::gpu::VertAttrType::SFLOAT_32_32);
295
296 /* find window pixel coordinates of origin */
297 UI_view2d_view_to_region(&region->v2d, 0.0f, 0.0f, &x, &y);
298
299 immUniformColor3f(0.0f, 0.0f, 0.0f);
300 immRectf(pos, x, y, x + zoomx * width, y + zoomy * height);
301
303}
304
306 SpaceClip *sc,
307 ARegion *region,
308 ImBuf *ibuf,
309 int width,
310 int height,
311 float zoomx,
312 float zoomy)
313{
315 bool use_filter = true;
316 int x, y;
317
318 /* find window pixel coordinates of origin */
319 UI_view2d_view_to_region(&region->v2d, 0.0f, 0.0f, &x, &y);
320
321 /* checkerboard for case alpha */
322 if (ibuf->planes == 32) {
324
325 imm_draw_box_checker_2d(x, y, x + zoomx * ibuf->x, y + zoomy * ibuf->y);
326 }
327
328 /* non-scaled proxy shouldn't use filtering */
329 if ((clip->flag & MCLIP_USE_PROXY) == 0 ||
331 {
332 use_filter = false;
333 }
334
335 ED_draw_imbuf_ctx(C, ibuf, x, y, use_filter, zoomx * width / ibuf->x, zoomy * height / ibuf->y);
336
337 if (ibuf->planes == 32) {
339 }
340
341 if (sc->flag & SC_SHOW_METADATA) {
342 rctf frame;
343 BLI_rctf_init(&frame, 0.0f, ibuf->x, 0.0f, ibuf->y);
345 x, y, ibuf, &frame, zoomx * width / ibuf->x, zoomy * height / ibuf->y);
346 }
347}
348
350 SpaceClip *sc, ARegion *region, int width, int height, float zoomx, float zoomy)
351{
352 int x, y;
354
355 /* find window pixel coordinates of origin */
356 UI_view2d_view_to_region(&region->v2d, 0.0f, 0.0f, &x, &y);
357
358 /* draw boundary border for frame if stabilization is enabled */
360 const uint shdr_pos = GPU_vertformat_attr_add(
361 immVertexFormat(), "pos", blender::gpu::VertAttrType::SFLOAT_32_32);
362
363 /* Exclusive OR allows to get orig value when second operand is 0,
364 * and negative of orig value when second operand is 1. */
366
369
370 GPU_matrix_scale_2f(zoomx, zoomy);
372
374
375 float viewport_size[4];
376 GPU_viewport_size_get_f(viewport_size);
378 "viewport_size", viewport_size[2] / UI_SCALE_FAC, viewport_size[3] / UI_SCALE_FAC);
379
380 immUniform1i("colors_len", 0); /* "simple" mode */
381 immUniformColor4f(1.0f, 1.0f, 1.0f, 0.0f);
382 immUniform1f("dash_width", 6.0f);
383 immUniform1f("udash_factor", 0.5f);
384
385 imm_draw_box_wire_2d(shdr_pos, 0.0f, 0.0f, width, height);
386
388
390
392 }
393}
394
395enum {
397};
398
400 float co[2];
402};
403
405 const MovieTrackingTrack *track,
406 const MovieTrackingMarker *marker,
407 TrackPathPoint *point)
408{
409 add_v2_v2v2(point->co, marker->pos, track->offset);
410 ED_clip_point_undistorted_pos(sc, point->co, point->co);
411 point->flag = 0;
412 if ((marker->flag & MARKER_TRACKED) == 0) {
414 }
415}
416
418 MovieTrackingTrack *track,
419 int direction,
420 TrackPathPoint *path)
421{
422 const int count = sc->path_length;
423 int current_frame = ED_space_clip_get_clip_frame_number(sc);
424 const MovieTrackingMarker *marker = BKE_tracking_marker_get_exact(track, current_frame);
425 /* Check whether there is marker at exact current frame.
426 * If not, we don't have anything to be put to path. */
427 if (marker == nullptr || (marker->flag & MARKER_DISABLED)) {
428 return 0;
429 }
430 /* Index inside of path array where we write data to. */
431 int point_index = count;
432 int path_length = 0;
433 for (int i = 0; i < count; ++i) {
434 marker_to_path_point(sc, track, marker, &path[point_index]);
435 /* Move to the next marker along the path segment. */
436 path_length++;
437 point_index += direction;
438 current_frame += direction;
439 marker = BKE_tracking_marker_get_exact(track, current_frame);
440 if (marker == nullptr || (marker->flag & MARKER_DISABLED)) {
441 /* Reached end of tracked segment. */
442 break;
443 }
444 }
445 return path_length;
446}
447
449 uint position_attribute,
450 const int start_point,
451 const int num_points)
452{
453 if (num_points == 0) {
454 return;
455 }
456 immBegin(GPU_PRIM_POINTS, num_points);
457 for (int i = 0; i < num_points; i++) {
458 const TrackPathPoint *point = &path[i + start_point];
459 immVertex2fv(position_attribute, point->co);
460 }
461 immEnd();
462}
463
465 uint position_attribute,
466 const int start_point,
467 const int num_points)
468{
469 immBeginAtMost(GPU_PRIM_POINTS, num_points);
470 for (int i = 0; i < num_points; i++) {
471 const TrackPathPoint *point = &path[i + start_point];
472 if (point->flag & PATH_POINT_FLAG_KEYFRAME) {
473 immVertex2fv(position_attribute, point->co);
474 }
475 }
476 immEnd();
477}
478
479static void draw_track_path_lines(const TrackPathPoint *path,
480 uint position_attribute,
481 const int start_point,
482 const int num_points)
483{
484 if (num_points < 2) {
485 return;
486 }
487 immBegin(GPU_PRIM_LINE_STRIP, num_points);
488 for (int i = 0; i < num_points; i++) {
489 const TrackPathPoint *point = &path[i + start_point];
490 immVertex2fv(position_attribute, point->co);
491 }
492 immEnd();
493}
494
495static void draw_track_path(SpaceClip *sc, MovieClip * /*clip*/, MovieTrackingTrack *track)
496{
497#define MAX_STATIC_PATH 64
498
499 const int count = sc->path_length;
500 TrackPathPoint path_static[(MAX_STATIC_PATH + 1) * 2];
501 TrackPathPoint *path;
502 const bool tiny = (sc->flag & SC_SHOW_TINY_MARKER) != 0;
503
504 if (count == 0) {
505 /* Early output, nothing to bother about here. */
506 return;
507 }
508
509 /* Try to use stack allocated memory when possibly, only use heap allocation
510 * for really long paths. */
511 path = (count < MAX_STATIC_PATH) ?
512 path_static :
513 MEM_calloc_arrayN<TrackPathPoint>(sizeof(*path) * (count + 1) * 2, "path");
514 /* Collect path information. */
515 const int num_points_before = track_to_path_segment(sc, track, -1, path);
516 const int num_points_after = track_to_path_segment(sc, track, 1, path);
517 if (num_points_before == 0 && num_points_after == 0) {
518 return;
519 }
520
521 int num_all_points = num_points_before + num_points_after;
522 /* If both leading and trailing parts of the path are there the center point is counted twice. */
523 if (num_points_before != 0 && num_points_after != 0) {
524 num_all_points -= 1;
525 }
526
527 const int path_start_index = count - num_points_before + 1;
528 const int path_center_index = count;
529
530 const uint position_attribute = GPU_vertformat_attr_add(
531 immVertexFormat(), "pos", blender::gpu::VertAttrType::SFLOAT_32_32);
532
533 /* Draw path outline. */
534 if (!tiny) {
535 if (TRACK_VIEW_SELECTED(sc, track)) {
538 immUniform1f("size", 5.0f);
539 draw_track_path_points(path, position_attribute, path_start_index, num_all_points);
540 immUniform1f("size", 7.0f);
541 draw_track_path_keyframe_points(path, position_attribute, path_start_index, num_all_points);
543 }
544 /* Draw darker outline for actual path, all line segments at once. */
545 GPU_line_width(3.0f);
548 draw_track_path_lines(path, position_attribute, path_start_index, num_all_points);
550 }
551
552 /* Draw all points. */
555 immUniform1f("size", 3.0f);
556 draw_track_path_points(path, position_attribute, path_start_index, num_points_before);
558 draw_track_path_points(path, position_attribute, path_center_index, num_points_after);
560
561 /* Connect points with color coded segments. */
562 GPU_line_width(1.0f);
565 draw_track_path_lines(path, position_attribute, path_start_index, num_points_before);
567 draw_track_path_lines(path, position_attribute, path_center_index, num_points_after);
569
570 /* Draw all bigger points corresponding to keyframes. */
573 immUniform1f("size", 5.0f);
574 draw_track_path_keyframe_points(path, position_attribute, path_start_index, num_points_before);
576 draw_track_path_keyframe_points(path, position_attribute, path_center_index, num_points_after);
578
579 if (path != path_static) {
580 MEM_freeN(path);
581 }
582
583#undef MAX_STATIC_PATH
584}
585
587 const MovieTrackingTrack *track,
588 const MovieTrackingMarker *marker,
589 const float marker_pos[2],
590 int width,
591 int height,
592 uint position)
593{
594 int tiny = sc->flag & SC_SHOW_TINY_MARKER;
595 bool show_search = false;
596 float px[2];
597
598 px[0] = 1.0f / width / sc->zoom;
599 px[1] = 1.0f / height / sc->zoom;
600
601 if ((marker->flag & MARKER_DISABLED) == 0) {
602 float pos[2];
603 float p[2];
604
605 add_v2_v2v2(pos, marker->pos, track->offset);
606
608
609 sub_v2_v2v2(p, pos, marker_pos);
610
612 marker->pattern_corners[0],
613 marker->pattern_corners[1],
614 marker->pattern_corners[2],
615 marker->pattern_corners[3]))
616 {
618 immUniform1f("size", tiny ? 3.0f : 4.0f);
621 immVertex2f(position, pos[0], pos[1]);
622 immEnd();
624 }
625 else {
626 GPU_line_width(tiny ? 1.0f : 3.0f);
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] - px[0] * 2, pos[1]);
635 immVertex2f(position, pos[0] - px[0] * 8, pos[1]);
636
637 immVertex2f(position, pos[0], pos[1] - px[1] * 2);
638 immVertex2f(position, pos[0], pos[1] - px[1] * 8);
639
640 immVertex2f(position, pos[0], pos[1] + px[1] * 2);
641 immVertex2f(position, pos[0], pos[1] + px[1] * 8);
642
643 immEnd();
645 }
646 }
647
648 /* pattern and search outline */
649 GPU_line_width(tiny ? 1.0f : 3.0f);
652
654 GPU_matrix_translate_2fv(marker_pos);
655
656 if (sc->flag & SC_SHOW_MARKER_PATTERN) {
658 immVertex2fv(position, marker->pattern_corners[0]);
659 immVertex2fv(position, marker->pattern_corners[1]);
660 immVertex2fv(position, marker->pattern_corners[2]);
661 immVertex2fv(position, marker->pattern_corners[3]);
662 immEnd();
663 }
664
665 show_search = (TRACK_VIEW_SELECTED(sc, track) && ((marker->flag & MARKER_DISABLED) == 0 ||
666 (sc->flag & SC_SHOW_MARKER_PATTERN) == 0)) !=
667 0;
668
669 if (sc->flag & SC_SHOW_MARKER_SEARCH && show_search) {
670 imm_draw_box_wire_2d(position,
671 marker->search_min[0],
672 marker->search_min[1],
673 marker->search_max[0],
674 marker->search_max[1]);
675 }
676
679}
680
681static void track_colors(const MovieTrackingTrack *track, int act, float r_col[3], float r_scol[3])
682{
683 if (track->flag & TRACK_CUSTOMCOLOR) {
684 if (act) {
686 }
687 else {
688 copy_v3_v3(r_scol, track->color);
689 }
690
691 mul_v3_v3fl(r_col, track->color, 0.5f);
692 }
693 else {
695
696 if (act) {
698 }
699 else {
701 }
702 }
703}
704
706 const MovieTrackingMarker *marker,
707 const bool is_track_active,
708 const bool is_area_selected,
709 const float color[3],
710 const float selected_color[3])
711{
712 if (track->flag & TRACK_LOCKED) {
713 if (is_track_active) {
715 }
716 else if (is_area_selected) {
718 }
719 else {
721 }
722 }
723 else if (marker->flag & MARKER_DISABLED) {
724 if (is_track_active) {
726 }
727 else if (is_area_selected) {
729 }
730 else {
732 }
733 }
734 else {
735 immUniformColor3fv(is_area_selected ? selected_color : color);
736 }
737}
738
740 const MovieTrackingTrack *track,
741 const MovieTrackingMarker *marker,
742 const float marker_pos[2],
743 int width,
744 int height,
745 int act,
746 int sel,
747 const uint shdr_pos)
748{
749 int tiny = sc->flag & SC_SHOW_TINY_MARKER;
750 bool show_search = false;
751 float col[3], scol[3];
752 blender::float4 color;
753 float px[2];
754
755 track_colors(track, act, col, scol);
756
757 px[0] = 1.0f / width / sc->zoom;
758 px[1] = 1.0f / height / sc->zoom;
759
760 float viewport[4];
761 GPU_viewport_size_get_f(viewport);
762
763 /* marker position and offset position */
764 if ((track->flag & SELECT) == sel && (marker->flag & MARKER_DISABLED) == 0) {
765 float pos[2], p[2];
766
767 if (track->flag & TRACK_LOCKED) {
768 if (act) {
770 }
771 else if (track->flag & SELECT) {
773 }
774 else {
776 }
777 }
778 else {
779 if (bool(track->flag & SELECT)) {
780 color = blender::float4(blender::float3(scol), 1.0);
781 }
782 else {
783 color = blender::float4(blender::float3(col), 1.0);
784 }
785 }
786
787 add_v2_v2v2(pos, marker->pos, track->offset);
789
790 sub_v2_v2v2(p, pos, marker_pos);
791
793 marker->pattern_corners[0],
794 marker->pattern_corners[1],
795 marker->pattern_corners[2],
796 marker->pattern_corners[3]))
797 {
799 immUniformColor4fv(color);
800 immUniform1f("size", tiny ? 1.0f : 2.0f);
802 immVertex2f(shdr_pos, pos[0], pos[1]);
803 immEnd();
805 }
806 else {
808 immUniform2f("viewport_size", viewport[2] / UI_SCALE_FAC, viewport[3] / UI_SCALE_FAC);
809 immUniform1i("colors_len", 0);
810 immUniformColor4fv(color);
811 immUniform1f("udash_factor", 2.0f); /* Solid line */
812
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] - px[0] * 3, pos[1]);
819 immVertex2f(shdr_pos, pos[0] - px[0] * 7, pos[1]);
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 immVertex2f(shdr_pos, pos[0], pos[1] + px[1] * 3);
825 immVertex2f(shdr_pos, pos[0], pos[1] + px[1] * 7);
826
827 immEnd();
828
829 immUniformColor4f(1.0f, 1.0f, 1.0f, 0.0f);
830 immUniform1f("dash_width", 6.0f);
831 immUniform1f("udash_factor", 0.5f);
832
834
836 immVertex2fv(shdr_pos, pos);
837 immVertex2fv(shdr_pos, marker_pos);
838 immEnd();
839
842 }
843 }
844
845 /* pattern */
847 GPU_matrix_translate_2fv(marker_pos);
848
850 immUniform2f("viewport_size", viewport[2] / UI_SCALE_FAC, viewport[3] / UI_SCALE_FAC);
851 immUniform1i("colors_len", 0);
852 set_draw_marker_area_color(track, marker, act, track->pat_flag & SELECT, col, scol);
853 if (tiny) {
854 immUniform1f("dash_width", 6.0f);
855 immUniform1f("udash_factor", 0.5f);
856 }
857 else {
858 immUniform1f("udash_factor", 2.0f); /* Solid line */
859 }
860
861 if ((track->pat_flag & SELECT) == sel && (sc->flag & SC_SHOW_MARKER_PATTERN)) {
863 immVertex2fv(shdr_pos, marker->pattern_corners[0]);
864 immVertex2fv(shdr_pos, marker->pattern_corners[1]);
865 immVertex2fv(shdr_pos, marker->pattern_corners[2]);
866 immVertex2fv(shdr_pos, marker->pattern_corners[3]);
867 immEnd();
868 }
869
870 /* search */
871 show_search = (TRACK_VIEW_SELECTED(sc, track) && ((marker->flag & MARKER_DISABLED) == 0 ||
872 (sc->flag & SC_SHOW_MARKER_PATTERN) == 0)) !=
873 0;
874
875 if ((track->search_flag & SELECT) == sel && (sc->flag & SC_SHOW_MARKER_SEARCH) && show_search) {
876 set_draw_marker_area_color(track, marker, act, track->search_flag & SELECT, col, scol);
877
878 imm_draw_box_wire_2d(shdr_pos,
879 marker->search_min[0],
880 marker->search_min[1],
881 marker->search_max[0],
882 marker->search_max[1]);
883 }
884
886
889 immVertexFormat(), "pos", blender::gpu::VertAttrType::SFLOAT_32_32);
890 BLI_assert(pos == shdr_pos);
892}
893
895{
896 float len_sq = FLT_MAX;
897
898 for (int i = 0; i < 4; i++) {
899 int next = (i + 1) % 4;
900 float cur_len = len_squared_v2v2(marker->pattern_corners[i], marker->pattern_corners[next]);
901 len_sq = min_ff(cur_len, len_sq);
902 }
903
904 return sqrtf(len_sq);
905}
906
908 float x, float y, float dx, float dy, int outline, const float px[2], uint pos)
909{
910 float tdx, tdy;
911
912 tdx = dx;
913 tdy = dy;
914
915 if (outline) {
916 tdx += px[0];
917 tdy += px[1];
918 }
919
920 immRectf(pos, x - tdx, y - tdy, x + tdx, y + tdy);
921}
922
924 float x, float y, float dx, float dy, int outline, const float px[2], uint pos)
925{
926 float tdx, tdy;
927
928 tdx = dx * 2.0f;
929 tdy = dy * 2.0f;
930
931 if (outline) {
932 tdx += px[0];
933 tdy += px[1];
934 }
935
937 immVertex2f(pos, x, y);
938 immVertex2f(pos, x - tdx, y);
939 immVertex2f(pos, x, y + tdy);
940 immEnd();
941}
942
944 const MovieTrackingTrack *track,
945 const MovieTrackingMarker *marker,
946 const float marker_pos[2],
947 int outline,
948 int sel,
949 int act,
950 int width,
951 int height,
952 uint pos)
953{
954 float dx, dy, patdx, patdy, searchdx, searchdy;
955 int tiny = sc->flag & SC_SHOW_TINY_MARKER;
956 float col[3], scol[3], px[2], side;
957
958 if ((tiny && outline) || (marker->flag & MARKER_DISABLED)) {
959 return;
960 }
961
962 if (!TRACK_VIEW_SELECTED(sc, track) || track->flag & TRACK_LOCKED) {
963 return;
964 }
965
967
968 track_colors(track, act, col, scol);
969
970 if (outline) {
972 }
973
975 GPU_matrix_translate_2fv(marker_pos);
976
977 dx = 6.0f / width / sc->zoom;
978 dy = 6.0f / height / sc->zoom;
979
980 side = get_shortest_pattern_side(marker);
981 patdx = min_ff(dx * 2.0f / 3.0f, side / 6.0f) * UI_SCALE_FAC;
982 patdy = min_ff(dy * 2.0f / 3.0f, side * width / height / 6.0f) * UI_SCALE_FAC;
983
984 searchdx = min_ff(dx, (marker->search_max[0] - marker->search_min[0]) / 6.0f) * UI_SCALE_FAC;
985 searchdy = min_ff(dy, (marker->search_max[1] - marker->search_min[1]) / 6.0f) * UI_SCALE_FAC;
986
987 px[0] = 1.0f / sc->zoom / width / sc->scale;
988 px[1] = 1.0f / sc->zoom / height / sc->scale;
989
990 if ((sc->flag & SC_SHOW_MARKER_SEARCH) && ((track->search_flag & SELECT) == sel || outline)) {
991 if (!outline) {
992 immUniformColor3fv((track->search_flag & SELECT) ? scol : col);
993 }
994
995 /* search offset square */
997 marker->search_min[0], marker->search_max[1], searchdx, searchdy, outline, px, pos);
998
999 /* search re-sizing triangle */
1001 marker->search_max[0], marker->search_min[1], searchdx, searchdy, outline, px, pos);
1002 }
1003
1004 if ((sc->flag & SC_SHOW_MARKER_PATTERN) && ((track->pat_flag & SELECT) == sel || outline)) {
1005 float pat_min[2], pat_max[2];
1006 // float dx = 12.0f / width, dy = 12.0f / height; /*UNUSED*/
1007 float tilt_ctrl[2];
1008
1009 if (!outline) {
1010 immUniformColor3fv((track->pat_flag & SELECT) ? scol : col);
1011 }
1012
1013 /* pattern's corners sliding squares */
1014 for (int i = 0; i < 4; i++) {
1016 marker->pattern_corners[i][1],
1017 patdx / 1.5f,
1018 patdy / 1.5f,
1019 outline,
1020 px,
1021 pos);
1022 }
1023
1024 /* ** sliders to control overall pattern ** */
1025 add_v2_v2v2(tilt_ctrl, marker->pattern_corners[1], marker->pattern_corners[2]);
1026
1027 BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max);
1028
1029 GPU_line_width(outline ? 3.0f : 1.0f);
1030
1032 immVertex2f(pos, 0.0f, 0.0f);
1033 immVertex2fv(pos, tilt_ctrl);
1034 immEnd();
1035
1036 /* slider to control pattern tilt */
1037 draw_marker_slide_square(tilt_ctrl[0], tilt_ctrl[1], patdx, patdy, outline, px, pos);
1038 }
1039
1042}
1043
1045 const MovieTrackingTrack *track,
1046 const MovieTrackingMarker *marker,
1047 const float marker_pos[2],
1048 int act,
1049 int width,
1050 int height,
1051 float zoomx,
1052 float zoomy)
1053{
1054 char str[128] = {0}, state[64] = {0};
1055 float dx = 0.0f, dy = 0.0f, fontsize, pos[3];
1056 uiStyle *style = static_cast<uiStyle *>(U.uistyles.first);
1057 int fontid = style->widget.uifont_id;
1058
1059 if (!TRACK_VIEW_SELECTED(sc, track)) {
1060 return;
1061 }
1062
1063 BLF_size(fontid, 11.0f * UI_SCALE_FAC);
1064 fontsize = BLF_height_max(fontid);
1065
1066 if (marker->flag & MARKER_DISABLED) {
1067 if (act) {
1069 }
1070 else {
1071 uchar color[4];
1073 BLF_color4ubv(fontid, color);
1074 }
1075 }
1076 else {
1078 }
1079
1080 if ((sc->flag & SC_SHOW_MARKER_SEARCH) &&
1081 ((marker->flag & MARKER_DISABLED) == 0 || (sc->flag & SC_SHOW_MARKER_PATTERN) == 0))
1082 {
1083 dx = marker->search_min[0];
1084 dy = marker->search_min[1];
1085 }
1086 else if (sc->flag & SC_SHOW_MARKER_PATTERN) {
1087 float pat_min[2], pat_max[2];
1088
1089 BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max);
1090 dx = pat_min[0];
1091 dy = pat_min[1];
1092 }
1093
1094 pos[0] = (marker_pos[0] + dx) * width;
1095 pos[1] = (marker_pos[1] + dy) * height;
1096 pos[2] = 0.0f;
1097
1098 mul_m4_v3(sc->stabmat, pos);
1099
1100 pos[0] = pos[0] * zoomx;
1101 pos[1] = pos[1] * zoomy - fontsize;
1102
1103 if (marker->flag & MARKER_DISABLED) {
1104 STRNCPY_UTF8(state, "disabled");
1105 }
1106 else if (marker->framenr != ED_space_clip_get_clip_frame_number(sc)) {
1107 STRNCPY_UTF8(state, "estimated");
1108 }
1109 else if (marker->flag & MARKER_TRACKED) {
1110 STRNCPY_UTF8(state, "tracked");
1111 }
1112 else {
1113 STRNCPY_UTF8(state, "keyframed");
1114 }
1115
1116 if (state[0]) {
1117 SNPRINTF_UTF8(str, "%s: %s", track->name, state);
1118 }
1119 else {
1120 STRNCPY_UTF8(str, track->name);
1121 }
1122
1123 BLF_position(fontid, pos[0], pos[1], 0.0f);
1124 BLF_draw(fontid, str, sizeof(str));
1125 pos[1] -= fontsize;
1126
1127 if (track->flag & TRACK_HAS_BUNDLE) {
1128 SNPRINTF_UTF8(str, "Average error: %.2f px", track->error);
1129 BLF_position(fontid, pos[0], pos[1], 0.0f);
1130 BLF_draw(fontid, str, sizeof(str));
1131 pos[1] -= fontsize;
1132 }
1133
1134 if (track->flag & TRACK_LOCKED) {
1135 BLF_position(fontid, pos[0], pos[1], 0.0f);
1136 BLF_draw(fontid, "locked", 6);
1137 }
1138}
1139
1140static void plane_track_colors(bool is_active, float r_color[3], float r_selected_color[3])
1141{
1143
1144 UI_GetThemeColor3fv(is_active ? TH_ACT_MARKER : TH_SEL_MARKER, r_selected_color);
1145}
1146
1147static void getArrowEndPoint(const int width,
1148 const int height,
1149 const float zoom,
1150 const float start_corner[2],
1151 const float end_corner[2],
1152 float end_point[2])
1153{
1154 float direction[2];
1155 float max_length;
1156
1157 sub_v2_v2v2(direction, end_corner, start_corner);
1158
1159 direction[0] *= width;
1160 direction[1] *= height;
1161 max_length = normalize_v2(direction);
1162 mul_v2_fl(direction, min_ff(32.0f / zoom, max_length));
1163 direction[0] /= width;
1164 direction[1] /= height;
1165
1166 add_v2_v2v2(end_point, start_corner, direction);
1167}
1168
1169static void homogeneous_2d_to_gl_matrix(/*const*/ float matrix[3][3], float gl_matrix[4][4])
1170{
1171 gl_matrix[0][0] = matrix[0][0];
1172 gl_matrix[0][1] = matrix[0][1];
1173 gl_matrix[0][2] = 0.0f;
1174 gl_matrix[0][3] = matrix[0][2];
1175
1176 gl_matrix[1][0] = matrix[1][0];
1177 gl_matrix[1][1] = matrix[1][1];
1178 gl_matrix[1][2] = 0.0f;
1179 gl_matrix[1][3] = matrix[1][2];
1180
1181 gl_matrix[2][0] = 0.0f;
1182 gl_matrix[2][1] = 0.0f;
1183 gl_matrix[2][2] = 1.0f;
1184 gl_matrix[2][3] = 0.0f;
1185
1186 gl_matrix[3][0] = matrix[2][0];
1187 gl_matrix[3][1] = matrix[2][1];
1188 gl_matrix[3][2] = 0.0f;
1189 gl_matrix[3][3] = matrix[2][2];
1190}
1191
1193 MovieTrackingPlaneTrack *plane_track,
1194 MovieTrackingPlaneMarker *plane_marker)
1195{
1196 Image *image = plane_track->image;
1197 ImBuf *ibuf;
1198 void *lock;
1199
1200 if (image == nullptr) {
1201 return;
1202 }
1203
1204 ibuf = BKE_image_acquire_ibuf(image, nullptr, &lock);
1205
1206 if (ibuf) {
1207 void *cache_handle;
1208 const uchar *display_buffer = IMB_display_buffer_acquire(
1209 ibuf, &scene->view_settings, &scene->display_settings, &cache_handle);
1210
1211 if (display_buffer) {
1212 float frame_corners[4][2] = {{0.0f, 0.0f}, {1.0f, 0.0f}, {1.0f, 1.0f}, {0.0f, 1.0f}};
1213 float perspective_matrix[3][3];
1214 float gl_matrix[4][4];
1215 bool transparent = false;
1217 frame_corners, plane_marker->corners, perspective_matrix);
1218
1219 homogeneous_2d_to_gl_matrix(perspective_matrix, gl_matrix);
1220
1221 if (plane_track->image_opacity != 1.0f || ibuf->planes == 32) {
1222 transparent = true;
1224 }
1225
1227 "plane_marker_image",
1228 ibuf->x,
1229 ibuf->y,
1230 1,
1231 blender::gpu::TextureFormat::UNORM_8_8_8_8,
1233 nullptr);
1234 GPU_texture_update(texture, GPU_DATA_UBYTE, display_buffer);
1236
1238 GPU_matrix_mul(gl_matrix);
1239
1240 GPUVertFormat *imm_format = immVertexFormat();
1242 imm_format, "pos", blender::gpu::VertAttrType::SFLOAT_32_32_32);
1243 uint texCoord = GPU_vertformat_attr_add(
1244 imm_format, "texCoord", blender::gpu::VertAttrType::SFLOAT_32_32);
1245
1246 /* Use 3D image for correct display of planar tracked images. */
1248
1249 immBindTexture("image", texture);
1250 immUniformColor4f(1.0f, 1.0f, 1.0f, plane_track->image_opacity);
1251
1253
1254 immAttr2f(texCoord, 0.0f, 0.0f);
1255 immVertex3f(pos, 0.0f, 0.0f, 0.0f);
1256
1257 immAttr2f(texCoord, 1.0f, 0.0f);
1258 immVertex3f(pos, 1.0f, 0.0f, 0.0f);
1259
1260 immAttr2f(texCoord, 1.0f, 1.0f);
1261 immVertex3f(pos, 1.0f, 1.0f, 0.0f);
1262
1263 immAttr2f(texCoord, 0.0f, 1.0f);
1264 immVertex3f(pos, 0.0f, 1.0f, 0.0f);
1265
1266 immEnd();
1267
1269
1271
1274
1275 if (transparent) {
1277 }
1278 }
1279
1280 IMB_display_buffer_release(cache_handle);
1281 }
1282
1283 BKE_image_release_ibuf(image, ibuf, lock);
1284}
1285
1287 Scene *scene,
1288 MovieTrackingPlaneTrack *plane_track,
1289 MovieTrackingPlaneMarker *plane_marker,
1290 bool is_active_track,
1291 bool draw_outline,
1292 int width,
1293 int height)
1294{
1295 bool tiny = (sc->flag & SC_SHOW_TINY_MARKER) != 0;
1296 bool is_selected_track = (plane_track->flag & SELECT) != 0;
1297 const bool has_image = plane_track->image != nullptr &&
1298 BKE_image_has_ibuf(plane_track->image, nullptr);
1299 const bool draw_plane_quad = !has_image || plane_track->image_opacity == 0.0f;
1300 float px[2];
1301 float color[3], selected_color[3];
1302
1303 px[0] = 1.0f / width / sc->zoom;
1304 px[1] = 1.0f / height / sc->zoom;
1305
1306 /* Draw image */
1307 if (draw_outline == false) {
1308 draw_plane_marker_image(scene, plane_track, plane_marker);
1309 }
1310
1311 if (draw_plane_quad || is_selected_track) {
1312 const uint shdr_pos = GPU_vertformat_attr_add(
1313 immVertexFormat(), "pos", blender::gpu::VertAttrType::SFLOAT_32_32);
1314
1316
1317 float viewport_size[4];
1318 GPU_viewport_size_get_f(viewport_size);
1320 "viewport_size", viewport_size[2] / UI_SCALE_FAC, viewport_size[3] / UI_SCALE_FAC);
1321
1322 immUniform1i("colors_len", 0); /* "simple" mode */
1323
1324 if (is_selected_track) {
1325 plane_track_colors(is_active_track, color, selected_color);
1326 }
1327
1328 if (draw_plane_quad) {
1329 const bool stipple = !draw_outline && tiny;
1330 const bool thick = draw_outline && !tiny;
1331
1332 GPU_line_width(thick ? 3.0f : 1.0f);
1333
1334 if (stipple) {
1335 immUniform1f("dash_width", 6.0f);
1336 immUniform1f("udash_factor", 0.5f);
1337 }
1338 else {
1339 immUniform1f("udash_factor", 2.0f); /* Solid line */
1340 }
1341
1342 if (draw_outline) {
1344 }
1345 else {
1346 immUniformColor3fv(is_selected_track ? selected_color : color);
1347 }
1348
1349 /* Draw rectangle itself. */
1351 immVertex2fv(shdr_pos, plane_marker->corners[0]);
1352 immVertex2fv(shdr_pos, plane_marker->corners[1]);
1353 immVertex2fv(shdr_pos, plane_marker->corners[2]);
1354 immVertex2fv(shdr_pos, plane_marker->corners[3]);
1355 immEnd();
1356
1357 /* Draw axis. */
1358 if (!draw_outline) {
1359 float end_point[2];
1360
1361 immUniformColor3f(1.0f, 0.0f, 0.0f);
1362
1364
1365 getArrowEndPoint(width,
1366 height,
1367 sc->zoom,
1368 plane_marker->corners[0],
1369 plane_marker->corners[1],
1370 end_point);
1371 immVertex2fv(shdr_pos, plane_marker->corners[0]);
1372 immVertex2fv(shdr_pos, end_point);
1373
1374 immEnd();
1375
1376 immUniformColor3f(0.0f, 1.0f, 0.0f);
1377
1379
1380 getArrowEndPoint(width,
1381 height,
1382 sc->zoom,
1383 plane_marker->corners[0],
1384 plane_marker->corners[3],
1385 end_point);
1386 immVertex2fv(shdr_pos, plane_marker->corners[0]);
1387 immVertex2fv(shdr_pos, end_point);
1388
1389 immEnd();
1390 }
1391 }
1393
1394 /* Draw sliders. */
1395 if (is_selected_track) {
1397
1398 if (draw_outline) {
1400 }
1401 else {
1402 immUniformColor3fv(selected_color);
1403 }
1404
1405 for (int i = 0; i < 4; i++) {
1406 draw_marker_slide_square(plane_marker->corners[i][0],
1407 plane_marker->corners[i][1],
1408 3.0f * px[0],
1409 3.0f * px[1],
1410 draw_outline,
1411 px,
1412 shdr_pos);
1413 }
1415 }
1416 }
1417}
1418
1420 Scene *scene,
1421 MovieTrackingPlaneTrack *plane_track,
1422 MovieTrackingPlaneMarker *plane_marker,
1423 int width,
1424 int height)
1425{
1426 draw_plane_marker_ex(sc, scene, plane_track, plane_marker, false, true, width, height);
1427}
1428
1430 Scene *scene,
1431 MovieTrackingPlaneTrack *plane_track,
1432 MovieTrackingPlaneMarker *plane_marker,
1433 bool is_active_track,
1434 int width,
1435 int height)
1436{
1438 sc, scene, plane_track, plane_marker, is_active_track, false, width, height);
1439}
1440
1442 Scene *scene,
1443 MovieTrackingPlaneTrack *plane_track,
1444 int framenr,
1445 bool is_active_track,
1446 int width,
1447 int height)
1448{
1449 MovieTrackingPlaneMarker *plane_marker;
1450
1451 plane_marker = BKE_tracking_plane_marker_get(plane_track, framenr);
1452
1453 draw_plane_marker_outline(sc, scene, plane_track, plane_marker, width, height);
1454 draw_plane_marker(sc, scene, plane_track, plane_marker, is_active_track, width, height);
1455}
1456
1457/* Draw all kind of tracks. */
1459 Scene *scene,
1460 ARegion *region,
1461 MovieClip *clip,
1462 int width,
1463 int height,
1464 float zoomx,
1465 float zoomy)
1466{
1467 float x, y;
1468 /*const*/ MovieTracking *tracking = &clip->tracking;
1469 /*const*/ MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(tracking);
1470 /*const*/ MovieTrackingTrack *active_track = tracking_object->active_track;
1471 /*const*/ MovieTrackingPlaneTrack *active_plane_track = tracking_object->active_plane_track;
1472 const int framenr = ED_space_clip_get_clip_frame_number(sc);
1473 const int undistort = sc->user.render_flag & MCLIP_PROXY_RENDER_UNDISTORT;
1474 float *marker_pos = nullptr, *fp, *active_pos = nullptr, cur_pos[2];
1475
1476 /* ** find window pixel coordinates of origin ** */
1477
1478 /* UI_view2d_view_to_region_no_clip return integer values, this could
1479 * lead to 1px flickering when view is locked to selection during playback.
1480 * to avoid this flickering, calculate base point in the same way as it happens
1481 * in UI_view2d_view_to_region_no_clip, but do it in floats here */
1482
1483 UI_view2d_view_to_region_fl(&region->v2d, 0.0f, 0.0f, &x, &y);
1484
1487
1489 GPU_matrix_scale_2f(zoomx, zoomy);
1491 GPU_matrix_scale_2f(width, height);
1492
1493 /* Draw plane tracks */
1494 LISTBASE_FOREACH (MovieTrackingPlaneTrack *, plane_track, &tracking_object->plane_tracks) {
1495 if ((plane_track->flag & PLANE_TRACK_HIDDEN) == 0) {
1497 sc, scene, plane_track, framenr, plane_track == active_plane_track, width, height);
1498 }
1499 }
1500
1502 int count = 0;
1503
1504 /* count */
1505 LISTBASE_FOREACH (MovieTrackingTrack *, track, &tracking_object->tracks) {
1506 if (track->flag & TRACK_HIDDEN) {
1507 continue;
1508 }
1509
1510 const MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
1511
1512 if (ED_space_clip_marker_is_visible(sc, tracking_object, track, marker)) {
1513 count++;
1514 }
1515 }
1516
1517 /* undistort */
1518 if (count) {
1519 marker_pos = MEM_calloc_arrayN<float>(2 * count, "draw_tracking_tracks marker_pos");
1520
1521 fp = marker_pos;
1522 LISTBASE_FOREACH (MovieTrackingTrack *, track, &tracking_object->tracks) {
1523 if (track->flag & TRACK_HIDDEN) {
1524 continue;
1525 }
1526
1527 const MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
1528
1529 if (ED_space_clip_marker_is_visible(sc, tracking_object, track, marker)) {
1530 ED_clip_point_undistorted_pos(sc, marker->pos, fp);
1531
1532 if (track == active_track) {
1533 active_pos = fp;
1534 }
1535
1536 fp += 2;
1537 }
1538 }
1539 }
1540 }
1541
1542 if (sc->flag & SC_SHOW_TRACK_PATH) {
1543 LISTBASE_FOREACH (MovieTrackingTrack *, track, &tracking_object->tracks) {
1544 if ((track->flag & TRACK_HIDDEN) == 0) {
1545 draw_track_path(sc, clip, track);
1546 }
1547 }
1548 }
1549
1550 const uint position = GPU_vertformat_attr_add(
1551 immVertexFormat(), "pos", blender::gpu::VertAttrType::SFLOAT_32_32);
1552
1553 /* markers outline and non-selected areas */
1554 fp = marker_pos;
1555 LISTBASE_FOREACH (MovieTrackingTrack *, track, &tracking_object->tracks) {
1556 if (track->flag & TRACK_HIDDEN) {
1557 continue;
1558 }
1559
1560 const MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
1561
1562 if (ED_space_clip_marker_is_visible(sc, tracking_object, track, marker)) {
1563 copy_v2_v2(cur_pos, fp ? fp : marker->pos);
1564
1565 draw_marker_outline(sc, track, marker, cur_pos, width, height, position);
1566 draw_marker_areas(sc, track, marker, cur_pos, width, height, 0, 0, position);
1567 draw_marker_slide_zones(sc, track, marker, cur_pos, 1, 0, 0, width, height, position);
1568 draw_marker_slide_zones(sc, track, marker, cur_pos, 0, 0, 0, width, height, position);
1569
1570 if (fp) {
1571 fp += 2;
1572 }
1573 }
1574 }
1575
1576 /* selected areas only, so selection wouldn't be overlapped by non-selected areas */
1577 fp = marker_pos;
1578 LISTBASE_FOREACH (MovieTrackingTrack *, track, &tracking_object->tracks) {
1579 if (track->flag & TRACK_HIDDEN) {
1580 continue;
1581 }
1582 const int act = track == active_track;
1583 const MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
1584
1585 if (ED_space_clip_marker_is_visible(sc, tracking_object, track, marker)) {
1586 if (!act) {
1587 copy_v2_v2(cur_pos, fp ? fp : marker->pos);
1588
1589 draw_marker_areas(sc, track, marker, cur_pos, width, height, 0, 1, position);
1590 draw_marker_slide_zones(sc, track, marker, cur_pos, 0, 1, 0, width, height, position);
1591 }
1592
1593 if (fp) {
1594 fp += 2;
1595 }
1596 }
1597 }
1598
1599 /* active marker would be displayed on top of everything else */
1600 if (active_track && (active_track->flag & TRACK_HIDDEN) == 0) {
1601 const MovieTrackingMarker *marker = BKE_tracking_marker_get(active_track, framenr);
1602
1603 if (ED_space_clip_marker_is_visible(sc, tracking_object, active_track, marker)) {
1604 copy_v2_v2(cur_pos, active_pos ? active_pos : marker->pos);
1605
1606 draw_marker_areas(sc, active_track, marker, cur_pos, width, height, 1, 1, position);
1607 draw_marker_slide_zones(sc, active_track, marker, cur_pos, 0, 1, 1, width, height, position);
1608 }
1609 }
1610
1611 if (sc->flag & SC_SHOW_BUNDLES) {
1612 float pos[4], vec[4], mat[4][4], aspy;
1613
1614 aspy = 1.0f / clip->tracking.camera.pixel_aspect;
1615 BKE_tracking_get_projection_matrix(tracking, tracking_object, framenr, width, height, mat);
1616
1618 immUniform1f("size", 3.0f);
1619 LISTBASE_FOREACH (MovieTrackingTrack *, track, &tracking_object->tracks) {
1620 if (track->flag & TRACK_HIDDEN || (track->flag & TRACK_HAS_BUNDLE) == 0) {
1621 continue;
1622 }
1623
1624 const MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
1625
1626 if (ED_space_clip_marker_is_visible(sc, tracking_object, track, marker)) {
1627 float npos[2];
1628 copy_v3_v3(vec, track->bundle_pos);
1629 vec[3] = 1;
1630
1631 mul_v4_m4v4(pos, mat, vec);
1632
1633 pos[0] = (pos[0] / (pos[3] * 2.0f) + 0.5f) * width;
1634 pos[1] = (pos[1] / (pos[3] * 2.0f) + 0.5f) * height * aspy;
1635
1636 BKE_tracking_distort_v2(tracking, width, height, pos, npos);
1637
1638 if (npos[0] >= 0.0f && npos[1] >= 0.0f && npos[0] <= width && npos[1] <= height * aspy) {
1639 vec[0] = (marker->pos[0] + track->offset[0]) * width;
1640 vec[1] = (marker->pos[1] + track->offset[1]) * height * aspy;
1641
1642 sub_v2_v2(vec, npos);
1643
1644 immUniformColor4fv((len_squared_v2(vec) < (3.0f * 3.0f)) ?
1645 blender::float4(0.0f, 1.0f, 0.0f, 1.0f) :
1646 blender::float4(1.0f, 0.0f, 0.0f, 1.0f));
1647
1649
1650 if (undistort) {
1651 immVertex2f(position, pos[0] / width, pos[1] / (height * aspy));
1652 }
1653 else {
1654 immVertex2f(position, npos[0] / width, npos[1] / (height * aspy));
1655 }
1656
1657 immEnd();
1658 }
1659 }
1660 }
1662 }
1663
1665
1666 if (sc->flag & SC_SHOW_NAMES) {
1667 /* scaling should be cleared before drawing texts, otherwise font would also be scaled */
1668 fp = marker_pos;
1669 LISTBASE_FOREACH (MovieTrackingTrack *, track, &tracking_object->tracks) {
1670 if (track->flag & TRACK_HIDDEN) {
1671 continue;
1672 }
1673
1674 const MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
1675
1676 if (ED_space_clip_marker_is_visible(sc, tracking_object, track, marker)) {
1677 const int act = track == active_track;
1678
1679 copy_v2_v2(cur_pos, fp ? fp : marker->pos);
1680
1681 draw_marker_texts(sc, track, marker, cur_pos, act, width, height, zoomx, zoomy);
1682
1683 if (fp) {
1684 fp += 2;
1685 }
1686 }
1687 }
1688 }
1689
1691
1692 if (marker_pos) {
1693 MEM_freeN(marker_pos);
1694 }
1695}
1696
1698 ARegion *region,
1699 MovieClip *clip,
1700 int width,
1701 int height,
1702 float zoomx,
1703 float zoomy)
1704{
1705 float x, y;
1706 const int n = 10;
1707 float tpos[2], grid[11][11][2];
1708 MovieTracking *tracking = &clip->tracking;
1709 bGPdata *gpd = nullptr;
1710 float aspy = 1.0f / tracking->camera.pixel_aspect;
1711 float dx = float(width) / n, dy = float(height) / n * aspy;
1712 float offsx = 0.0f, offsy = 0.0f;
1713
1714 if (!tracking->camera.focal) {
1715 return;
1716 }
1717
1718 if ((sc->flag & SC_SHOW_GRID) == 0 && (sc->flag & SC_MANUAL_CALIBRATION) == 0) {
1719 return;
1720 }
1721
1722 UI_view2d_view_to_region_fl(&region->v2d, 0.0f, 0.0f, &x, &y);
1723
1726 GPU_matrix_scale_2f(zoomx, zoomy);
1728 GPU_matrix_scale_2f(width, height);
1729
1730 uint position = GPU_vertformat_attr_add(
1731 immVertexFormat(), "pos", blender::gpu::VertAttrType::SFLOAT_32_32);
1732
1734
1735 /* grid */
1736 if (sc->overlay.flag & SC_SHOW_OVERLAYS && sc->flag & SC_SHOW_GRID) {
1737 float val[4][2], idx[4][2];
1738 float min[2], max[2];
1739
1740 for (int a = 0; a < 4; a++) {
1741 if (a < 2) {
1742 val[a][a % 2] = FLT_MAX;
1743 }
1744 else {
1745 val[a][a % 2] = -FLT_MAX;
1746 }
1747 }
1748
1749 for (int i = 0; i <= n; i++) {
1750 for (int j = 0; j <= n; j++) {
1751 if (i == 0 || j == 0 || i == n || j == n) {
1752 const float pos[2] = {dx * j, dy * i};
1753 BKE_tracking_distort_v2(tracking, width, height, pos, tpos);
1754
1755 for (int a = 0; a < 4; a++) {
1756 int ok;
1757
1758 if (a < 2) {
1759 ok = tpos[a % 2] < val[a][a % 2];
1760 }
1761 else {
1762 ok = tpos[a % 2] > val[a][a % 2];
1763 }
1764
1765 if (ok) {
1766 copy_v2_v2(val[a], tpos);
1767 idx[a][0] = j;
1768 idx[a][1] = i;
1769 }
1770 }
1771 }
1772 }
1773 }
1774
1776
1777 for (int a = 0; a < 4; a++) {
1778 const float pos[2] = {idx[a][0] * dx, idx[a][1] * dy};
1779
1780 BKE_tracking_undistort_v2(tracking, width, height, pos, tpos);
1781
1782 minmax_v2v2_v2(min, max, tpos);
1783 }
1784
1785 dx = (max[0] - min[0]) / n;
1786 dy = (max[1] - min[1]) / n;
1787
1788 for (int i = 0; i <= n; i++) {
1789 for (int j = 0; j <= n; j++) {
1790 const float pos[2] = {min[0] + dx * j, min[1] + dy * i};
1791
1792 BKE_tracking_distort_v2(tracking, width, height, pos, grid[i][j]);
1793
1794 grid[i][j][0] /= width;
1795 grid[i][j][1] /= height * aspy;
1796 }
1797 }
1798
1799 immUniformColor3f(1.0f, 0.0f, 0.0f);
1800
1801 for (int i = 0; i <= n; i++) {
1803
1804 for (int j = 0; j <= n; j++) {
1805 immVertex2fv(position, grid[i][j]);
1806 }
1807
1808 immEnd();
1809 }
1810
1811 for (int j = 0; j <= n; j++) {
1813
1814 for (int i = 0; i <= n; i++) {
1815 immVertex2fv(position, grid[i][j]);
1816 }
1817
1818 immEnd();
1819 }
1820 }
1821
1822 if (sc->gpencil_src != SC_GPENCIL_SRC_TRACK) {
1823 gpd = clip->gpd;
1824 }
1825
1826 if (sc->flag & SC_MANUAL_CALIBRATION && gpd) {
1827 bGPDlayer *layer = static_cast<bGPDlayer *>(gpd->layers.first);
1828
1829 while (layer) {
1830 bGPDframe *frame = static_cast<bGPDframe *>(layer->frames.first);
1831
1832 if (layer->flag & GP_LAYER_HIDE) {
1833 layer = layer->next;
1834 continue;
1835 }
1836
1837 immUniformColor4fv(layer->color);
1838
1839 GPU_line_width(layer->thickness);
1840 GPU_point_size(float(layer->thickness + 2));
1841
1842 while (frame) {
1843 bGPDstroke *stroke = static_cast<bGPDstroke *>(frame->strokes.first);
1844
1845 while (stroke) {
1846 if (stroke->flag & GP_STROKE_2DSPACE) {
1847 if (stroke->totpoints > 1) {
1848 for (int i = 0; i < stroke->totpoints - 1; i++) {
1849 float pos[2], npos[2], dpos[2], len;
1850 int steps;
1851
1852 pos[0] = (stroke->points[i].x + offsx) * width;
1853 pos[1] = (stroke->points[i].y + offsy) * height * aspy;
1854
1855 npos[0] = (stroke->points[i + 1].x + offsx) * width;
1856 npos[1] = (stroke->points[i + 1].y + offsy) * height * aspy;
1857
1858 len = len_v2v2(pos, npos);
1859 steps = ceil(len / 5.0f);
1860
1861 /* we want to distort only long straight lines */
1862 if (stroke->totpoints == 2) {
1863 BKE_tracking_undistort_v2(tracking, width, height, pos, pos);
1864 BKE_tracking_undistort_v2(tracking, width, height, npos, npos);
1865 }
1866
1867 sub_v2_v2v2(dpos, npos, pos);
1868 mul_v2_fl(dpos, 1.0f / steps);
1869
1870 immBegin(GPU_PRIM_LINE_STRIP, steps + 1);
1871
1872 for (int j = 0; j <= steps; j++) {
1873 BKE_tracking_distort_v2(tracking, width, height, pos, tpos);
1874 immVertex2f(position, tpos[0] / width, tpos[1] / (height * aspy));
1875
1876 add_v2_v2(pos, dpos);
1877 }
1878
1879 immEnd();
1880 }
1881 }
1882 else if (stroke->totpoints == 1) {
1884 immVertex2f(position, stroke->points[0].x + offsx, stroke->points[0].y + offsy);
1885 immEnd();
1886 }
1887 }
1888
1889 stroke = stroke->next;
1890 }
1891
1892 frame = frame->next;
1893 }
1894
1895 layer = layer->next;
1896 }
1897 }
1898
1900
1902}
1903
1904void clip_draw_main(const bContext *C, SpaceClip *sc, ARegion *region)
1905{
1907 Scene *scene = CTX_data_scene(C);
1908 ImBuf *ibuf = nullptr;
1909 int width, height;
1910 float zoomx, zoomy;
1911
1912 ED_space_clip_get_size(sc, &width, &height);
1913 ED_space_clip_get_zoom(sc, region, &zoomx, &zoomy);
1914
1915 /* if no clip, nothing to do */
1916 if (!clip) {
1917 ED_region_grid_draw(region, zoomx, zoomy, 0.0f, 0.0f);
1918 return;
1919 }
1920
1921 if (sc->flag & SC_SHOW_STABLE) {
1922 float translation[2];
1923 float aspect = clip->tracking.camera.pixel_aspect;
1924 float smat[4][4], ismat[4][4];
1925
1926 if ((sc->flag & SC_MUTE_FOOTAGE) == 0) {
1927 ibuf = ED_space_clip_get_stable_buffer(sc, sc->loc, &sc->scale, &sc->angle);
1928 }
1929
1930 if (ibuf != nullptr && width != ibuf->x) {
1931 mul_v2_v2fl(translation, sc->loc, float(width) / ibuf->x);
1932 }
1933 else {
1934 copy_v2_v2(translation, sc->loc);
1935 }
1936
1938 width, height, aspect, translation, sc->scale, sc->angle, sc->stabmat);
1939
1940 unit_m4(smat);
1941 smat[0][0] = 1.0f / width;
1942 smat[1][1] = 1.0f / height;
1943 invert_m4_m4(ismat, smat);
1944
1945 mul_m4_series(sc->unistabmat, smat, sc->stabmat, ismat);
1946 }
1947 else if ((sc->flag & SC_MUTE_FOOTAGE) == 0) {
1948 ibuf = ED_space_clip_get_buffer(sc);
1949
1950 zero_v2(sc->loc);
1951 sc->scale = 1.0f;
1952 unit_m4(sc->stabmat);
1953 unit_m4(sc->unistabmat);
1954 }
1955
1956 if (ibuf) {
1957 draw_movieclip_buffer(C, sc, region, ibuf, width, height, zoomx, zoomy);
1958 IMB_freeImBuf(ibuf);
1959 }
1960 else if (sc->flag & SC_MUTE_FOOTAGE) {
1961 draw_movieclip_muted(region, width, height, zoomx, zoomy);
1962 }
1963 else {
1964 ED_region_grid_draw(region, zoomx, zoomy, 0.0f, 0.0f);
1965 }
1966
1967 if (width && height) {
1968 draw_stabilization_border(sc, region, width, height, zoomx, zoomy);
1969 if (sc->overlay.flag & SC_SHOW_OVERLAYS)
1970 draw_tracking_tracks(sc, scene, region, clip, width, height, zoomx, zoomy);
1971 draw_distortion(sc, region, clip, width, height, zoomx, zoomy);
1972 }
1973}
1974
1976{
1977 Scene *scene = CTX_data_scene(C);
1979 if (clip) {
1980 draw_movieclip_cache(sc, region, clip, scene);
1981 draw_movieclip_notes(sc, region);
1982 }
1983}
1984
1986{
1989
1990 if (!clip) {
1991 return;
1992 }
1993
1994 if (onlyv2d) {
1995 bool is_track_source = sc->gpencil_src == SC_GPENCIL_SRC_TRACK;
1996 /* if manual calibration is used then grease pencil data
1997 * associated with the clip is already drawn in draw_distortion
1998 */
1999 if ((sc->flag & SC_MANUAL_CALIBRATION) == 0 || is_track_source) {
2002
2003 if (is_track_source) {
2004 const MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(
2005 &clip->tracking);
2006 MovieTrackingTrack *active_track = tracking_object->active_track;
2007
2008 if (active_track) {
2009 const int framenr = ED_space_clip_get_clip_frame_number(sc);
2010 MovieTrackingMarker *marker = BKE_tracking_marker_get(active_track, framenr);
2011
2013 }
2014 }
2015
2017
2019 }
2020 }
2021 else {
2023 }
2024}
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:613
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:2415
#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:387
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:2442
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:443
void BLF_draw(int fontid, const char *str, size_t str_len, ResultBLF *r_info=nullptr) ATTR_NONNULL(2)
Definition blf.cc:585
int BLF_height_max(int fontid) ATTR_WARN_UNUSED_RESULT
Definition blf.cc:850
void BLF_color4ubv(int fontid, const unsigned char rgba[4])
Definition blf.cc:452
void BLF_position(int fontid, float x, float y, float z)
Definition blf.cc:388
#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_UTF8(dst, format,...)
#define STRNCPY_UTF8(dst, src)
unsigned char uchar
unsigned int uint
#define INIT_MINMAX2(min, max)
#define UNUSED_VARS_NDEBUG(...)
#define ELEM(...)
@ MCLIP_USE_PROXY
@ MCLIP_PROXY_RENDER_UNDISTORT
@ MCLIP_PROXY_RENDER_SIZE_100
@ MCLIP_PROXY_RENDER_SIZE_FULL
@ SC_SHOW_OVERLAYS
@ 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
@ TRACK_CUSTOMCOLOR
@ TRACK_HIDDEN
@ TRACK_LOCKED
@ TRACK_HAS_BUNDLE
@ TRACKING_2D_STABILIZATION
@ TRACKING_RECONSTRUCTED
@ MARKER_TRACKED
@ MARKER_DISABLED
@ PLANE_MARKER_TRACKED
@ 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:791
void ED_region_info_draw(ARegion *region, const char *text, const float fill_color[4], bool full_redraw)
Definition area.cc:4128
void ED_region_cache_draw_cached_segments(ARegion *region, int num_segments, const int *points, int sfra, int efra)
Definition area.cc:4362
void ED_region_cache_draw_background(ARegion *region)
Definition area.cc:4312
void ED_region_cache_draw_curfra_label(int framenr, float x, float y)
Definition area.cc:4326
void ED_region_grid_draw(ARegion *region, float zoomx, float zoomy, float x0, float y0)
Definition area.cc:4156
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 immBindTexture(const char *name, blender::gpu::Texture *tex)
void immBindBuiltinProgram(GPUBuiltinShader shader_id)
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 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 immRectf(uint pos, float x1, float y1, float x2, float y2)
void imm_draw_box_checker_2d(float x1, float y1, float x2, float y2, bool clear_alpha=false)
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
void GPU_line_width(float width)
Definition gpu_state.cc:166
@ GPU_BLEND_NONE
Definition GPU_state.hh:85
@ GPU_BLEND_ALPHA
Definition GPU_state.hh:87
void GPU_logic_op_xor_set(bool enable)
Definition gpu_state.cc:88
void GPU_blend(GPUBlend blend)
Definition gpu_state.cc:42
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
void GPU_texture_unbind(blender::gpu::Texture *texture)
@ GPU_DATA_UBYTE
@ GPU_TEXTURE_USAGE_SHADER_READ
blender::gpu::Texture * GPU_texture_create_2d(const char *name, int width, int height, int mip_len, blender::gpu::TextureFormat format, eGPUTextureUsage usage, const float *data)
void GPU_texture_filter_mode(blender::gpu::Texture *texture, bool use_filter)
void GPU_texture_free(blender::gpu::Texture *texture)
void GPU_texture_update(blender::gpu::Texture *texture, eGPUDataFormat data_format, const void *data)
uint GPU_vertformat_attr_add(GPUVertFormat *format, blender::StringRef name, blender::gpu::VertAttrType type)
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:1739
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:1723
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:265
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:943
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:586
static void draw_movieclip_cache(SpaceClip *sc, ARegion *region, MovieClip *clip, Scene *scene)
Definition clip_draw.cc:131
@ PATH_POINT_FLAG_KEYFRAME
Definition clip_draw.cc:396
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:288
static void draw_track_path_points(const TrackPathPoint *path, uint position_attribute, const int start_point, const int num_points)
Definition clip_draw.cc:448
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:739
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:923
static float get_shortest_pattern_side(const MovieTrackingMarker *marker)
Definition clip_draw.cc:894
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:464
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:417
#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:705
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:404
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:495
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:305
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:349
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:907
static void draw_track_path_lines(const TrackPathPoint *path, uint position_attribute, const int start_point, const int num_points)
Definition clip_draw.cc:479
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:681
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)
nullptr float
#define SELECT
#define roundf(x)
#define str(s)
uint pos
uint col
#define ceil
TEX_TEMPLATE DataVec texture(T, FltCoord, float=0.0f) RET
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
#define sqrtf
#define ceilf
#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 SpaceClipOverlay overlay
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