Tracking: Highlight keyframes in path visualization
authorSergey Sharybin <sergey.vfx@gmail.com>
Mon, 16 Sep 2019 10:43:51 +0000 (12:43 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Tue, 24 Sep 2019 15:20:16 +0000 (17:20 +0200)
This gives better idea of what's going on with your track. Example:

{F693806}

Color of keyframes are configurable from theme editor of clip editor.

Reviewers: keir, brecht, Severin

Differential Revision: https://developer.blender.org/D2772

release/datafiles/userdef/userdef_default_theme.c
source/blender/blenloader/intern/versioning_userdef.c
source/blender/editors/include/UI_resources.h
source/blender/editors/interface/resources.c
source/blender/editors/space_clip/clip_draw.c
source/blender/makesdna/DNA_userdef_types.h
source/blender/makesrna/intern/rna_userdef.c

index ff2a5ae2739d6ce0cd5ca31980ea759e388f3641..80bed03debf89815773fb9d4751745dcce5f17c1 100644 (file)
@@ -914,6 +914,8 @@ const bTheme U_theme_default = {
     .lock_marker = RGBA(0x7f7f7fff),
     .path_before = RGBA(0xff0000ff),
     .path_after = RGBA(0x0000ffff),
+    .path_keyframe_before = RGBA(0xffc4c4ff),
+    .path_keyframe_after = RGBA(0xc4c4ffff),
     .gp_vertex_size = 1,
     .metadatatext = RGBA(0xffffffff),
   },
index 71077d5a89d41e7abf28b5c81d556c1059cb692f..ad11be1a5f54bd053cb856aafb74dfb11bd3597b 100644 (file)
@@ -151,6 +151,8 @@ static void do_versions_theme(const UserDef *userdef, bTheme *btheme)
   {
     FROM_DEFAULT_V4_UCHAR(space_file.execution_buts);
     FROM_DEFAULT_V4_UCHAR(tui.icon_folder);
+    FROM_DEFAULT_V4_UCHAR(space_clip.path_keyframe_before);
+    FROM_DEFAULT_V4_UCHAR(space_clip.path_keyframe_after);
   }
 
 #undef FROM_DEFAULT_V4_UCHAR
index 1c317ac458bf1479741836e029ae0b10e6cfaf32..76ab4a53eb83a7e3d7e395adac82c4043fde919f 100644 (file)
@@ -234,6 +234,8 @@ typedef enum ThemeColorID {
   TH_DIS_MARKER,
   TH_PATH_BEFORE,
   TH_PATH_AFTER,
+  TH_PATH_KEYFRAME_BEFORE,
+  TH_PATH_KEYFRAME_AFTER,
   TH_CAMERA_PATH,
   TH_LOCK_MARKER,
 
index ae161f1017cdcaf10c7e85e6e3eff6f654c2028a..8a570933a3303e385270545c21d876267d4140e4 100644 (file)
@@ -779,6 +779,12 @@ const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
         case TH_PATH_AFTER:
           cp = ts->path_after;
           break;
+        case TH_PATH_KEYFRAME_BEFORE:
+          cp = ts->path_keyframe_before;
+          break;
+        case TH_PATH_KEYFRAME_AFTER:
+          cp = ts->path_keyframe_after;
+          break;
         case TH_CAMERA_PATH:
           cp = ts->camera_path;
           break;
index c847c7d07bba64d0c7603165bf6b625dcefc9c24..80b58954c8f5764963e63c6e72780d034792238b 100644 (file)
@@ -473,6 +473,21 @@ static void draw_track_path_points(const TrackPathPoint *path,
   immEnd();
 }
 
+static void draw_track_path_keyframe_points(const TrackPathPoint *path,
+                                            uint position_attribute,
+                                            const int start_point,
+                                            const int num_points)
+{
+  immBeginAtMost(GPU_PRIM_POINTS, num_points);
+  for (int i = 0; i < num_points; i++) {
+    const TrackPathPoint *point = &path[i + start_point];
+    if (point->flag & PATH_POINT_FLAG_KEYFRAME) {
+      immVertex2fv(position_attribute, point->co);
+    }
+  }
+  immEnd();
+}
+
 static void draw_track_path_lines(const TrackPathPoint *path,
                                   uint position_attribute,
                                   const int start_point,
@@ -533,6 +548,8 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin
     if (TRACK_VIEW_SELECTED(sc, track)) {
       GPU_point_size(5.0f);
       draw_track_path_points(path, position_attribute, path_start_index, num_all_points);
+      GPU_point_size(7.0f);
+      draw_track_path_keyframe_points(path, position_attribute, path_start_index, num_all_points);
     }
     /* Draw darker outline for actual path, all line segments at once. */
     GPU_line_width(3.0f);
@@ -553,6 +570,13 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin
   immUniformThemeColor(TH_PATH_AFTER);
   draw_track_path_lines(path, position_attribute, path_center_index, num_points_after);
 
+  /* Draw all bigger points corresponding to keyframes. */
+  GPU_point_size(5.0f);
+  immUniformThemeColor(TH_PATH_KEYFRAME_BEFORE);
+  draw_track_path_keyframe_points(path, position_attribute, path_start_index, num_points_before);
+  immUniformThemeColor(TH_PATH_KEYFRAME_AFTER);
+  draw_track_path_keyframe_points(path, position_attribute, path_center_index, num_points_after);
+
   if (path != path_static) {
     MEM_freeN(path);
   }
index 1110b0fb8b50ca958fa6536c0dd83bf06a4bbe4a..4006cbc977e1ac0b58cadbd83e737f32752a8779 100644 (file)
@@ -345,6 +345,7 @@ typedef struct ThemeSpace {
       lock_marker[4];
   unsigned char bundle_solid[4];
   unsigned char path_before[4], path_after[4];
+  unsigned char path_keyframe_before[4], path_keyframe_after[4];
   unsigned char camera_path[4];
   unsigned char _pad1[2];
 
index 494bebc9b2092cb2551be71649cb06956304ab9a..bba4bc1cb543cc46e141fbdad5885982355c3425 100644 (file)
@@ -3397,6 +3397,16 @@ static void rna_def_userdef_theme_space_clip(BlenderRNA *brna)
   RNA_def_property_ui_text(prop, "Path After", "Color of path after current frame");
   RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
 
+  prop = RNA_def_property(srna, "path_keyframe_before", PROP_FLOAT, PROP_COLOR_GAMMA);
+  RNA_def_property_array(prop, 3);
+  RNA_def_property_ui_text(prop, "Path Before", "Color of path before current frame");
+  RNA_def_property_update(prop, 0, "rna_userdef_update");
+
+  prop = RNA_def_property(srna, "path_keyframe_after", PROP_FLOAT, PROP_COLOR_GAMMA);
+  RNA_def_property_array(prop, 3);
+  RNA_def_property_ui_text(prop, "Path After", "Color of path after current frame");
+  RNA_def_property_update(prop, 0, "rna_userdef_update");
+
   prop = RNA_def_property(srna, "frame_current", PROP_FLOAT, PROP_COLOR_GAMMA);
   RNA_def_property_float_sdna(prop, NULL, "cframe");
   RNA_def_property_array(prop, 3);