[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46089] branches/soc-2011-tomato/source/ blender: Tomato: refactoring of dopesheet to allow different sort orders in list of channels

Sergey Sharybin sergey.vfx at gmail.com
Sun Apr 29 22:04:15 CEST 2012


Revision: 46089
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46089
Author:   nazgul
Date:     2012-04-29 20:04:12 +0000 (Sun, 29 Apr 2012)
Log Message:
-----------
Tomato: refactoring of dopesheet to allow different sort orders in list of channels

Store list of channels displaying in dopesheet separately from list of tracks.
This allows to re-sort channels in dopesheet independently from list of all
tracks (currently only alphabetic sorting is implemented).

This also allows to cache assorted information (like tracked segments of track)
but currently such a things are not bottlenecks and could be done after merge
dopesheet view into trunk.

TODO:
- Still have some deadlocks when drawing selected channels.
  Skipping channel background or keyframe drawing helps here but
  this need to be resolved.
- Bump sub-version and wrote code needed to convert pre-dopesheet interface
  with opened curve view displaying properly.
- Probably it'll worth caching tracked segments.

Modified Paths:
--------------
    branches/soc-2011-tomato/source/blender/blenkernel/BKE_tracking.h
    branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c
    branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c
    branches/soc-2011-tomato/source/blender/blenloader/intern/readfile.c
    branches/soc-2011-tomato/source/blender/blenloader/intern/writefile.c
    branches/soc-2011-tomato/source/blender/editors/include/ED_clip.h
    branches/soc-2011-tomato/source/blender/editors/space_clip/clip_dopesheet_draw.c
    branches/soc-2011-tomato/source/blender/editors/space_clip/clip_dopesheet_ops.c
    branches/soc-2011-tomato/source/blender/editors/space_clip/clip_editor.c
    branches/soc-2011-tomato/source/blender/editors/space_clip/clip_graph_ops.c
    branches/soc-2011-tomato/source/blender/editors/space_clip/tracking_ops.c
    branches/soc-2011-tomato/source/blender/makesdna/DNA_tracking_types.h

Modified: branches/soc-2011-tomato/source/blender/blenkernel/BKE_tracking.h
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/BKE_tracking.h	2012-04-29 18:53:43 UTC (rev 46088)
+++ branches/soc-2011-tomato/source/blender/blenkernel/BKE_tracking.h	2012-04-29 20:04:12 UTC (rev 46089)
@@ -164,6 +164,9 @@
 void BKE_tracking_select_track(struct ListBase *tracksbase, struct MovieTrackingTrack *track, int area, int extend);
 void BKE_tracking_deselect_track(struct MovieTrackingTrack *track, int area);
 
+/* Dopesheet */
+void BKE_tracking_update_dopesheet(struct MovieTracking *tracking);
+
 #define TRACK_SELECTED(track)				((track)->flag&SELECT || (track)->pat_flag&SELECT || (track)->search_flag&SELECT)
 
 #define TRACK_AREA_SELECTED(track, area)	((area)==TRACK_AREA_POINT ? (track)->flag&SELECT : \

Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c	2012-04-29 18:53:43 UTC (rev 46088)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c	2012-04-29 20:04:12 UTC (rev 46089)
@@ -453,7 +453,7 @@
 MovieClip *BKE_movieclip_file_add(const char *name)
 {
 	MovieClip *clip;
-	MovieClipUser user;
+	MovieClipUser user = {0};
 	int file, len, width, height;
 	const char *libname;
 	char str[FILE_MAX], strtest[FILE_MAX];

Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c	2012-04-29 18:53:43 UTC (rev 46088)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c	2012-04-29 20:04:12 UTC (rev 46089)
@@ -632,6 +632,12 @@
 	BLI_freelistN(objects);
 }
 
+static void tracking_dopesheet_free(MovieTrackingDopesheet *dopesheet)
+{
+	BLI_freelistN(&dopesheet->channels);
+	dopesheet->tot_channel = 0;
+}
+
 void BKE_tracking_free(MovieTracking *tracking)
 {
 	tracking_tracks_free(&tracking->tracks);
@@ -643,6 +649,8 @@
 
 	if (tracking->camera.intrinsics)
 		BKE_tracking_distortion_destroy(tracking->camera.intrinsics);
+
+	tracking_dopesheet_free(&tracking->dopesheet);
 }
 
 static MovieTrackingTrack *duplicate_track(MovieTrackingTrack *track)
@@ -1352,6 +1360,8 @@
 		newframe = context->user.framenr - 1;
 
 	context->sync_frame = newframe;
+
+	BKE_tracking_update_dopesheet(tracking);
 }
 
 void BKE_tracking_sync_user(MovieClipUser *user, MovieTrackingContext *context)
@@ -3033,3 +3043,53 @@
 
 	return NULL;
 }
+
+/*********************** dopesheet functions *************************/
+
+static int channels_alpha_sort(void *a, void *b)
+{
+	MovieTrackingDopesheetChannel *channel_a = a;
+	MovieTrackingDopesheetChannel *channel_b = b;
+
+	if (BLI_strcasecmp(channel_a->track->name, channel_b->track->name) > 0)
+		return 1;
+	else
+		return 0;
+}
+
+void BKE_tracking_update_dopesheet(MovieTracking *tracking)
+{
+	MovieTrackingObject *object = BKE_tracking_active_object(tracking);
+	MovieTrackingDopesheet *dopesheet = &tracking->dopesheet;
+	MovieTrackingTrack *track;
+	ListBase *tracksbase = BKE_tracking_object_tracks(tracking, object);
+	ListBase old_channels;
+
+	old_channels = dopesheet->channels;
+	dopesheet->channels.first = dopesheet->channels.last = NULL;
+	dopesheet->tot_channel = 0;
+
+	for (track = tracksbase->first; track; track = track->next) {
+		if (TRACK_SELECTED(track) && (track->flag & TRACK_HIDDEN) == 0) {
+			MovieTrackingDopesheetChannel *channel, *old_channel;
+
+			channel = MEM_callocN(sizeof(MovieTrackingDopesheetChannel), "tracking dopesheet channel");
+			channel->track = track;
+
+			/* copy flags from current dopsheet information to new one */
+			for (old_channel = old_channels.first; old_channel; old_channel = old_channel->next) {
+				if (old_channel->track == track) {
+					channel->flag = old_channel->flag;
+					break;
+				}
+			}
+
+			BLI_addtail(&dopesheet->channels, channel);
+			dopesheet->tot_channel++;
+		}
+	}
+
+	BLI_sortlist(&dopesheet->channels, channels_alpha_sort);
+
+	BLI_freelistN(&old_channels);
+}

Modified: branches/soc-2011-tomato/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenloader/intern/readfile.c	2012-04-29 18:53:43 UTC (rev 46088)
+++ branches/soc-2011-tomato/source/blender/blenloader/intern/readfile.c	2012-04-29 20:04:12 UTC (rev 46089)
@@ -6167,6 +6167,20 @@
 	}
 }
 
+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 = channel->next;
+	}
+}
+
 static void direct_link_movieclip(FileData *fd, MovieClip *clip)
 {
 	MovieTracking *tracking= &clip->tracking;
@@ -6202,6 +6216,8 @@
 
 		object= object->next;
 	}
+
+	direct_link_movieDopesheet(fd, &clip->tracking.dopesheet);
 }
 
 static void lib_link_movieclip(FileData *fd, Main *main)

Modified: branches/soc-2011-tomato/source/blender/blenloader/intern/writefile.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenloader/intern/writefile.c	2012-04-29 18:53:43 UTC (rev 46088)
+++ branches/soc-2011-tomato/source/blender/blenloader/intern/writefile.c	2012-04-29 20:04:12 UTC (rev 46089)
@@ -2677,6 +2677,18 @@
 	}
 }
 
+static void write_movieDopesheet(WriteData *wd, MovieTrackingDopesheet *dopesheet)
+{
+	MovieTrackingDopesheetChannel *channel;
+
+	channel = dopesheet->channels.first;
+	while (channel) {
+		writestruct(wd, DATA, "MovieTrackingDopesheetChannel", 1, channel);
+
+		channel = channel->next;
+	}
+}
+
 static void write_movieReconstruction(WriteData *wd, MovieTrackingReconstruction *reconstruction)
 {
 	if (reconstruction->camnr)
@@ -2709,6 +2721,8 @@
 
 				object= object->next;
 			}
+
+			write_movieDopesheet(wd, &tracking->dopesheet);
 		}
 
 		clip= clip->id.next;

Modified: branches/soc-2011-tomato/source/blender/editors/include/ED_clip.h
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/include/ED_clip.h	2012-04-29 18:53:43 UTC (rev 46088)
+++ branches/soc-2011-tomato/source/blender/editors/include/ED_clip.h	2012-04-29 20:04:12 UTC (rev 46089)
@@ -69,6 +69,8 @@
 
 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);
 

Modified: branches/soc-2011-tomato/source/blender/editors/space_clip/clip_dopesheet_draw.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_clip/clip_dopesheet_draw.c	2012-04-29 18:53:43 UTC (rev 46088)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/clip_dopesheet_draw.c	2012-04-29 20:04:12 UTC (rev 46089)
@@ -154,8 +154,8 @@
 
 	if (clip) {
 		MovieTracking *tracking = &clip->tracking;
-		MovieTrackingTrack *track;
-		ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
+		MovieTrackingDopesheet *dopesheet = &tracking->dopesheet;
+		MovieTrackingDopesheetChannel *channel;
 		float y, xscale, yscale;
 		float strip[4], selected_strip[4];
 
@@ -172,17 +172,15 @@
 
 		glEnable(GL_BLEND);
 
-		for (track = tracksbase->first; track; track = track->next) {
+		for (channel = dopesheet->channels.first; channel; channel = channel->next) {
 			float yminc = (float) (y - CHANNEL_HEIGHT_HALF);
 			float ymaxc = (float) (y + CHANNEL_HEIGHT_HALF);
 
-			if (!TRACK_VIEW_SELECTED(sc, track))
-				continue;
-
 			/* check if visible */
 			if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
 			    IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax))
 			{
+				MovieTrackingTrack *track = channel->track;
 				float alpha;
 				int i, sel = track->flag & TRACK_DOPE_SEL;
 
@@ -272,21 +270,20 @@
 	View2D *v2d = &ar->v2d;
 	MovieClip *clip = ED_space_clip(sc);
 	MovieTracking *tracking;
-	MovieTrackingTrack *track;
-	ListBase *tracksbase;
+	MovieTrackingDopesheet *dopesheet;
+	MovieTrackingDopesheetChannel *channel;
 	uiStyle *style = UI_GetStyle();
 	uiBlock *block;
 	int fontid = style->widget.uifont_id;
-	int items, height;
+	int height;
 	float y;
 
 	if (!clip)
 		return;
 
 	tracking = &clip->tracking;
-	tracksbase = BKE_tracking_get_tracks(tracking);
-	items = BLI_countlist(tracksbase);
-	height = (items * CHANNEL_STEP) + (CHANNEL_HEIGHT * 2);
+	dopesheet = &tracking->dopesheet;
+	height = (dopesheet->tot_channel * CHANNEL_STEP) + (CHANNEL_HEIGHT * 2);
 
 	if (height > (v2d->mask.ymax - v2d->mask.ymin)) {
 		/* don't use totrect set, as the width stays the same 
@@ -305,17 +302,15 @@
 
 	BLF_size(fontid, 11.0f, U.dpi);
 
-	for (track = tracksbase->first; track; track = track->next) {
+	for (channel = dopesheet->channels.first; channel; channel = channel->next) {
 		float yminc = (float) (y - CHANNEL_HEIGHT_HALF);
 		float ymaxc = (float) (y + CHANNEL_HEIGHT_HALF);
 
-		if (!TRACK_VIEW_SELECTED(sc, track))
-			continue;
-
 		/* check if visible */
 		if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
 		    IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax))
 		{
+			MovieTrackingTrack *track = channel->track;
 			float font_height, color[3];
 			int sel = track->flag & TRACK_DOPE_SEL;
 
@@ -345,17 +340,15 @@
 	y = (float) CHANNEL_FIRST;
 
 	glEnable(GL_BLEND);
-	for (track = tracksbase->first; track; track = track->next) {
+	for (channel = dopesheet->channels.first; channel; channel = channel->next) {
 		float yminc = (float)(y - CHANNEL_HEIGHT_HALF);
 		float ymaxc = (float)(y + CHANNEL_HEIGHT_HALF);
 
-		if (!TRACK_VIEW_SELECTED(sc, track))
-			continue;
-
 		/* check if visible */
 		if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
 		    IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax))
 		{
+			MovieTrackingTrack *track = channel->track;
 			uiBut *but;
 			PointerRNA ptr;
 			int icon;

Modified: branches/soc-2011-tomato/source/blender/editors/space_clip/clip_dopesheet_ops.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_clip/clip_dopesheet_ops.c	2012-04-29 18:53:43 UTC (rev 46088)

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list