[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38038] branches/soc-2011-salad: Merging r38025 through r38037 soc-2011-tomato into soc-2011-salad
Sergey Sharybin
g.ulairi at gmail.com
Sat Jul 2 13:08:29 CEST 2011
Revision: 38038
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38038
Author: nazgul
Date: 2011-07-02 11:08:29 +0000 (Sat, 02 Jul 2011)
Log Message:
-----------
Merging r38025 through r38037 soc-2011-tomato into soc-2011-salad
Revision Links:
--------------
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38025
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38037
Modified Paths:
--------------
branches/soc-2011-salad/source/blender/blenkernel/BKE_tracking.h
branches/soc-2011-salad/source/blender/blenkernel/intern/tracking.c
branches/soc-2011-salad/source/blender/editors/space_clip/clip_draw.c
Property Changed:
----------------
branches/soc-2011-salad/
Property changes on: branches/soc-2011-salad
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/soc-2010-jwilkins:28499-37009
/branches/soc-2010-nicolasbishop:28448-30783,30792-30793,30797-30798,30815
/branches/soc-2011-cucumber:36829-36994
/branches/soc-2011-onion:36833-37529
/branches/soc-2011-pepper:36830-37151
/branches/soc-2011-tomato:36831-38024
/trunk/blender:36834-38033
+ /branches/soc-2010-jwilkins:28499-37009
/branches/soc-2010-nicolasbishop:28448-30783,30792-30793,30797-30798,30815
/branches/soc-2011-cucumber:36829-36994
/branches/soc-2011-onion:36833-37529
/branches/soc-2011-pepper:36830-37151
/branches/soc-2011-tomato:36831-38037
/trunk/blender:36834-38036
Modified: branches/soc-2011-salad/source/blender/blenkernel/BKE_tracking.h
===================================================================
--- branches/soc-2011-salad/source/blender/blenkernel/BKE_tracking.h 2011-07-02 11:06:30 UTC (rev 38037)
+++ branches/soc-2011-salad/source/blender/blenkernel/BKE_tracking.h 2011-07-02 11:08:29 UTC (rev 38038)
@@ -55,8 +55,10 @@
void BKE_tracking_clear_path(struct MovieTrackingTrack *track, int ref_frame, int action);
void BKE_tracking_free(struct MovieTracking *tracking);
-struct ImBuf *BKE_tracking_acquire_pattern_imbuf(struct ImBuf *ibuf, struct MovieTrackingTrack *track, struct MovieTrackingMarker *marker, int pos[2]);
-struct ImBuf *BKE_tracking_acquire_search_imbuf(struct ImBuf *ibuf, struct MovieTrackingTrack *track, struct MovieTrackingMarker *marker, int pos[2]);
+struct ImBuf *BKE_tracking_acquire_pattern_imbuf(struct ImBuf *ibuf, struct MovieTrackingTrack *track,
+ struct MovieTrackingMarker *marker, int margin, float pos[2], int origin[2]);
+struct ImBuf *BKE_tracking_acquire_search_imbuf(struct ImBuf *ibuf, struct MovieTrackingTrack *track,
+ struct MovieTrackingMarker *marker, int margin, float pos[2], int origin[2]);
struct MovieTrackingContext *BKE_tracking_context_new(struct MovieClip *clip, struct MovieClipUser *user, int backwards);
void BKE_tracking_context_free(struct MovieTrackingContext *context);
Modified: branches/soc-2011-salad/source/blender/blenkernel/intern/tracking.c
===================================================================
--- branches/soc-2011-salad/source/blender/blenkernel/intern/tracking.c 2011-07-02 11:06:30 UTC (rev 38037)
+++ branches/soc-2011-salad/source/blender/blenkernel/intern/tracking.c 2011-07-02 11:08:29 UTC (rev 38038)
@@ -422,8 +422,8 @@
if((track->flag&(TRACK_DISABLE_RED|TRACK_DISABLE_GREEN|TRACK_DISABLE_BLUE))==0)
return;
- for(y= 0; y<ibuf->x; y++) {
- for (x= 0; x<ibuf->y; x++) {
+ for(y= 0; y<ibuf->y; y++) {
+ for (x= 0; x<ibuf->x; x++) {
int pixel= ibuf->x*y + x;
char *rrgb= (char*)ibuf->rect + pixel*4;
@@ -434,7 +434,8 @@
}
}
-static ImBuf *acquire_area_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, MovieTrackingMarker *marker, float min[2], float max[2], int pos[2])
+static ImBuf *acquire_area_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, MovieTrackingMarker *marker,
+ float min[2], float max[2], int margin, float pos[2], int origin[2])
{
ImBuf *tmpibuf;
int x, y;
@@ -455,30 +456,39 @@
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);
+ tmpibuf= IMB_allocImBuf(w+margin*2, h+margin*2, 32, IB_rect);
+ IMB_rectcpy(tmpibuf, ibuf, 0, 0, x1-margin, y1-margin, w+margin*2, h+margin*2);
- pos[0]= x-x1;
- pos[1]= y-y1;
+ if(pos != NULL) {
+ pos[0]= x-x1+(marker->pos[0]*ibuf->x-x)+margin;
+ pos[1]= y-y1+(marker->pos[1]*ibuf->y-y)+margin;
+ }
+ if(origin != NULL) {
+ origin[0]= x1-margin;
+ origin[1]= y1-margin;
+ }
+
disable_imbuf_channels(tmpibuf, track);
return tmpibuf;
}
-ImBuf *BKE_tracking_acquire_pattern_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, MovieTrackingMarker *marker, int pos[2])
+ImBuf *BKE_tracking_acquire_pattern_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, MovieTrackingMarker *marker,
+ int margin, float pos[2], int origin[2])
{
- return acquire_area_imbuf(ibuf, track, marker, track->pat_min, track->pat_max, pos);
+ return acquire_area_imbuf(ibuf, track, marker, track->pat_min, track->pat_max, margin, pos, origin);
}
-ImBuf *BKE_tracking_acquire_search_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, MovieTrackingMarker *marker, int pos[2])
+ImBuf *BKE_tracking_acquire_search_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, MovieTrackingMarker *marker,
+ int margin, float pos[2], int origin[2])
{
- return acquire_area_imbuf(ibuf, track, marker, track->search_min, track->search_max, pos);
+ return acquire_area_imbuf(ibuf, track, marker, track->search_min, track->search_max, margin, pos, origin);
}
#ifdef WITH_LIBMV
static float *acquire_search_floatbuf(ImBuf *ibuf, MovieTrackingTrack *track, MovieTrackingMarker *marker,
- int *width_r, int *height_r, int pos[2])
+ int *width_r, int *height_r, float pos[2], int origin[2])
{
ImBuf *tmpibuf;
float *pixels, *fp;
@@ -487,10 +497,7 @@
width= (track->search_max[0]-track->search_min[0])*ibuf->x;
height= (track->search_max[1]-track->search_min[1])*ibuf->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);
+ tmpibuf= BKE_tracking_acquire_search_imbuf(ibuf, track, marker, 0, pos, origin);
disable_imbuf_channels(tmpibuf, track);
*width_r= width;
@@ -621,11 +628,11 @@
if(marker && (marker->flag&MARKER_DISABLED)==0 && marker->framenr==curfra) {
#ifdef WITH_LIBMV
- int width, height, pos[2];
- float *patch= acquire_search_floatbuf(ibuf, track, marker, &width, &height, pos);
- float *patch_new= acquire_search_floatbuf(ibuf_new, track, marker, &width, &height, pos);
- //double x1= pos[0], y1= pos[1];
- double x1= -track->search_min[0]*ibuf->x, y1= -track->search_min[1]*ibuf->y;
+ int width, height, origin[2];
+ float pos[2];
+ float *patch= acquire_search_floatbuf(ibuf, track, marker, &width, &height, pos, origin);
+ float *patch_new= acquire_search_floatbuf(ibuf_new, track, marker, &width, &height, pos, origin);
+ double x1= pos[0], y1= pos[1];
double x2= x1, y2= y1;
int wndx, wndy;
@@ -638,8 +645,8 @@
MovieTrackingMarker marker_new;
memset(&marker_new, 0, sizeof(marker_new));
- marker_new.pos[0]= marker->pos[0]+track->search_min[0]+x2/ibuf_new->x;
- marker_new.pos[1]= marker->pos[1]+track->search_min[1]+y2/ibuf_new->y;
+ marker_new.pos[0]= (origin[0]+x2)/ibuf_new->x;
+ marker_new.pos[1]= (origin[1]+y2)/ibuf_new->y;
if(context->backwards) marker_new.framenr= curfra-1;
else marker_new.framenr= curfra+1;
Modified: branches/soc-2011-salad/source/blender/editors/space_clip/clip_draw.c
===================================================================
--- branches/soc-2011-salad/source/blender/editors/space_clip/clip_draw.c 2011-07-02 11:06:30 UTC (rev 38037)
+++ branches/soc-2011-salad/source/blender/editors/space_clip/clip_draw.c 2011-07-02 11:08:29 UTC (rev 38038)
@@ -491,6 +491,28 @@
draw_movieclip_cache(sc, ar, clip, scene);
}
+static ImBuf *scale_ibuf(ImBuf *ibuf, float zoomx, float zoomy)
+{
+ ImBuf *scaleibuf;
+ int x, y, w= ibuf->x*zoomx, h= ibuf->y*zoomy;
+ scaleibuf= IMB_allocImBuf(w, h, 32, IB_rect);
+
+ for(y= 0; y<scaleibuf->y; y++) {
+ for (x= 0; x<scaleibuf->x; x++) {
+ int pixel= scaleibuf->x*y + x;
+ int orig_pixel= ibuf->x*(int)(((float)y)/zoomy) + (int)(((float)x)/zoomx);
+ char *rrgb= (char*)scaleibuf->rect + pixel*4;
+ char *orig_rrgb= (char*)ibuf->rect + orig_pixel*4;
+ rrgb[0]= orig_rrgb[0];
+ rrgb[1]= orig_rrgb[1];
+ rrgb[2]= orig_rrgb[2];
+ rrgb[3]= orig_rrgb[3];
+ }
+ }
+
+ return scaleibuf;
+}
+
void draw_clip_track_widget(const bContext *C, void *trackp, void *userp, void *clipp, rcti *rect)
{
ARegion *ar= CTX_wm_region(C);
@@ -516,36 +538,40 @@
ImBuf* ibuf= BKE_movieclip_acquire_ibuf(clip, user);
if(ibuf && ibuf->rect) {
- int pos[2];
- ImBuf* tmpibuf;
+ float pos[2];
+ ImBuf *tmpibuf;
- tmpibuf= BKE_tracking_acquire_pattern_imbuf(ibuf, track, marker, pos);
+ tmpibuf= BKE_tracking_acquire_pattern_imbuf(ibuf, track, marker, 1, pos, NULL);
if(tmpibuf->rect_float)
IMB_rect_from_float(tmpibuf);
if(tmpibuf->rect) {
- int a, w, h;
- float zoomx, zoomy;
+ int a;
+ float zoomx, zoomy, off_x, off_y;
GLint scissor[4];
+ ImBuf *drawibuf;
- w= rect->xmax-rect->xmin;
- h= rect->ymax-rect->ymin;
+ zoomx= ((float)rect->xmax-rect->xmin) / (tmpibuf->x-2);
+ zoomy= ((float)rect->ymax-rect->ymin) / (tmpibuf->y-2);
- zoomx= ((float)w) / tmpibuf->x;
- zoomy= ((float)h) / tmpibuf->y;
+ off_x= ((int)pos[0]-pos[0]-0.5)*zoomx;
+ off_y= ((int)pos[1]-pos[1]-0.5)*zoomy;
glPushMatrix();
- 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);
+ glGetIntegerv(GL_VIEWPORT, scissor);
- glGetIntegerv(GL_VIEWPORT, scissor);
+ /* draw content of pattern area */
+ glScissor(ar->winrct.xmin+rect->xmin, ar->winrct.ymin+rect->ymin, scissor[2], scissor[3]);
+
+ drawibuf= scale_ibuf(tmpibuf, zoomx, zoomy);
+ glaDrawPixelsSafe(off_x+rect->xmin, off_y+rect->ymin, rect->xmax-rect->xmin-off_x, rect->ymax-rect->ymin-off_y, drawibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, drawibuf->rect);
+
+ /* draw cross for pizel position */
+ glTranslatef(off_x+rect->xmin+pos[0]*zoomx, off_y+rect->ymin+pos[1]*zoomy, 0.f);
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));
- glTranslatef(rect->xmin+(pos[0]+0.5f)*zoomx, rect->ymin+(pos[1]+0.5f)*zoomy, 0.f);
-
for(a= 0; a< 2; a++) {
if(a==1) {
glLineStipple(3, 0xaaaa);
@@ -557,10 +583,10 @@
}
glBegin(GL_LINES);
- glVertex2f(-10, 0);
- glVertex2f(10, 0);
- glVertex2f(0, -10);
- glVertex2f(0, 10);
+ glVertex2f(-10.0f, 0.0f);
+ glVertex2f(10.0f, 0.0f);
+ glVertex2f(0.0f, -10.0f);
+ glVertex2f(0.0f, 10.0f);
glEnd();
}
@@ -569,6 +595,8 @@
glPopMatrix();
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list