[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38556] branches/soc-2011-tomato: Camera tracking integration

Sergey Sharybin g.ulairi at gmail.com
Thu Jul 21 11:23:25 CEST 2011


Revision: 38556
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38556
Author:   nazgul
Date:     2011-07-21 09:23:25 +0000 (Thu, 21 Jul 2011)
Log Message:
-----------
Camera tracking integration
===========================

- Fixed crash when transforming disabled marker.
- Select Inverse wouldn't select hidden parts of markers.
- Movie Clip display aspect ratio is now available on Display panel.

Modified Paths:
--------------
    branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py
    branches/soc-2011-tomato/source/blender/blenloader/intern/readfile.c
    branches/soc-2011-tomato/source/blender/editors/include/ED_clip.h
    branches/soc-2011-tomato/source/blender/editors/space_clip/clip_editor.c
    branches/soc-2011-tomato/source/blender/editors/space_clip/clip_ops.c
    branches/soc-2011-tomato/source/blender/editors/space_clip/space_clip.c
    branches/soc-2011-tomato/source/blender/editors/space_clip/tracking_ops.c
    branches/soc-2011-tomato/source/blender/editors/transform/transform_conversions.c
    branches/soc-2011-tomato/source/blender/makesdna/DNA_movieclip_types.h
    branches/soc-2011-tomato/source/blender/makesrna/intern/rna_movieclip.c

Modified: branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py
===================================================================
--- branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py	2011-07-21 08:10:34 UTC (rev 38555)
+++ branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py	2011-07-21 09:23:25 UTC (rev 38556)
@@ -341,7 +341,12 @@
         layout.prop(sc, "lock_selection")
         layout.prop(sc, "use_mute_footage")
 
+        clip = sc.clip
+        if clip:
+            layout.label(text="Display Aspect:")
+            layout.prop(clip, "display_aspect", text="")
 
+
 class CLIP_PT_footage(bpy.types.Panel):
     bl_space_type = 'CLIP_EDITOR'
     bl_region_type = 'UI'

Modified: branches/soc-2011-tomato/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenloader/intern/readfile.c	2011-07-21 08:10:34 UTC (rev 38555)
+++ branches/soc-2011-tomato/source/blender/blenloader/intern/readfile.c	2011-07-21 09:23:25 UTC (rev 38556)
@@ -11815,6 +11815,7 @@
 	{
 		bScreen *sc;
 		Camera *cam;
+		MovieClip *clip;
 
 		for (sc= main->screen.first; sc; sc= sc->id.next) {
 			ScrArea *sa;
@@ -11841,8 +11842,15 @@
 			}
 		}
 
+		for (clip= main->movieclip.first; clip; clip= clip->id.next) {
+			if(clip->aspx<1.0f) {
+				clip->aspx= 1.0f;
+				clip->aspy= 1.0f;
+			}
+		}
+
 		for(cam= main->camera.first; cam; cam= cam->id.next) {
-			if (cam->sensor_x < 0.01) {
+			if (cam->sensor_x < 0.01f) {
 				cam->sensor_x = 32.f;
 				cam->sensor_y = 18.f;
 			}

Modified: branches/soc-2011-tomato/source/blender/editors/include/ED_clip.h
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/include/ED_clip.h	2011-07-21 08:10:34 UTC (rev 38555)
+++ branches/soc-2011-tomato/source/blender/editors/include/ED_clip.h	2011-07-21 09:23:25 UTC (rev 38556)
@@ -45,7 +45,10 @@
 struct MovieClip *ED_space_clip(struct SpaceClip *sc);
 void ED_space_clip_size(struct SpaceClip *sc, int *width, int *height);
 void ED_space_clip_zoom(struct SpaceClip *sc, ARegion *ar, float *zoomx, float *zoomy);
+void ED_clip_aspect(struct MovieClip *clip, float *aspx, float *aspy);
+void ED_space_clip_aspect(struct SpaceClip *sc, float *aspx, float *aspy);
 
+
 struct ImBuf *ED_space_clip_acquire_buffer(struct SpaceClip *sc);
 
 void ED_clip_update_frame(const struct Main *mainp, int cfra);

Modified: branches/soc-2011-tomato/source/blender/editors/space_clip/clip_editor.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_clip/clip_editor.c	2011-07-21 08:10:34 UTC (rev 38555)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/clip_editor.c	2011-07-21 09:23:25 UTC (rev 38556)
@@ -102,6 +102,22 @@
 	*zoomy= (float)(ar->winrct.ymax - ar->winrct.ymin + 1)/(float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin)*height);
 }
 
+void ED_clip_aspect(MovieClip *clip, float *aspx, float *aspy)
+{
+	*aspx= *aspy= 1.0;
+
+	if(clip == NULL || clip->aspx==0.0f || clip->aspy==0.0f)
+		return;
+
+	/* x is always 1 */
+	*aspy = clip->aspy/clip->aspx;
+}
+
+void ED_space_clip_aspect(SpaceClip *sc, float *aspx, float *aspy)
+{
+	ED_clip_aspect(ED_space_clip(sc), aspx, aspy);
+}
+
 void ED_clip_update_frame(const Main *mainp, int cfra)
 {
 	wmWindowManager *wm;
@@ -158,9 +174,10 @@
 void ED_clip_view_selection(SpaceClip *sc, ARegion *ar, int fit)
 {
 	int w, h, width, height, frame_width, frame_height;
-	float min[2], max[2];
+	float min[2], max[2], aspx, aspy;
 
 	ED_space_clip_size(sc, &frame_width, &frame_height);
+	ED_space_clip_aspect(sc, &aspx, &aspy);
 
 	if(frame_width==0 || frame_height==0) return;
 
@@ -173,8 +190,8 @@
 	h= max[1]-min[1];
 
 	/* center view */
-	sc->xof= ((float)(max[0]+min[0]-frame_width))/2;
-	sc->yof= ((float)(max[1]+min[1]-frame_height))/2;
+	sc->xof= ((float)(max[0]+min[0]-frame_width))/2*aspx;
+	sc->yof= ((float)(max[1]+min[1]-frame_height))/2*aspy;
 
 	/* set zoom to see all selection */
 	if(w>0 && h>0) {

Modified: branches/soc-2011-tomato/source/blender/editors/space_clip/clip_ops.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_clip/clip_ops.c	2011-07-21 08:10:34 UTC (rev 38555)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/clip_ops.c	2011-07-21 09:23:25 UTC (rev 38556)
@@ -632,13 +632,18 @@
 	SpaceClip *sc;
 	ARegion *ar;
 	int w, h, width, height;
+	float aspx, aspy;
 
 	/* retrieve state */
 	sc= CTX_wm_space_clip(C);
 	ar= CTX_wm_region(C);
 
 	ED_space_clip_size(sc, &w, &h);
+	ED_space_clip_aspect(sc, &aspx, &aspy);
 
+	w= w*aspx;
+	h= h*aspy;
+
 	/* check if the image will fit in the image with zoom==1 */
 	width= ar->winrct.xmax - ar->winrct.xmin + 1;
 	height= ar->winrct.ymax - ar->winrct.ymin + 1;

Modified: branches/soc-2011-tomato/source/blender/editors/space_clip/space_clip.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_clip/space_clip.c	2011-07-21 08:10:34 UTC (rev 38555)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/space_clip.c	2011-07-21 09:23:25 UTC (rev 38556)
@@ -379,6 +379,7 @@
 /* sets up the fields of the View2D from zoom and offset */
 static void movieclip_main_area_set_view2d(SpaceClip *sc, ARegion *ar)
 {
+	MovieClip *clip= ED_space_clip(sc);
 	float x1, y1, w, h;
 	int width, height, winx, winy;
 
@@ -387,6 +388,9 @@
 	w= width;
 	h= height;
 
+	if(clip)
+		h*= clip->aspy/clip->aspx;
+
 	winx= ar->winrct.xmax - ar->winrct.xmin + 1;
 	winy= ar->winrct.ymax - ar->winrct.ymin + 1;
 

Modified: branches/soc-2011-tomato/source/blender/editors/space_clip/tracking_ops.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_clip/tracking_ops.c	2011-07-21 08:10:34 UTC (rev 38555)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/tracking_ops.c	2011-07-21 09:23:25 UTC (rev 38556)
@@ -162,10 +162,14 @@
 	ARegion *ar= CTX_wm_region(C);
 	SpaceClip *sc= CTX_wm_space_clip(C);
 	int sx, sy;
+	float zoomx, zoomy;
 
+	ED_space_clip_zoom(sc, ar, &zoomx, &zoomy);
+
 	UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &sx, &sy);
-	co[0]= ((float)event->mval[0]-sx)/sc->zoom;
-	co[1]= ((float)event->mval[1]-sy)/sc->zoom;
+
+	co[0]= ((float)event->mval[0]-sx)/zoomx;
+	co[1]= ((float)event->mval[1]-sy)/zoomy;
 }
 
 static int add_marker_invoke(bContext *C, wmOperator *op, wmEvent *event)
@@ -676,18 +680,18 @@
 				switch (action) {
 					case SEL_SELECT:
 						track->flag|= SELECT;
-						track->pat_flag|= SELECT;
-						track->search_flag|= SELECT;
+						if(sc->flag&SC_SHOW_MARKER_PATTERN) track->pat_flag|= SELECT;
+						if(sc->flag&SC_SHOW_MARKER_SEARCH) track->search_flag|= SELECT;
 						break;
 					case SEL_DESELECT:
 						track->flag&= ~SELECT;
-						track->pat_flag&= ~SELECT;
-						track->search_flag&= ~SELECT;
+						if(sc->flag&SC_SHOW_MARKER_PATTERN) track->pat_flag&= ~SELECT;
+						if(sc->flag&SC_SHOW_MARKER_SEARCH) track->search_flag&= ~SELECT;
 						break;
 					case SEL_INVERT:
 						track->flag^= SELECT;
-						track->pat_flag^= SELECT;
-						track->search_flag^= SELECT;
+						if(sc->flag&SC_SHOW_MARKER_PATTERN) track->pat_flag^= SELECT;
+						if(sc->flag&SC_SHOW_MARKER_SEARCH) track->search_flag^= SELECT;
 						break;
 				}
 			}

Modified: branches/soc-2011-tomato/source/blender/editors/transform/transform_conversions.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/transform/transform_conversions.c	2011-07-21 08:10:34 UTC (rev 38555)
+++ branches/soc-2011-tomato/source/blender/editors/transform/transform_conversions.c	2011-07-21 09:23:25 UTC (rev 38556)
@@ -5291,17 +5291,9 @@
 			marker= BKE_tracking_get_marker(track, framenr);
 
 			if(marker) {
-				if((marker->flag&MARKER_DISABLED)==0) {
-					if(track->flag&SELECT) t->total++;
-					if(track->pat_flag&SELECT) t->total+= 2;
-				}
-
-				if(track->search_flag&SELECT) {
-					t->total+= 2;
-
-					if(marker->flag&MARKER_DISABLED)
-						t->total+= 3;
-				}
+				if(track->flag&SELECT) t->total++;
+				if(track->pat_flag&SELECT) t->total+= 2;
+				if(track->search_flag&SELECT) t->total+= 2;
 			}
 		}
 

Modified: branches/soc-2011-tomato/source/blender/makesdna/DNA_movieclip_types.h
===================================================================
--- branches/soc-2011-tomato/source/blender/makesdna/DNA_movieclip_types.h	2011-07-21 08:10:34 UTC (rev 38555)
+++ branches/soc-2011-tomato/source/blender/makesdna/DNA_movieclip_types.h	2011-07-21 09:23:25 UTC (rev 38556)
@@ -59,6 +59,8 @@
 	int lastframe;		/* last accessed frame number */
 	int lastsize[2];	/* size of last accessed frame */
 
+	float aspx, aspy;	/* display aspect */
+
 	struct anim *anim;	/* movie source data */
 	void *ibuf_cache;	/* cache of ibufs, not in file */
 

Modified: branches/soc-2011-tomato/source/blender/makesrna/intern/rna_movieclip.c
===================================================================
--- branches/soc-2011-tomato/source/blender/makesrna/intern/rna_movieclip.c	2011-07-21 08:10:34 UTC (rev 38555)
+++ branches/soc-2011-tomato/source/blender/makesrna/intern/rna_movieclip.c	2011-07-21 09:23:25 UTC (rev 38556)
@@ -135,6 +135,13 @@
 	prop= RNA_def_float_vector(srna, "resolution" , 2 , NULL , 0, 0, "Resolution" , "X/Y pixels per meter" , 0 , 0);
 	RNA_def_property_float_funcs(prop, "rna_MovieClip_resolution_get", NULL, NULL);
 	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
+	prop= RNA_def_property(srna, "display_aspect", PROP_FLOAT, PROP_XYZ);
+	RNA_def_property_float_sdna(prop, NULL, "aspx");
+	RNA_def_property_array(prop, 2);
+	RNA_def_property_range(prop, 0.1f, 5000.0f);
+	RNA_def_property_ui_text(prop, "Display Aspect", "Display Aspect for this clip, does not affect rendering");
+	RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL);
 }
 
 void RNA_def_movieclip(BlenderRNA *brna)




More information about the Bf-blender-cvs mailing list