diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-06-12 21:10:24 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-06-12 21:10:24 +0400 |
commit | 55ca0e7636b77a408ea70bf3117eff569e49954b (patch) | |
tree | 88560249a92547e6f94698e369b11201cf28ea39 | |
parent | 1719b86f74a757998c6edc8ffc578a14c724d1ff (diff) |
Make dopesheet settings per-tracking data
It was a bit confusing to synchronize settings used in pre-calculated
dopesheet channels which was storing in tracking data with settings
used for display which is in space data.
This was initially done by converting one flags to other and checking
if space's settings matches pre-calculated one, but that had several
issues if two different dopesheet are using different settings:
- Channels would be re-calculated on every redraw for each of spaces
- Dopesheet operators could fail due to the could be using channels
calculated for other space.
That was also quite nasty code checking if requested settings matches
pre-calculated one.
-rw-r--r-- | release/scripts/startup/bl_ui/space_clip.py | 5 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_tracking.h | 8 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/tracking.c | 32 | ||||
-rw-r--r-- | source/blender/editors/space_clip/space_clip.c | 4 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_space_types.h | 19 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_tracking_types.h | 18 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_space.c | 23 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_tracking.c | 43 |
8 files changed, 77 insertions, 75 deletions
diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index 2f2d95f78df..cef2a20710a 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -82,11 +82,12 @@ class CLIP_HT_header(Header): row.prop(sc, "show_filters", icon='DISCLOSURE_TRI_RIGHT', text="Filters") elif sc.view == 'DOPESHEET': + dopesheet = tracking.dopesheet layout.prop(sc, "view", text="", expand=True) layout.label(text="Sort by:") - layout.prop(sc, "dopesheet_sort_method", text="") - layout.prop(sc, "invert_dopesheet_sort", text="Invert") + layout.prop(dopesheet, "sort_method", text="") + layout.prop(dopesheet, "use_invert_sort", text="Invert") else: layout.prop(sc, "view", text="", expand=True) diff --git a/source/blender/blenkernel/BKE_tracking.h b/source/blender/blenkernel/BKE_tracking.h index 11013d54951..e6c98c72b55 100644 --- a/source/blender/blenkernel/BKE_tracking.h +++ b/source/blender/blenkernel/BKE_tracking.h @@ -171,7 +171,7 @@ void BKE_tracking_deselect_track(struct MovieTrackingTrack *track, int area); /* Dopesheet */ void BKE_tracking_dopesheet_tag_update(struct MovieTracking *tracking); -void BKE_tracking_dopesheet_update(struct MovieTracking *tracking, int sort_method, int inverse); +void BKE_tracking_dopesheet_update(struct MovieTracking *tracking); #define TRACK_SELECTED(track) ((track)->flag & SELECT || (track)->pat_flag & SELECT || (track)->search_flag & SELECT) @@ -202,10 +202,4 @@ void BKE_tracking_dopesheet_update(struct MovieTracking *tracking, int sort_meth #define TRACK_AREA_ALL (TRACK_AREA_POINT | TRACK_AREA_PAT | TRACK_AREA_SEARCH) -#define TRACK_SORT_NONE -1 -#define TRACK_SORT_NAME 0 -#define TRACK_SORT_LONGEST 1 -#define TRACK_SORT_TOTAL 2 -#define TRACK_SORT_AVERAGE_ERROR 3 - #endif diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index a9e75449811..33f7b22f64a 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -3545,40 +3545,34 @@ static void tracking_dopesheet_sort(MovieTracking *tracking, int sort_method, i { MovieTrackingDopesheet *dopesheet = &tracking->dopesheet; - if (dopesheet->sort_method == sort_method && dopesheet->sort_inverse == inverse) - return; - if (inverse) { - if (sort_method == TRACK_SORT_NAME) { + if (sort_method == TRACKING_DOPE_SORT_NAME) { BLI_sortlist(&dopesheet->channels, channels_alpha_inverse_sort); } - else if (sort_method == TRACK_SORT_LONGEST) { + else if (sort_method == TRACKING_DOPE_SORT_LONGEST) { BLI_sortlist(&dopesheet->channels, channels_longest_segment_inverse_sort); } - else if (sort_method == TRACK_SORT_TOTAL) { + else if (sort_method == TRACKING_DOPE_SORT_TOTAL) { BLI_sortlist(&dopesheet->channels, channels_total_track_inverse_sort); } - else if (sort_method == TRACK_SORT_AVERAGE_ERROR) { + else if (sort_method == TRACKING_DOPE_SORT_AVERAGE_ERROR) { BLI_sortlist(&dopesheet->channels, channels_average_error_inverse_sort); } } else { - if (sort_method == TRACK_SORT_NAME) { + if (sort_method == TRACKING_DOPE_SORT_NAME) { BLI_sortlist(&dopesheet->channels, channels_alpha_sort); } - else if (sort_method == TRACK_SORT_LONGEST) { + else if (sort_method == TRACKING_DOPE_SORT_LONGEST) { BLI_sortlist(&dopesheet->channels, channels_longest_segment_sort); } - else if (sort_method == TRACK_SORT_TOTAL) { + else if (sort_method == TRACKING_DOPE_SORT_TOTAL) { BLI_sortlist(&dopesheet->channels, channels_total_track_sort); } - else if (sort_method == TRACK_SORT_AVERAGE_ERROR) { + else if (sort_method == TRACKING_DOPE_SORT_AVERAGE_ERROR) { BLI_sortlist(&dopesheet->channels, channels_average_error_sort); } } - - dopesheet->sort_method = sort_method; - dopesheet->sort_inverse = inverse; } void BKE_tracking_dopesheet_tag_update(MovieTracking *tracking) @@ -3588,17 +3582,17 @@ void BKE_tracking_dopesheet_tag_update(MovieTracking *tracking) dopesheet->ok = FALSE; } -void BKE_tracking_dopesheet_update(MovieTracking *tracking, int sort_method, int inverse) +void BKE_tracking_dopesheet_update(MovieTracking *tracking) { MovieTrackingObject *object = BKE_tracking_active_object(tracking); MovieTrackingDopesheet *dopesheet = &tracking->dopesheet; MovieTrackingTrack *track; ListBase *tracksbase = BKE_tracking_object_tracks(tracking, object); + short sort_method = dopesheet->sort_method; + short inverse = dopesheet->flag & TRACKING_DOPE_SORT_INVERSE; - if (dopesheet->ok) { - tracking_dopesheet_sort(tracking, sort_method, inverse); + if (dopesheet->ok) return; - } tracking_dopesheet_free(dopesheet); @@ -3616,8 +3610,6 @@ void BKE_tracking_dopesheet_update(MovieTracking *tracking, int sort_method, int } } - dopesheet->sort_method = TRACK_SORT_NONE; - tracking_dopesheet_sort(tracking, sort_method, inverse); dopesheet->ok = TRUE; diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 9a8e0de3e84..2f684f9e330 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -1233,7 +1233,7 @@ static void dopesheet_area_draw(const bContext *C, ARegion *ar) short unit = 0; if (clip) - BKE_tracking_dopesheet_update(&clip->tracking, sc->dope_sort, sc->dope_flag & SC_DOPE_SORT_INVERSE); + BKE_tracking_dopesheet_update(&clip->tracking); /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); @@ -1294,7 +1294,7 @@ static void clip_channels_area_draw(const bContext *C, ARegion *ar) View2DScrollers *scrollers; if (clip) - BKE_tracking_dopesheet_update(&clip->tracking, sc->dope_sort, sc->dope_flag & SC_DOPE_SORT_INVERSE); + BKE_tracking_dopesheet_update(&clip->tracking); /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index cb905d7f768..e9a07bfbf29 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -1006,11 +1006,7 @@ typedef struct SpaceClip { void *draw_context; - /* dopesheet */ - short dope_sort; /* sort order in dopesheet view */ - short dope_flag; /* dopsheet view flags */ - - int around; /* pivot point for transforms */ + int around, pad4; /* pivot point for transforms */ /* **** mask editing **** */ struct Mask *mask; @@ -1058,19 +1054,6 @@ typedef enum eSpaceClip_View { SC_VIEW_DOPESHEET, } eSpaceClip_View; -/* SpaceClip->dope_sort */ -typedef enum eSpaceClip_Dopesheet_Sort { - SC_DOPE_SORT_NAME = 0, - SC_DOPE_SORT_LONGEST, - SC_DOPE_SORT_TOTAL, - SC_DOPE_SORT_AVERAGE_ERROR, -} eSpaceClip_Dopesheet_Sort; - -/* SpaceClip->dope_flag */ -typedef enum eSpaceClip_Dopesheet_Flag { - SC_DOPE_SORT_INVERSE = (1 << 0), -} eSpaceClip_Dopesheet_Flag; - /* SpaceClip->gpencil_src */ typedef enum eSpaceClip_GPencil_Source { SC_GPENCIL_SRC_CLIP = 0, diff --git a/source/blender/makesdna/DNA_tracking_types.h b/source/blender/makesdna/DNA_tracking_types.h index 84ae1835751..850d4361ab7 100644 --- a/source/blender/makesdna/DNA_tracking_types.h +++ b/source/blender/makesdna/DNA_tracking_types.h @@ -238,13 +238,16 @@ typedef struct MovieTrackingDopesheetChannel { } MovieTrackingDopesheetChannel; typedef struct MovieTrackingDopesheet { - int ok, pad; /* flag if dopesheet information is still relevant */ + int ok; /* flag if dopesheet information is still relevant */ + short sort_method; /* method to be used to sort tracks */ + short flag; /* dopesheet building flag such as inverted order of sort */ + + /* runtime stuff */ ListBase channels; int tot_channel; - short sort_method; /* method to be used to sort tracks */ - short sort_inverse; /* order of tracks is inverted */ + int pad; } MovieTrackingDopesheet; typedef struct MovieTracking { @@ -347,4 +350,13 @@ enum { #define TRACKING_CLEAN_DELETE_TRACK 1 #define TRACKING_CLEAN_DELETE_SEGMENT 2 +/* MovieTrackingDopesheet->sort_method */ +#define TRACKING_DOPE_SORT_NAME 0 +#define TRACKING_DOPE_SORT_LONGEST 1 +#define TRACKING_DOPE_SORT_TOTAL 2 +#define TRACKING_DOPE_SORT_AVERAGE_ERROR 3 + +/* MovieTrackingDopesheet->flag */ +#define TRACKING_DOPE_SORT_INVERSE (1 << 0) + #endif diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 81538d20a50..941e44e9f78 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -2985,14 +2985,6 @@ static void rna_def_space_clip(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; - static EnumPropertyItem dope_sort_items[] = { - {SC_DOPE_SORT_NAME, "NAME", 0, "Name", "Sort channels by their names"}, - {SC_DOPE_SORT_LONGEST, "LONGEST", 0, "Longest", "Sort channels by longest tracked segment"}, - {SC_DOPE_SORT_TOTAL, "TOTAL", 0, "Total", "Sort channels by overall amount of tracked segments"}, - {SC_DOPE_SORT_AVERAGE_ERROR, "AVERAGE_ERROR", 0, "Average Error", "Sort channels by average reprojection error of tracks after solve"}, - {0, NULL, 0, NULL, NULL} - }; - static EnumPropertyItem gpencil_source_items[] = { {SC_GPENCIL_SRC_CLIP, "CLIP", 0, "Clip", "Show grease pencil datablock which belongs to movie clip"}, {SC_GPENCIL_SRC_TRACK, "TRACK", 0, "Track", "Show grease pencil datablock which belongs to active track"}, @@ -3221,21 +3213,6 @@ static void rna_def_space_clip(BlenderRNA *brna) RNA_def_property_enum_items(prop, pivot_items); RNA_def_property_ui_text(prop, "Pivot Point", "Pivot center for rotation/scaling"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL); - - /* ** dopesheet ** */ - - /* dopesheet sort */ - prop = RNA_def_property(srna, "dopesheet_sort_method", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "dope_sort"); - RNA_def_property_enum_items(prop, dope_sort_items); - RNA_def_property_ui_text(prop, "Dopesheet Sort Field", "Method to be used to sort channels in dopesheet view"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL); - - /* invert_dopesheet_sort */ - prop = RNA_def_property(srna, "invert_dopesheet_sort", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "dope_flag", SC_DOPE_SORT_INVERSE); - RNA_def_property_ui_text(prop, "Invert Dopesheet Sort", "Invert sort order of dopesheet channels"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL); } diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index c95d04d005a..a2869a842ee 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -382,6 +382,14 @@ static void rna_tracking_markerSearch_update(Main *UNUSED(bmain), Scene *UNUSED( BKE_tracking_clamp_marker(marker, CLAMP_SEARCH_DIM); } +static void rna_trackingDopesheet_tagUpdate(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr) +{ + MovieClip *clip = (MovieClip *)ptr->id.data; + MovieTrackingDopesheet *dopesheet = &clip->tracking.dopesheet; + + dopesheet->ok = 0; +} + /* API */ static void add_tracks_to_base(MovieClip *clip, MovieTracking *tracking, ListBase *tracksbase, int frame, int number) @@ -1396,6 +1404,36 @@ static void rna_def_trackingObjects(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_ui_text(prop, "Active Object", "Active object in this tracking data object"); } +static void rna_def_trackingDopesheet(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem sort_items[] = { + {TRACKING_DOPE_SORT_NAME, "NAME", 0, "Name", "Sort channels by their names"}, + {TRACKING_DOPE_SORT_LONGEST, "LONGEST", 0, "Longest", "Sort channels by longest tracked segment"}, + {TRACKING_DOPE_SORT_TOTAL, "TOTAL", 0, "Total", "Sort channels by overall amount of tracked segments"}, + {TRACKING_DOPE_SORT_AVERAGE_ERROR, "AVERAGE_ERROR", 0, "Average Error", "Sort channels by average reprojection error of tracks after solve"}, + {0, NULL, 0, NULL, NULL} + }; + + srna = RNA_def_struct(brna, "MovieTrackingDopesheet", NULL); + RNA_def_struct_ui_text(srna, "Movie Tracking Dopesheet", "Match-moving dopesheet data"); + + /* dopesheet sort */ + prop = RNA_def_property(srna, "sort_method", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "sort_method"); + RNA_def_property_enum_items(prop, sort_items); + RNA_def_property_ui_text(prop, "Dopesheet Sort Field", "Method to be used to sort channels in dopesheet view"); + RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, "rna_trackingDopesheet_tagUpdate"); + + /* invert_dopesheet_sort */ + prop = RNA_def_property(srna, "use_invert_sort", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", TRACKING_DOPE_SORT_INVERSE); + RNA_def_property_ui_text(prop, "Invert Dopesheet Sort", "Invert sort order of dopesheet channels"); + RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, "rna_trackingDopesheet_tagUpdate"); +} + static void rna_def_tracking(BlenderRNA *brna) { StructRNA *srna; @@ -1409,6 +1447,7 @@ static void rna_def_tracking(BlenderRNA *brna) rna_def_trackingStabilization(brna); rna_def_trackingReconstruction(brna); rna_def_trackingObject(brna); + rna_def_trackingDopesheet(brna); srna = RNA_def_struct(brna, "MovieTracking", NULL); RNA_def_struct_path_func(srna, "rna_tracking_path"); @@ -1456,6 +1495,10 @@ static void rna_def_tracking(BlenderRNA *brna) "rna_tracking_active_object_index_range"); RNA_def_property_ui_text(prop, "Active Object Index", "Index of active object"); RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL); + + /* dopesheet */ + prop = RNA_def_property(srna, "dopesheet", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "MovieTrackingDopesheet"); } void RNA_def_tracking(BlenderRNA *brna) |