Revision: 37515
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37515
Author:   nazgul
Date:     2011-06-15 17:23:08 +0000 (Wed, 15 Jun 2011)
Log Message:
-----------
Camera tracking integration
===========================

- Marker's preview panel is now avaliable with any
  tool selected (except NONE).
- Fixed bug with marker's point going outside of pattern
  when scaling pattern which isn't centered to marker's pos.
- Changed a bit pattern area image generation.
  Now it shouldn't give artifacts with different kinds of
  offsets caused because of float-?int conversions.
- Rollback code for generating flat buffer of search area
  when tracking. It'll be more accurate with current position
  calculation.
  Will switch to BKE_tracking_acquire_search_imbuf when
  backwards position calculation would be implemented.
- Added option to make markers thin. It's in Debug panel due
  to this option was really useful for debugging preview image
  but not sure it'll be useful for artists.
- Added "View Selected" operator (hotkey is numpad period).
  Fits view to show all selection at the frame.
- Added option "Lock to Selection" which locks view
  to show centered selection. Useful to visual markers
  tracking during playback.
  This option is on "Display" panel.

Modified Paths:
--------------
    branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py
    branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c
    branches/soc-2011-tomato/source/blender/editors/include/ED_clip.h
    branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c
    branches/soc-2011-tomato/source/blender/editors/space_clip/clip_editor.c
    branches/soc-2011-tomato/source/blender/editors/space_clip/clip_intern.h
    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/makesdna/DNA_space_types.h
    branches/soc-2011-tomato/source/blender/makesrna/intern/rna_space.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-06-15 17:21:34 UTC (rev 37514)
+++ branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py        
2011-06-15 17:23:08 UTC (rev 37515)
@@ -156,7 +156,7 @@
         tool = ts.movieclip.tool
 
         return (sc.mode == 'TRACKING' and clip and \
-            tool == 'MARKER' and clip.tracking.act_track)
+            tool != 'NONE' and clip.tracking.act_track)
 
     def draw(self, context):
         layout = self.layout
@@ -234,6 +234,7 @@
 
         layout.prop(sc, "show_marker_pattern")
         layout.prop(sc, "show_marker_search")
+        layout.prop(sc, "lock_selection")
 
 
 class CLIP_PT_debug(bpy.types.Panel):
@@ -247,6 +248,7 @@
         sc = context.space_data
 
         layout.prop(sc, "show_cache")
+        layout.prop(sc, "show_tiny_markers")
 
 
 class CLIP_MT_view(bpy.types.Menu):
@@ -259,6 +261,22 @@
         layout.operator("clip.tools", icon='MENU_PANEL')
         layout.separator()
 
+        layout.operator("clip.view_selected")
+        layout.operator("clip.view_all")
+
+        layout.separator()
+        layout.operator("clip.view_zoom_in")
+        layout.operator("clip.view_zoom_out")
+
+        layout.separator()
+
+        ratios = [[1, 8], [1, 4], [1, 2], [1, 1], [2, 1], [4, 1], [8, 1]]
+
+        for a, b in ratios:
+            text = "Zoom %d:%d" % (a, b)
+            layout.operator("clip.view_zoom_ratio", text=text).ratio = a / b
+
+        layout.separator()
         layout.operator("screen.area_dupli")
         layout.operator("screen.screen_full_area")
 
@@ -298,7 +316,7 @@
 
         sc = context.space_data
 
-        layout.operator('clip.add_marker')
+        layout.operator('clip.add_marker_move')
 
 
 class CLIP_MT_select(bpy.types.Menu):

Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c        
2011-06-15 17:21:34 UTC (rev 37514)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c        
2011-06-15 17:23:08 UTC (rev 37515)
@@ -86,16 +86,6 @@
                                track->pat_max[a]= track->search_max[a];
                                track->pat_min[a]= track->pat_max[a]-dim[a];
                        }
-
-                       /* marker's center should be inside pattern */
-                       if(track->pat_min[a] > 0.0f) {
-                               track->pat_min[a]= 0.0f;
-                               track->pat_max[a]= dim[a];
-                       }
-                       if(track->pat_max[a] < 0.0f) {
-                               track->pat_max[a]= 0.0f;
-                               track->pat_min[a]= -dim[a];
-                       }
                }
        }
        else if(event==CLAMP_SEARCH_DIM) {
@@ -121,6 +111,23 @@
                        }
                }
        }
+
+       /* marker's center should be inside pattern */
+       if(event==CLAMP_PAT_DIM || event==CLAMP_PAT_POS) {
+               float dim[2];
+               sub_v2_v2v2(dim, track->pat_max, track->pat_min);
+
+               for(a= 0; a<2; a++) {
+                       if(track->pat_min[a] > 0.0f) {
+                               track->pat_min[a]= 0.0f;
+                               track->pat_max[a]= dim[a];
+                       }
+                       if(track->pat_max[a] < 0.0f) {
+                               track->pat_max[a]= 0.0f;
+                               track->pat_min[a]= -dim[a];
+                       }
+               }
+       }
 }
 
 void BKE_tracking_track_flag(MovieTrackingTrack *track, int area, int flag, 
int clear)
@@ -306,20 +313,24 @@
 static ImBuf *acquire_area_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, 
MovieTrackingMarker *marker, float min[2], float max[2], int pos[2])
 {
        ImBuf *tmpibuf;
-       const float eps= 0.001;
        int x, y;
        int x1, y1, x2, y2, w, h;
 
-       x= floor(marker->pos[0]*ibuf->x+eps);
-       y= floor(marker->pos[1]*ibuf->y+eps);
-       x1= x-floor(-min[0]*ibuf->x-eps);
-       y1= y-floor(-min[1]*ibuf->y-eps);
-       x2= x+ceil(max[0]*ibuf->x+eps);
-       y2= y+ceil(max[1]*ibuf->y+eps);
+       x= marker->pos[0]*ibuf->x;
+       y= marker->pos[1]*ibuf->y;
+       x1= x-(int)(-min[0]*ibuf->x);
+       y1= y-(int)(-min[1]*ibuf->y);
+       x2= x+(int)(max[0]*ibuf->x);
+       y2= y+(int)(max[1]*ibuf->y);
 
+       /* dimensions should be odd */
        w= (x2-x1)|1;
        h= (y2-y1)|1;
 
+       /* happens due to rounding issues */
+       if(x1+w<=x) x1++;
+       if(y1+h<=y) y1++;
+
        tmpibuf= IMB_allocImBuf(w, h, 32, IB_rect);
        IMB_rectcpy(tmpibuf, ibuf, 0, 0, x1, y1, w, h);
 
@@ -345,16 +356,22 @@
 {
        ImBuf *tmpibuf;
        float *pixels, *fp;
-       int x, y;
+       int x, y, width, height;
 
-       tmpibuf= BKE_tracking_acquire_search_imbuf(ibuf, track, marker, pos);
+       width= (track->search_max[0]-track->search_min[0])*ibuf->x;
+       height= (track->search_max[1]-track->search_min[1])*ibuf->y;
 
-       *width_r= tmpibuf->x;
-       *height_r= tmpibuf->y;
+       tmpibuf= IMB_allocImBuf(width, height, 32, IB_rect);
+       IMB_rectcpy(tmpibuf, ibuf, 0, 0,
+                       (track->search_min[0]+marker->pos[0])*ibuf->x,
+                       (track->search_min[1]+marker->pos[1])*ibuf->y, width, 
height);
 
-       fp= pixels= MEM_callocN(tmpibuf->x*tmpibuf->y*sizeof(float), "tracking 
floatBuf");
-       for(y= 0; y<tmpibuf->y; y++) {
-               for (x= 0; x<tmpibuf->x; x++) {
+       *width_r= width;
+       *height_r= height;
+
+       fp= pixels= MEM_callocN(width*height*sizeof(float), "tracking 
floatBuf");
+       for(y= 0; y<(int)height; y++) {
+               for (x= 0; x<(int)width; x++) {
                        int pixel= tmpibuf->x*y + x;
                        char *rrgb= (char*)tmpibuf->rect + pixel*4;
 
@@ -382,7 +399,7 @@
        /* duplicate currently tracking tracks to list of displaying tracks */
        track= context->tracks.first;
        while(track) {
-               int replace= 0, replace_sel= 0;
+               int replace_sel= 0;
                MovieTrackingTrack *new_track, *old;
 
                /* find original of tracking track in list of previously 
displayed tracks */
@@ -408,16 +425,13 @@
 
                                BKE_tracking_free_track(cur);
                                BLI_freelinkN(old_tracks, cur);
-                               replace= 1;
                        }
                }
 
                new_track= BKE_tracking_copy_track(track);
 
-               if(replace) {
-                       BLI_ghash_remove(context->hash, track, NULL, NULL); /* 
XXX: are we actually need this */
-                       BLI_ghash_insert(context->hash, track, new_track);
-               }
+               BLI_ghash_remove(context->hash, track, NULL, NULL); /* XXX: are 
we actually need this */
+               BLI_ghash_insert(context->hash, track, new_track);
 
                if(replace_sel)         /* update current selection in clip */
                        BKE_movieclip_set_selection(context->clip, 
MCLIP_SEL_TRACK, new_track);

Modified: branches/soc-2011-tomato/source/blender/editors/include/ED_clip.h
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/include/ED_clip.h   
2011-06-15 17:21:34 UTC (rev 37514)
+++ branches/soc-2011-tomato/source/blender/editors/include/ED_clip.h   
2011-06-15 17:23:08 UTC (rev 37515)
@@ -33,6 +33,7 @@
 #ifndef ED_MOVIECLIP_H
 #define ED_MOVIECLIP_H
 
+struct ARegion;
 struct bContext;
 struct ImBuf;
 struct Main;
@@ -48,6 +49,7 @@
 struct ImBuf *ED_space_clip_acquire_buffer(struct SpaceClip *sc);
 
 void ED_clip_update_frame(const struct Main *mainp, int cfra);
+void ED_clip_view_selection(struct SpaceClip *sc, struct ARegion *ar, int fit);
 
 /* clip_ops.c */
 void ED_operatormacros_clip(void);

Modified: branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c      
2011-06-15 17:21:34 UTC (rev 37514)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c      
2011-06-15 17:23:08 UTC (rev 37515)
@@ -125,8 +125,11 @@
 
 static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, 
MovieTrackingMarker *marker)
 {
+       int tiny= sc->flag&SC_SHOW_TINY_MARKER;
+
        UI_ThemeColor(TH_MARKER_OUTLINE);
-       glPointSize(4.0f);
+       if(tiny) glPointSize(3.0f);
+       else glPointSize(4.0f);
        glBegin(GL_POINTS);
                glVertex2f(marker->pos[0], marker->pos[1]);
        glEnd();
@@ -135,7 +138,9 @@
        /* pattern and search outline */
        glPushMatrix();
        glTranslatef(marker->pos[0], marker->pos[1], 0);
-       glLineWidth(3.0f);
+
+       if(!tiny) glLineWidth(3.0f);
+
        if(sc->flag&SC_SHOW_MARKER_PATTERN) {
                glBegin(GL_LINE_LOOP);
                        glVertex2f(track->pat_min[0], track->pat_min[1]);
@@ -154,25 +159,32 @@
                glEnd();
        }
        glPopMatrix();
-       glLineWidth(1.0f);
+
+       if(!tiny) glLineWidth(1.0f);
 }
 
 static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, 
MovieTrackingMarker *marker, int act, int sel)
 {
        int color= act?TH_ACT_MARKER:TH_SEL_MARKER;
+       int tiny= sc->flag&SC_SHOW_TINY_MARKER;
 
        /* marker position */
        if((track->flag&SELECT)==sel) {
                if(track->flag&SELECT) UI_ThemeColor(color);
                else UI_ThemeColor(TH_MARKER);
 
-               glPointSize(2.0f);
+               if(!tiny) glPointSize(2.0f);
                glBegin(GL_POINTS);
                        glVertex2f(marker->pos[0], marker->pos[1]);
                glEnd();
-               glPointSize(1.0f);
+               if(!tiny) glPointSize(1.0f);
        }
 
+       if(tiny) {
+               glLineStipple(3, 0xaaaa);
+               glEnable(GL_LINE_STIPPLE);
+       }
+
        /* pattern */
        glPushMatrix();
        glTranslatef(marker->pos[0], marker->pos[1], 0);
@@ -208,6 +220,8 @@
 
        glPopMatrix();
 
+       if(tiny)
+               glDisable(GL_LINE_STIPPLE);
 }
 
 static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip)
@@ -300,8 +314,9 @@
                draw_movieclip_cache(sc, ar, clip, scene);
 }
 
-void draw_clip_track_widget(const bContext *UNUSED(C), void *trackp, void 
*userp, void *clipp, rcti *rect)
+void draw_clip_track_widget(const bContext *C, void *trackp, void *userp, void 
*clipp, rcti *rect)
 {
+       ARegion *ar= CTX_wm_region(C);
        MovieClipUser *user= (MovieClipUser *)userp;
        MovieClip *clip= (MovieClip *)clipp;
        MovieTrackingTrack *track= (MovieTrackingTrack *)trackp;
@@ -326,23 +341,27 @@
                                        IMB_rect_from_float(tmpibuf);
 
                                if(tmpibuf->rect) {
-                                       int a;
+                                       int a, w, h;
                                        float zoomx, zoomy;
+                                       GLint scissor[4];
 
-                                       zoomx= ((float)rect->xmax-rect->xmin) / 
tmpibuf->x;
-                                       zoomy= ((float)rect->ymax-rect->ymin) / 
tmpibuf->y;
+                                       w= rect->xmax-rect->xmin;
+                                       h= rect->ymax-rect->ymin;
 
+                                       zoomx= ((float)w) / tmpibuf->x;
+                                       zoomy= ((float)h) / tmpibuf->y;
+
                                        glPushMatrix();
 
-                                       glTranslatef(rect->xmin, rect->ymin, 
0.f);
                                        glPixelZoom(zoomx, zoomy);
+                                       glaDrawPixelsSafe(rect->xmin, 
rect->ymin, tmpibuf->x, tmpibuf->y, tmpibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, 
tmpibuf->rect);
+                                       glPixelZoom(1.f, 1.f);
 
-                                       glaDrawPixelsSafe(0, 0, tmpibuf->x, 
tmpibuf->y, tmpibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, tmpibuf->rect);
+                                       glGetIntegerv(GL_VIEWPORT, scissor);
+                                       glScissor(ar->winrct.xmin + 
(rect->xmin-1), ar->winrct.ymin+(rect->ymin-1), (rect->xmax+1)-(rect->xmin-1), 
(rect->ymax+1)-(rect->ymin-1));
 
-                                       glPixelZoom(1.f, 1.f);
+                                       
glTranslatef(rect->xmin+(pos[0]+0.5f)*zoomx, rect->ymin+(pos[1]+0.5f)*zoomy, 
0.f);
 
-                                       glTranslatef((pos[0]+0.5f)*zoomx, 
(pos[1]+0.5f)*zoomy, 0.f);
-

@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to