forked from bartvdbraak/blender
Camera tracking: switch dopesheet information to lazy calculation
All operators which changes tracking data now just tags dopsheet as outdated, actual re-calculaiton of happens only when this information is actually needed (like on dopesheet draw). This makes things a bit faster when there's no dopesheet visible in current screen and also makes it much easier to update dopesheet using dependency graph. Also renamed dopesheet_sort_order to dopesheet_sort_method in rna and internal stuff which makes much more sense and also correlated with naming in file browser.
This commit is contained in:
parent
5da2135eef
commit
48ead27366
@ -86,7 +86,7 @@ class CLIP_HT_header(Header):
|
||||
|
||||
if sc.view == 'DOPESHEET':
|
||||
layout.label(text="Sort by:")
|
||||
layout.prop(sc, "dopesheet_sort_order", text="")
|
||||
layout.prop(sc, "dopesheet_sort_method", text="")
|
||||
layout.prop(sc, "invert_dopesheet_sort", text="Invert")
|
||||
|
||||
layout.template_running_jobs()
|
||||
|
@ -165,8 +165,8 @@ void BKE_tracking_select_track(struct ListBase *tracksbase, struct MovieTracking
|
||||
void BKE_tracking_deselect_track(struct MovieTrackingTrack *track, int area);
|
||||
|
||||
/* Dopesheet */
|
||||
void BKE_tracking_update_dopesheet(struct MovieTracking *tracking);
|
||||
void BKE_tracking_dopesheet_sort(struct MovieTracking *tracking, int sort_order, int inverse);
|
||||
void BKE_tracking_dopesheet_tag_update(struct MovieTracking *tracking);
|
||||
void BKE_tracking_dopesheet_update(struct MovieTracking *tracking, int sort_method, int inverse);
|
||||
|
||||
#define TRACK_SELECTED(track) ((track)->flag&SELECT || (track)->pat_flag&SELECT || (track)->search_flag&SELECT)
|
||||
|
||||
|
@ -72,6 +72,7 @@
|
||||
#include "BKE_pointcache.h"
|
||||
#include "BKE_scene.h"
|
||||
#include "BKE_screen.h"
|
||||
#include "BKE_tracking.h"
|
||||
#include "BKE_utildefines.h"
|
||||
|
||||
#include "depsgraph_private.h"
|
||||
@ -2580,6 +2581,10 @@ static void dag_id_flush_update(Scene *sce, ID *id)
|
||||
}
|
||||
|
||||
if (idtype == ID_MC) {
|
||||
MovieClip *clip = (MovieClip *) id;
|
||||
|
||||
BKE_tracking_dopesheet_tag_update(&clip->tracking);
|
||||
|
||||
for (obt=bmain->object.first; obt; obt= obt->id.next) {
|
||||
bConstraint *con;
|
||||
for (con = obt->constraints.first; con; con=con->next) {
|
||||
|
@ -1376,7 +1376,7 @@ void BKE_tracking_sync(MovieTrackingContext *context)
|
||||
|
||||
context->sync_frame = newframe;
|
||||
|
||||
BKE_tracking_update_dopesheet(tracking);
|
||||
tracking->dopesheet.ok = FALSE;
|
||||
}
|
||||
|
||||
void BKE_tracking_sync_user(MovieClipUser *user, MovieTrackingContext *context)
|
||||
@ -3196,13 +3196,59 @@ static void channels_segments_calc(MovieTrackingDopesheetChannel *channel)
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_tracking_update_dopesheet(MovieTracking *tracking)
|
||||
static void tracking_dopesheet_sort(MovieTracking *tracking, int sort_method, int inverse)
|
||||
{
|
||||
MovieTrackingDopesheet *dopesheet = &tracking->dopesheet;
|
||||
|
||||
if (dopesheet->sort_method == sort_method && dopesheet->sort_inverse == inverse)
|
||||
return;
|
||||
|
||||
if (inverse) {
|
||||
if (sort_method == TRACK_SORT_NAME) {
|
||||
BLI_sortlist(&dopesheet->channels, channels_alpha_inverse_sort);
|
||||
}
|
||||
else if (sort_method == TRACK_SORT_LONGEST) {
|
||||
BLI_sortlist(&dopesheet->channels, channels_longest_segment_inverse_sort);
|
||||
}
|
||||
else if (sort_method == TRACK_SORT_TOTAL) {
|
||||
BLI_sortlist(&dopesheet->channels, channels_total_track_inverse_sort);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (sort_method == TRACK_SORT_NAME) {
|
||||
BLI_sortlist(&dopesheet->channels, channels_alpha_sort);
|
||||
}
|
||||
else if (sort_method == TRACK_SORT_LONGEST) {
|
||||
BLI_sortlist(&dopesheet->channels, channels_longest_segment_sort);
|
||||
}
|
||||
else if (sort_method == TRACK_SORT_TOTAL) {
|
||||
BLI_sortlist(&dopesheet->channels, channels_total_track_sort);
|
||||
}
|
||||
}
|
||||
|
||||
dopesheet->sort_method = sort_method;
|
||||
dopesheet->sort_inverse = inverse;
|
||||
}
|
||||
|
||||
void BKE_tracking_dopesheet_tag_update(MovieTracking *tracking)
|
||||
{
|
||||
MovieTrackingDopesheet *dopesheet = &tracking->dopesheet;
|
||||
|
||||
dopesheet->ok = FALSE;
|
||||
}
|
||||
|
||||
void BKE_tracking_dopesheet_update(MovieTracking *tracking, int sort_method, int inverse)
|
||||
{
|
||||
MovieTrackingObject *object = BKE_tracking_active_object(tracking);
|
||||
MovieTrackingDopesheet *dopesheet = &tracking->dopesheet;
|
||||
MovieTrackingTrack *track;
|
||||
ListBase *tracksbase = BKE_tracking_object_tracks(tracking, object);
|
||||
|
||||
if (dopesheet->ok) {
|
||||
tracking_dopesheet_sort(tracking, sort_method, inverse);
|
||||
return;
|
||||
}
|
||||
|
||||
tracking_dopesheet_free(dopesheet);
|
||||
|
||||
for (track = tracksbase->first; track; track = track->next) {
|
||||
@ -3219,40 +3265,9 @@ void BKE_tracking_update_dopesheet(MovieTracking *tracking)
|
||||
}
|
||||
}
|
||||
|
||||
dopesheet->sort_order = TRACK_SORT_NONE;
|
||||
dopesheet->sort_inverse = -1;
|
||||
}
|
||||
|
||||
void BKE_tracking_dopesheet_sort(MovieTracking *tracking, int sort_order, int inverse)
|
||||
{
|
||||
MovieTrackingDopesheet *dopesheet = &tracking->dopesheet;
|
||||
|
||||
if (dopesheet->sort_order == sort_order && dopesheet->sort_inverse == inverse)
|
||||
return;
|
||||
|
||||
if (inverse) {
|
||||
if (sort_order == TRACK_SORT_NAME) {
|
||||
BLI_sortlist(&dopesheet->channels, channels_alpha_inverse_sort);
|
||||
}
|
||||
else if (sort_order == TRACK_SORT_LONGEST) {
|
||||
BLI_sortlist(&dopesheet->channels, channels_longest_segment_inverse_sort);
|
||||
}
|
||||
else if (sort_order == TRACK_SORT_TOTAL) {
|
||||
BLI_sortlist(&dopesheet->channels, channels_total_track_inverse_sort);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (sort_order == TRACK_SORT_NAME) {
|
||||
BLI_sortlist(&dopesheet->channels, channels_alpha_sort);
|
||||
}
|
||||
else if (sort_order == TRACK_SORT_LONGEST) {
|
||||
BLI_sortlist(&dopesheet->channels, channels_longest_segment_sort);
|
||||
}
|
||||
else if (sort_order == TRACK_SORT_TOTAL) {
|
||||
BLI_sortlist(&dopesheet->channels, channels_total_track_sort);
|
||||
}
|
||||
}
|
||||
|
||||
dopesheet->sort_order = sort_order;
|
||||
dopesheet->sort_inverse = inverse;
|
||||
dopesheet->sort_method = TRACK_SORT_NONE;
|
||||
|
||||
tracking_dopesheet_sort(tracking, sort_method, inverse);
|
||||
|
||||
dopesheet->ok = TRUE;
|
||||
}
|
||||
|
@ -6170,21 +6170,6 @@ static void direct_link_movieTracks(FileData *fd, ListBase *tracksbase)
|
||||
}
|
||||
}
|
||||
|
||||
static void direct_link_movieDopesheet(FileData *fd, MovieTrackingDopesheet *dopesheet)
|
||||
{
|
||||
MovieTrackingDopesheetChannel *channel;
|
||||
|
||||
link_list(fd, &dopesheet->channels);
|
||||
|
||||
channel = dopesheet->channels.first;
|
||||
while (channel) {
|
||||
channel->track = newdataadr(fd, channel->track);
|
||||
channel->segments = newdataadr(fd, channel->segments);
|
||||
|
||||
channel = channel->next;
|
||||
}
|
||||
}
|
||||
|
||||
static void direct_link_movieclip(FileData *fd, MovieClip *clip)
|
||||
{
|
||||
MovieTracking *tracking= &clip->tracking;
|
||||
@ -6211,6 +6196,9 @@ static void direct_link_movieclip(FileData *fd, MovieClip *clip)
|
||||
clip->tracking.stabilization.scaleibuf= NULL;
|
||||
clip->tracking.stabilization.rot_track= newdataadr(fd, clip->tracking.stabilization.rot_track);
|
||||
|
||||
clip->tracking.dopesheet.ok = 0;
|
||||
clip->tracking.dopesheet.channels.first = clip->tracking.dopesheet.channels.last = NULL;
|
||||
|
||||
link_list(fd, &tracking->objects);
|
||||
|
||||
object= tracking->objects.first;
|
||||
@ -6220,8 +6208,6 @@ static void direct_link_movieclip(FileData *fd, MovieClip *clip)
|
||||
|
||||
object= object->next;
|
||||
}
|
||||
|
||||
direct_link_movieDopesheet(fd, &clip->tracking.dopesheet);
|
||||
}
|
||||
|
||||
static void lib_link_movieclip(FileData *fd, Main *main)
|
||||
|
@ -2679,19 +2679,6 @@ static void write_movieTracks(WriteData *wd, ListBase *tracks)
|
||||
}
|
||||
}
|
||||
|
||||
static void write_movieDopesheet(WriteData *wd, MovieTrackingDopesheet *dopesheet)
|
||||
{
|
||||
MovieTrackingDopesheetChannel *channel;
|
||||
|
||||
channel = dopesheet->channels.first;
|
||||
while (channel) {
|
||||
writestruct(wd, DATA, "MovieTrackingDopesheetChannel", 1, channel);
|
||||
writedata(wd, DATA, 2 * channel->tot_segment * sizeof(int), channel->segments);
|
||||
|
||||
channel = channel->next;
|
||||
}
|
||||
}
|
||||
|
||||
static void write_movieReconstruction(WriteData *wd, MovieTrackingReconstruction *reconstruction)
|
||||
{
|
||||
if (reconstruction->camnr)
|
||||
@ -2724,8 +2711,6 @@ static void write_movieclips(WriteData *wd, ListBase *idbase)
|
||||
|
||||
object= object->next;
|
||||
}
|
||||
|
||||
write_movieDopesheet(wd, &tracking->dopesheet);
|
||||
}
|
||||
|
||||
clip= clip->id.next;
|
||||
|
@ -72,8 +72,6 @@ void ED_space_clip_free_texture_buffer(struct SpaceClip *sc);
|
||||
|
||||
int ED_space_clip_show_trackedit(struct SpaceClip *sc);
|
||||
|
||||
void ED_space_clip_update_dopesheet(struct SpaceClip *sc);
|
||||
|
||||
/* clip_ops.c */
|
||||
void ED_operatormacros_clip(void);
|
||||
|
||||
|
@ -552,11 +552,3 @@ int ED_space_clip_show_trackedit(SpaceClip *sc)
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void ED_space_clip_update_dopesheet(SpaceClip *sc)
|
||||
{
|
||||
MovieClip *clip = sc->clip;
|
||||
MovieTracking *tracking = &clip->tracking;
|
||||
|
||||
BKE_tracking_update_dopesheet(tracking);
|
||||
}
|
||||
|
@ -194,11 +194,11 @@ void clip_delete_track(bContext *C, MovieClip *clip, ListBase *tracksbase, Movie
|
||||
|
||||
if (update_stab) {
|
||||
tracking->stabilization.ok = FALSE;
|
||||
|
||||
DAG_id_tag_update(&clip->id, 0);
|
||||
WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, clip);
|
||||
}
|
||||
|
||||
DAG_id_tag_update(&clip->id, 0);
|
||||
|
||||
if (has_bundle)
|
||||
WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, NULL);
|
||||
}
|
||||
|
@ -1135,7 +1135,7 @@ static void dopesheet_area_draw(const bContext *C, ARegion *ar)
|
||||
View2DScrollers *scrollers;
|
||||
short unit = 0;
|
||||
|
||||
BKE_tracking_dopesheet_sort(&clip->tracking, sc->dope_sort, sc->dope_flag & SC_DOPE_SORT_INVERSE);
|
||||
BKE_tracking_dopesheet_update(&clip->tracking, sc->dope_sort, sc->dope_flag & SC_DOPE_SORT_INVERSE);
|
||||
|
||||
/* clear and setup matrix */
|
||||
UI_ThemeClearColor(TH_BACK);
|
||||
@ -1194,7 +1194,7 @@ static void clip_channels_area_draw(const bContext *C, ARegion *ar)
|
||||
View2D *v2d = &ar->v2d;
|
||||
View2DScrollers *scrollers;
|
||||
|
||||
BKE_tracking_dopesheet_sort(&clip->tracking, sc->dope_sort, sc->dope_flag & SC_DOPE_SORT_INVERSE);
|
||||
BKE_tracking_dopesheet_update(&clip->tracking, sc->dope_sort, sc->dope_flag & SC_DOPE_SORT_INVERSE);
|
||||
|
||||
/* clear and setup matrix */
|
||||
UI_ThemeClearColor(TH_BACK);
|
||||
|
@ -95,8 +95,6 @@ static void add_marker(SpaceClip *sc, float x, float y)
|
||||
BKE_tracking_select_track(tracksbase, track, TRACK_AREA_ALL, 0);
|
||||
|
||||
clip->tracking.act_track = track;
|
||||
|
||||
ED_space_clip_update_dopesheet(sc);
|
||||
}
|
||||
|
||||
static int add_marker_exec(bContext *C, wmOperator *op)
|
||||
@ -176,8 +174,6 @@ static int delete_track_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
/* nothing selected now, unlock view so it can be scrolled nice again */
|
||||
sc->flag &= ~SC_LOCK_SELECTION;
|
||||
|
||||
ED_space_clip_update_dopesheet(sc);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
@ -229,8 +225,6 @@ static int delete_marker_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
sc->flag &= ~SC_LOCK_SELECTION;
|
||||
}
|
||||
|
||||
ED_space_clip_update_dopesheet(sc);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
@ -795,8 +789,9 @@ static int mouse_select(bContext *C, float co[2], int extend)
|
||||
sc->ylockof = 0.0f;
|
||||
}
|
||||
|
||||
BKE_tracking_dopesheet_tag_update(tracking);
|
||||
|
||||
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL);
|
||||
ED_space_clip_update_dopesheet(sc);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@ -868,8 +863,9 @@ static int border_select_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
MovieClip *clip = ED_space_clip(sc);
|
||||
MovieTracking *tracking = &clip->tracking;
|
||||
MovieTrackingTrack *track;
|
||||
ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking);
|
||||
ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
|
||||
rcti rect;
|
||||
rctf rectf;
|
||||
int change = FALSE, mode, extend;
|
||||
@ -908,7 +904,7 @@ static int border_select_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
|
||||
if (change) {
|
||||
ED_space_clip_update_dopesheet(sc);
|
||||
BKE_tracking_dopesheet_tag_update(tracking);
|
||||
|
||||
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL);
|
||||
|
||||
@ -956,8 +952,9 @@ static int circle_select_exec(bContext *C, wmOperator *op)
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
MovieClip *clip = ED_space_clip(sc);
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
MovieTracking *tracking = &clip->tracking;
|
||||
MovieTrackingTrack *track;
|
||||
ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking);
|
||||
ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
|
||||
int x, y, radius, width, height, mode, change = FALSE;
|
||||
float zoomx, zoomy, offset[2], ellipse[2];
|
||||
|
||||
@ -994,7 +991,7 @@ static int circle_select_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
|
||||
if (change) {
|
||||
ED_space_clip_update_dopesheet(sc);
|
||||
BKE_tracking_dopesheet_tag_update(tracking);
|
||||
|
||||
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL);
|
||||
|
||||
@ -1033,9 +1030,10 @@ static int select_all_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
MovieClip *clip = ED_space_clip(sc);
|
||||
MovieTracking *tracking = &clip->tracking;
|
||||
MovieTrackingTrack *track = NULL; /* selected track */
|
||||
MovieTrackingMarker *marker;
|
||||
ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking);
|
||||
ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
|
||||
int action = RNA_enum_get(op->ptr, "action");
|
||||
int framenr = sc->user.framenr;
|
||||
int has_selection = FALSE;
|
||||
@ -1092,7 +1090,7 @@ static int select_all_exec(bContext *C, wmOperator *op)
|
||||
if (!has_selection)
|
||||
sc->flag &= ~SC_LOCK_SELECTION;
|
||||
|
||||
ED_space_clip_update_dopesheet(sc);
|
||||
BKE_tracking_dopesheet_tag_update(tracking);
|
||||
|
||||
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL);
|
||||
|
||||
@ -1174,7 +1172,7 @@ static int select_groped_exec(bContext *C, wmOperator *op)
|
||||
track = track->next;
|
||||
}
|
||||
|
||||
ED_space_clip_update_dopesheet(sc);
|
||||
BKE_tracking_dopesheet_tag_update(tracking);
|
||||
|
||||
WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, clip);
|
||||
|
||||
@ -2745,7 +2743,7 @@ static int hide_tracks_exec(bContext *C, wmOperator *op)
|
||||
sc->flag &= ~SC_LOCK_SELECTION;
|
||||
}
|
||||
|
||||
BKE_tracking_update_dopesheet(tracking);
|
||||
BKE_tracking_dopesheet_tag_update(tracking);
|
||||
|
||||
WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, NULL);
|
||||
|
||||
@ -2776,7 +2774,8 @@ static int hide_tracks_clear_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
MovieClip *clip = ED_space_clip(sc);
|
||||
ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking);
|
||||
MovieTracking *tracking = &clip->tracking;
|
||||
ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
|
||||
MovieTrackingTrack *track;
|
||||
|
||||
track = tracksbase->first;
|
||||
@ -2786,6 +2785,8 @@ static int hide_tracks_clear_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
track = track->next;
|
||||
}
|
||||
|
||||
BKE_tracking_dopesheet_tag_update(tracking);
|
||||
|
||||
WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
|
@ -205,10 +205,12 @@ typedef struct MovieTrackingDopesheetChannel {
|
||||
} MovieTrackingDopesheetChannel;
|
||||
|
||||
typedef struct MovieTrackingDopesheet {
|
||||
int ok, pad; /* flag if dopesheet information is still relevant */
|
||||
|
||||
ListBase channels;
|
||||
int tot_channel;
|
||||
|
||||
short sort_order; /* order in which tracks are stored */
|
||||
short sort_method; /* method to be used to sort tracks */
|
||||
short sort_inverse; /* order of tracks is inverted */
|
||||
} MovieTrackingDopesheet;
|
||||
|
||||
|
@ -3122,10 +3122,10 @@ static void rna_def_space_clip(BlenderRNA *brna)
|
||||
/* ** dopesheet ** */
|
||||
|
||||
/* dopesheet sort */
|
||||
prop = RNA_def_property(srna, "dopesheet_sort_order", PROP_ENUM, PROP_NONE);
|
||||
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", "Field used to sort channels in dopesheet view");
|
||||
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 */
|
||||
|
Loading…
Reference in New Issue
Block a user