Camera tracking integration
authorSergey Sharybin <sergey.vfx@gmail.com>
Thu, 21 Jul 2011 09:23:25 +0000 (09:23 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Thu, 21 Jul 2011 09:23:25 +0000 (09:23 +0000)
===========================

- 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.

release/scripts/startup/bl_ui/space_clip.py
source/blender/blenloader/intern/readfile.c
source/blender/editors/include/ED_clip.h
source/blender/editors/space_clip/clip_editor.c
source/blender/editors/space_clip/clip_ops.c
source/blender/editors/space_clip/space_clip.c
source/blender/editors/space_clip/tracking_ops.c
source/blender/editors/transform/transform_conversions.c
source/blender/makesdna/DNA_movieclip_types.h
source/blender/makesrna/intern/rna_movieclip.c

index 642ecdd0e06abfc0eecf3508955ea818ea57620e..dfea34071ec1b96b2984e5f75c2d348bc3ad6c64 100644 (file)
@@ -341,6 +341,11 @@ class CLIP_PT_display(bpy.types.Panel):
         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'
index 7316eb6e183a50de638aad197bef7631e5e36483..43b29714f4fb6c21cdc69aff37477bc6fc159230 100644 (file)
@@ -11815,6 +11815,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
        {
                bScreen *sc;
                Camera *cam;
+               MovieClip *clip;
 
                for (sc= main->screen.first; sc; sc= sc->id.next) {
                        ScrArea *sa;
@@ -11841,8 +11842,15 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                        }
                }
 
+               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;
                        }
index 7787adb859b475c9d362a64dba37088d358ac82a..809ebb676350861f67e775b644029f8b5b31d9dc 100644 (file)
@@ -45,6 +45,9 @@ void ED_space_clip_set(struct bContext *C, struct SpaceClip *sc, struct MovieCli
 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);
 
index d5f1925b12fa589d16722f7af09bedd517593b3e..cb1b68299e7a02a6468cd40f956db25f55c90898 100644 (file)
@@ -102,6 +102,22 @@ void ED_space_clip_zoom(SpaceClip *sc, ARegion *ar, float *zoomx, float *zoomy)
        *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 @@ static int selected_boundbox(SpaceClip *sc, float min[2], float max[2])
 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 @@ void ED_clip_view_selection(SpaceClip *sc, ARegion *ar, int fit)
        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) {
index 97a8c76a13a63bb052ccba7a25c095d3e406840d..6488f5bb646aaf1a193b80c4ded9bfd5cea21bf7 100644 (file)
@@ -632,12 +632,17 @@ static int view_all_exec(bContext *C, wmOperator *UNUSED(op))
        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;
index 261653b9d41cba2673a946a83064125e459875eb..771008b0a01c4fb5dadf53952443458c0623a132 100644 (file)
@@ -379,6 +379,7 @@ static void clip_refresh(const bContext *C, ScrArea *UNUSED(sa))
 /* 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 @@ static void movieclip_main_area_set_view2d(SpaceClip *sc, ARegion *ar)
        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;
 
index a90ac0764921d2127c9174d93c6497c98fbff20c..40235b97cc827ed8b95640a67935f3b747c21273 100644 (file)
@@ -162,10 +162,14 @@ static void mouse_pos(bContext *C, wmEvent *event, float co[2])
        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 @@ static int select_all_exec(bContext *C, wmOperator *op)
                                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;
                                }
                        }
index 58f6c67ac8bee5c415fe41f78e6a73cd6c89950e..c2d5c0ad252e916d9f275c5c68f1257e57f9820f 100644 (file)
@@ -5291,17 +5291,9 @@ static void createTransTrackingData(bContext *C, TransInfo *t)
                        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;
                        }
                }
 
index 227d8387375032cbf1429f5afccbaa621ed92d7b..c799c401ec52b3f84bd7a0efbb53d394538323db 100644 (file)
@@ -59,6 +59,8 @@ typedef struct MovieClip {
        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 */
 
index 80f0c3dc90575367c0d06d9f481c724647ba371c..22b26ebec53cd412175a50ad579b439fe0b81aa5 100644 (file)
@@ -135,6 +135,13 @@ static void rna_def_movieclip(BlenderRNA *brna)
        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)