[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43691] trunk/blender: Various fixes for camera tracking stuff

Sergey Sharybin sergey.vfx at gmail.com
Wed Jan 25 14:37:31 CET 2012


Revision: 43691
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43691
Author:   nazgul
Date:     2012-01-25 13:37:11 +0000 (Wed, 25 Jan 2012)
Log Message:
-----------
Various fixes for camera tracking stuff

- Fixed tooltip displaying for track sequence forwards in clip editor
- Corrected detection of 8 tracks so it wouldn't count tracks disabled
  on keyframes.
- Scale track preview to actual track widget size instead of scaling the
  whole preview image with given zoom ratio, so no extra memory needed to
  store zoomed margin would be used.
- Track's statistics text will fit pattern position instead of search if
  marker is disabled on current frame.
- Fixed toggle selection operator if selected track is hidden due to
  "Hide Disabled" policy.

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_ui/space_clip.py
    trunk/blender/source/blender/blenkernel/BKE_tracking.h
    trunk/blender/source/blender/blenkernel/intern/tracking.c
    trunk/blender/source/blender/editors/interface/interface_draw.c
    trunk/blender/source/blender/editors/space_clip/clip_draw.c
    trunk/blender/source/blender/editors/space_clip/tracking_ops.c

Modified: trunk/blender/release/scripts/startup/bl_ui/space_clip.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_clip.py	2012-01-25 10:10:15 UTC (rev 43690)
+++ trunk/blender/release/scripts/startup/bl_ui/space_clip.py	2012-01-25 13:37:11 UTC (rev 43691)
@@ -172,6 +172,7 @@
         props.backwards = True
         props.sequence = True
         props = row.operator("clip.track_markers", text="", icon='PLAY')
+        props.backwards = False
         props.sequence = True
         row.operator("clip.track_markers", text="", icon='FRAME_NEXT')
 

Modified: trunk/blender/source/blender/blenkernel/BKE_tracking.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_tracking.h	2012-01-25 10:10:15 UTC (rev 43690)
+++ trunk/blender/source/blender/blenkernel/BKE_tracking.h	2012-01-25 13:37:11 UTC (rev 43691)
@@ -61,6 +61,7 @@
 struct MovieTrackingMarker *BKE_tracking_ensure_marker(struct MovieTrackingTrack *track, int framenr);
 struct MovieTrackingMarker *BKE_tracking_exact_marker(struct MovieTrackingTrack *track, int framenr);
 int BKE_tracking_has_marker(struct MovieTrackingTrack *track, int framenr);
+int BKE_tracking_has_enabled_marker(struct MovieTrackingTrack *track, int framenr);
 
 void BKE_tracking_free_track(struct MovieTrackingTrack *track);
 

Modified: trunk/blender/source/blender/blenkernel/intern/tracking.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/tracking.c	2012-01-25 10:10:15 UTC (rev 43690)
+++ trunk/blender/source/blender/blenkernel/intern/tracking.c	2012-01-25 13:37:11 UTC (rev 43691)
@@ -395,6 +395,13 @@
 	return BKE_tracking_exact_marker(track, framenr) != 0;
 }
 
+int BKE_tracking_has_enabled_marker(MovieTrackingTrack *track, int framenr)
+{
+	MovieTrackingMarker *marker = BKE_tracking_exact_marker(track, framenr);
+
+	return marker && (marker->flag & MARKER_DISABLED) == 0;
+}
+
 void BKE_tracking_free_track(MovieTrackingTrack *track)
 {
 	if(track->markers) MEM_freeN(track->markers);
@@ -1741,8 +1748,8 @@
 
 	track= tracksbase->first;
 	while(track) {
-		if(BKE_tracking_has_marker(track, frame1))
-			if(BKE_tracking_has_marker(track, frame2))
+		if(BKE_tracking_has_enabled_marker(track, frame1))
+			if(BKE_tracking_has_enabled_marker(track, frame2))
 				tot++;
 
 		track= track->next;
@@ -1758,7 +1765,7 @@
 	ListBase *tracksbase= BKE_tracking_object_tracks(tracking, object);
 
 	if(count_tracks_on_both_keyframes(tracking, tracksbase)<8) {
-		BLI_strncpy(error_msg, "At least 8 tracks on both of keyframes are needed for reconstruction", error_size);
+		BLI_strncpy(error_msg, "At least 8 common tracks on both of keyframes are needed for reconstruction", error_size);
 		return 0;
 	}
 

Modified: trunk/blender/source/blender/editors/interface/interface_draw.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_draw.c	2012-01-25 10:10:15 UTC (rev 43690)
+++ trunk/blender/source/blender/editors/interface/interface_draw.c	2012-01-25 13:37:11 UTC (rev 43691)
@@ -1461,19 +1461,21 @@
 	fdrawbox(rect->xmin, rect->ymin, rect->xmax, rect->ymax);
 }
 
-static ImBuf *scale_trackpreview_ibuf(ImBuf *ibuf, float zoomx, float zoomy)
+static ImBuf *scale_trackpreview_ibuf(ImBuf *ibuf, float track_pos[2], int width, float height, int margin)
 {
 	ImBuf *scaleibuf;
-	int x, y, w= ibuf->x*zoomx, h= ibuf->y*zoomy;
-	const float scalex= 1.0f/zoomx;
-	const float scaley= 1.0f/zoomy;
+	const float scalex= ((float)ibuf->x-2*margin) / width;
+	const float scaley= ((float)ibuf->y-2*margin) / height;
+	float off_x= (int)track_pos[0]-track_pos[0]+0.5f;
+	float off_y= (int)track_pos[1]-track_pos[1]+0.5f;
+	int x, y;
 
-	scaleibuf= IMB_allocImBuf(w, h, 32, IB_rect);
+	scaleibuf= IMB_allocImBuf(width, height, 32, IB_rect);
 
-	for(y= 0; y<h; y++) {
-		for (x= 0; x<w; x++) {
-			float src_x= scalex*x;
-			float src_y= scaley*y;
+	for(y= 0; y<height; y++) {
+		for (x= 0; x<width; x++) {
+			float src_x= scalex*(x)+margin-off_x;
+			float src_y= scaley*(y)+margin-off_y;
 
 			bicubic_interpolation(ibuf, scaleibuf, src_x, src_y, x, y);
 		}
@@ -1504,7 +1506,7 @@
 	if(scopes->track_disabled) {
 		glColor4f(0.7f, 0.3f, 0.3f, 0.3f);
 		uiSetRoundBox(15);
-		uiDrawBox(GL_POLYGON, rect.xmin-1, rect.ymin-1, rect.xmax+1, rect.ymax+1, 3.0f);
+		uiDrawBox(GL_POLYGON, rect.xmin-1, rect.ymin, rect.xmax+1, rect.ymax+1, 3.0f);
 
 		ok= 1;
 	}
@@ -1512,8 +1514,8 @@
 		/* additional margin around image */
 		/* NOTE: should be kept in sync with value from BKE_movieclip_update_scopes */
 		const int margin= 3;
-		float zoomx, zoomy, track_pos[2], off_x, off_y, x0, y0;
-		int a;
+		float zoomx, zoomy, track_pos[2], off_x, off_y;
+		int a, width, height;
 		ImBuf *drawibuf;
 
 		glPushMatrix();
@@ -1524,16 +1526,18 @@
 		/* draw content of pattern area */
 		glScissor(ar->winrct.xmin+rect.xmin, ar->winrct.ymin+rect.ymin, scissor[2], scissor[3]);
 
-		zoomx= (rect.xmax-rect.xmin) / (scopes->track_preview->x-2*margin);
-		zoomy= (rect.ymax-rect.ymin) / (scopes->track_preview->y-2*margin);
+		width= rect.xmax-rect.xmin+1;
+		height = rect.ymax-rect.ymin;
 
+		zoomx= (float)width / (scopes->track_preview->x-2*margin);
+		zoomy= (float)height / (scopes->track_preview->y-2*margin);
+
 		off_x= ((int)track_pos[0]-track_pos[0]+0.5)*zoomx;
 		off_y= ((int)track_pos[1]-track_pos[1]+0.5)*zoomy;
-		x0= (int)(off_x+rect.xmin-zoomx*(margin-0.5f))+1;
-		y0= (int)(off_y+rect.ymin-zoomy*(margin-0.5f))+1;
 
-		drawibuf= scale_trackpreview_ibuf(scopes->track_preview, zoomx, zoomy);
-		glaDrawPixelsSafe(x0, y0, rect.xmax-x0+1, rect.ymax-y0+1,
+		drawibuf= scale_trackpreview_ibuf(scopes->track_preview, track_pos, width, height, margin);
+
+		glaDrawPixelsSafe(rect.xmin, rect.ymin+1, drawibuf->x, drawibuf->y,
 		                  drawibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, drawibuf->rect);
 		IMB_freeImBuf(drawibuf);
 
@@ -1568,7 +1572,7 @@
 	if(!ok) {
 		glColor4f(0.f, 0.f, 0.f, 0.3f);
 		uiSetRoundBox(15);
-		uiDrawBox(GL_POLYGON, rect.xmin-1, rect.ymin-1, rect.xmax+1, rect.ymax+1, 3.0f);
+		uiDrawBox(GL_POLYGON, rect.xmin-1, rect.ymin, rect.xmax+1, rect.ymax+1, 3.0f);
 	}
 
 	/* outline, scale gripper */

Modified: trunk/blender/source/blender/editors/space_clip/clip_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_clip/clip_draw.c	2012-01-25 10:10:15 UTC (rev 43690)
+++ trunk/blender/source/blender/editors/space_clip/clip_draw.c	2012-01-25 13:37:11 UTC (rev 43691)
@@ -777,7 +777,9 @@
 		else UI_ThemeColor(TH_SEL_MARKER);
 	}
 
-	if(sc->flag&SC_SHOW_MARKER_SEARCH) {
+	if((sc->flag&SC_SHOW_MARKER_SEARCH) &&
+	   ((marker->flag&MARKER_DISABLED)==0 || (sc->flag&SC_SHOW_MARKER_PATTERN)==0))
+	{
 		dx= track->search_min[0];
 		dy= track->search_min[1];
 	} else if(sc->flag&SC_SHOW_MARKER_PATTERN) {

Modified: trunk/blender/source/blender/editors/space_clip/tracking_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_clip/tracking_ops.c	2012-01-25 10:10:15 UTC (rev 43690)
+++ trunk/blender/source/blender/editors/space_clip/tracking_ops.c	2012-01-25 13:37:11 UTC (rev 43691)
@@ -1014,6 +1014,7 @@
 	SpaceClip *sc= CTX_wm_space_clip(C);
 	MovieClip *clip= ED_space_clip(sc);
 	MovieTrackingTrack *track= NULL;	/* selected track */
+	MovieTrackingMarker *marker;
 	ListBase *tracksbase= BKE_tracking_get_tracks(&clip->tracking);
 	int action= RNA_enum_get(op->ptr, "action");
 	int framenr= sc->user.framenr;
@@ -1024,8 +1025,12 @@
 		track= tracksbase->first;
 		while(track) {
 			if(TRACK_VIEW_SELECTED(sc, track)) {
-				action= SEL_DESELECT;
-				break;
+				marker= BKE_tracking_get_marker(track, framenr);
+
+				if(MARKER_VISIBLE(sc, marker)) {
+					action= SEL_DESELECT;
+					break;
+				}
 			}
 
 			track= track->next;
@@ -1035,9 +1040,9 @@
 	track= tracksbase->first;
 	while(track) {
 		if((track->flag&TRACK_HIDDEN)==0) {
-			MovieTrackingMarker *marker= BKE_tracking_get_marker(track, framenr);
+			marker= BKE_tracking_get_marker(track, framenr);
 
-			if(marker && MARKER_VISIBLE(sc, marker)) {
+			if(MARKER_VISIBLE(sc, marker)) {
 				switch (action) {
 					case SEL_SELECT:
 						track->flag|= SELECT;



More information about the Bf-blender-cvs mailing list