Tracking: Add utility function to get RNA path prefix for given track
authorSergey Sharybin <sergey.vfx@gmail.com>
Tue, 19 Dec 2017 12:09:39 +0000 (13:09 +0100)
committerSergey Sharybin <sergey.vfx@gmail.com>
Tue, 19 Dec 2017 12:09:39 +0000 (13:09 +0100)
Some code could be de-duplicated with the full path case, but that's
for another rainy day i guess.

source/blender/blenkernel/BKE_tracking.h
source/blender/blenkernel/intern/tracking.c

index b44f90cbf7343a86bd6feb120655adf0238b3ee2..13302caa09d840fdd979976bee873dc2a2623543 100644 (file)
@@ -310,11 +310,21 @@ void BKE_tracking_get_rna_path_for_track(
         const struct MovieTrackingTrack *track,
         char *rna_path,
         size_t rna_path_len);
+void BKE_tracking_get_rna_path_prefix_for_track(
+        const struct MovieTracking *tracking,
+        const struct MovieTrackingTrack *track,
+        char *rna_path,
+        size_t rna_path_len);
 void BKE_tracking_get_rna_path_for_plane_track(
         const struct MovieTracking *tracking,
         const struct MovieTrackingPlaneTrack *plane_track,
         char *rna_path,
         size_t rna_path_len);
+void BKE_tracking_get_rna_path_prefix_for_plane_track(
+        const struct MovieTracking *tracking,
+        const struct MovieTrackingPlaneTrack *plane_track,
+        char *rna_path,
+        size_t rna_path_len);
 
 /* **** Utility macros **** */
 
index 7890f17c4dfdb27c4f02d5a32ff19a51b39cfa75..f9d34534a450ff1badf067dacb12223d3fa52ddc 100644 (file)
@@ -2992,6 +2992,26 @@ void BKE_tracking_get_rna_path_for_track(
        }
 }
 
+void BKE_tracking_get_rna_path_prefix_for_track(
+        const struct MovieTracking *tracking,
+        const struct MovieTrackingTrack *track,
+        char *rna_path,
+        size_t rna_path_len)
+{
+       MovieTrackingObject *object =
+               BKE_tracking_find_object_for_track(tracking, track);
+       if (object == NULL) {
+               BLI_snprintf(rna_path, rna_path_len, "tracking.tracks");
+       }
+       else {
+               char object_name_esc[MAX_NAME * 2];
+               BLI_strescape(object_name_esc, object->name, sizeof(object_name_esc));
+               BLI_snprintf(rna_path, rna_path_len,
+                            "tracking.objects[\"%s\"]",
+                            object_name_esc);
+       }
+}
+
 void BKE_tracking_get_rna_path_for_plane_track(
         const struct MovieTracking *tracking,
         const struct MovieTrackingPlaneTrack *plane_track,
@@ -3016,3 +3036,23 @@ void BKE_tracking_get_rna_path_for_plane_track(
                             track_name_esc);
        }
 }
+
+void BKE_tracking_get_rna_path_prefix_for_plane_track(
+        const struct MovieTracking *tracking,
+        const struct MovieTrackingPlaneTrack *plane_track,
+        char *rna_path,
+        size_t rna_path_len)
+{
+       MovieTrackingObject *object =
+               BKE_tracking_find_object_for_plane_track(tracking, plane_track);
+       if (object == NULL) {
+               BLI_snprintf(rna_path, rna_path_len, "tracking.plane_tracks");
+       }
+       else {
+               char object_name_esc[MAX_NAME * 2];
+               BLI_strescape(object_name_esc, object->name, sizeof(object_name_esc));
+               BLI_snprintf(rna_path, rna_path_len,
+                            "tracking.objects[\"%s\"].plane_tracks",
+                            object_name_esc);
+       }
+}