Revision: 38333
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38333
Author: nazgul
Date: 2011-07-12 13:35:25 +0000 (Tue, 12 Jul 2011)
Log Message:
-----------
Camera tracking integration
===========================
- Fixed buf with under reference for Follow Track constraint.
- Get rid of BKE_movieclip_approx_size. Rather than accessing
to cache with previously set frame number it'll be easier to
store size of last accessed in "runtime" DNA.
Modified Paths:
--------------
branches/soc-2011-tomato/source/blender/blenkernel/BKE_movieclip.h
branches/soc-2011-tomato/source/blender/blenkernel/intern/constraint.c
branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c
branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c
branches/soc-2011-tomato/source/blender/editors/space_clip/tracking_ops.c
branches/soc-2011-tomato/source/blender/makesdna/DNA_movieclip_types.h
branches/soc-2011-tomato/source/blender/makesrna/intern/rna_movieclip.c
branches/soc-2011-tomato/source/blender/makesrna/intern/rna_tracking.c
Modified: branches/soc-2011-tomato/source/blender/blenkernel/BKE_movieclip.h
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/BKE_movieclip.h
2011-07-12 13:17:54 UTC (rev 38332)
+++ branches/soc-2011-tomato/source/blender/blenkernel/BKE_movieclip.h
2011-07-12 13:35:25 UTC (rev 38333)
@@ -48,7 +48,6 @@
struct ImBuf *BKE_movieclip_acquire_ibuf(struct MovieClip *clip, struct
MovieClipUser *user);
void BKE_movieclip_acquire_size(struct MovieClip *clip, struct MovieClipUser
*user, int *width, int *height);
-void BKE_movieclip_approx_size(struct MovieClip *clip, int *width, int
*height);
int BKE_movieclip_has_frame(struct MovieClip *clip, struct MovieClipUser
*user);
void BKE_movieclip_user_set_frame(struct MovieClipUser *user, int framenr);
Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/constraint.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/constraint.c
2011-07-12 13:17:54 UTC (rev 38332)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/constraint.c
2011-07-12 13:35:25 UTC (rev 38333)
@@ -3941,6 +3941,7 @@
data->clip= NULL;
data->flag|= FOLLOWTRACK_DEFAULTCLIP;
+ data->reference= FOLLOWTRACK_TRACK;
}
static void followtrack_id_looper (bConstraint *con, ConstraintIDFunc func,
void *userdata)
Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c
2011-07-12 13:17:54 UTC (rev 38332)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c
2011-07-12 13:35:25 UTC (rev 38333)
@@ -296,9 +296,13 @@
put_imbuf_cache(clip, user, ibuf);
}
- if(ibuf)
+ if(ibuf) {
clip->lastframe= framenr;
+ clip->lastsize[0]= ibuf->x;
+ clip->lastsize[1]= ibuf->y;
+ }
+
return ibuf;
}
@@ -316,41 +320,23 @@
void BKE_movieclip_acquire_size(MovieClip *clip, MovieClipUser *user, int
*width, int *height)
{
- ImBuf *ibuf= BKE_movieclip_acquire_ibuf(clip, user);
-
- if(ibuf && ibuf->x && ibuf->y) {
- *width= ibuf->x;
- *height= ibuf->y;
+ if(!user || user->framenr==clip->lastframe) {
+ *width= clip->lastsize[0];
+ *height= clip->lastsize[1];
} else {
- *width= 0;
- *height= 0;
- }
+ ImBuf *ibuf= BKE_movieclip_acquire_ibuf(clip, user);
- if(ibuf)
- IMB_freeImBuf(ibuf);
-}
+ if(ibuf && ibuf->x && ibuf->y) {
+ *width= ibuf->x;
+ *height= ibuf->y;
+ } else {
+ *width= 0;
+ *height= 0;
+ }
-void BKE_movieclip_approx_size(MovieClip *clip, int *width, int *height)
-{
- ImBuf *ibuf= BKE_movieclip_acquire_ibuf(clip, NULL);
-
- if(!ibuf) {
- MovieClipUser user;
- user.framenr= 0;
-
- ibuf= BKE_movieclip_acquire_ibuf(clip, &user);
+ if(ibuf)
+ IMB_freeImBuf(ibuf);
}
-
- if(ibuf && ibuf->x && ibuf->y) {
- *width= ibuf->x;
- *height= ibuf->y;
- } else {
- *width= 0;
- *height= 0;
- }
-
- if(ibuf)
- IMB_freeImBuf(ibuf);
}
/* get segments of cached frames. useful for debugging cache policies */
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-07-12 13:17:54 UTC (rev 38332)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c
2011-07-12 13:35:25 UTC (rev 38333)
@@ -495,20 +495,16 @@
*regiony= v2d->mask.ymin + y*(v2d->mask.ymax-v2d->mask.ymin);
}
-static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip,
float zoomx, float zoomy)
+static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip,
+ int width, int height, float zoomx, float zoomy)
{
float x, y;
MovieTracking* tracking= &clip->tracking;
MovieTrackingMarker *marker;
MovieTrackingTrack *track;
- int width, height, sel_type, framenr= sc->user.framenr;
+ int sel_type, framenr= sc->user.framenr;
void *sel;
- ED_space_clip_size(sc, &width, &height);
-
- if(!width || !height) /* no image displayed for frame */
- return;
-
/* ** find window pixel coordinates of origin ** */
/* UI_view2d_to_region_no_clip return integer values, this could
@@ -620,9 +616,10 @@
glPopMatrix();
}
-static void draw_tracking(SpaceClip *sc, ARegion *ar, MovieClip *clip, float
zoomx, float zoomy)
+static void draw_tracking(SpaceClip *sc, ARegion *ar, MovieClip *clip,
+ int width, int height, float zoomx, float zoomy)
{
- draw_tracking_tracks(sc, ar, clip, zoomx, zoomy);
+ draw_tracking_tracks(sc, ar, clip, width, height, zoomx, zoomy);
}
void draw_clip_main(SpaceClip *sc, ARegion *ar, Scene *scene)
@@ -643,7 +640,7 @@
draw_movieclip_buffer(sc, ar, ibuf, zoomx, zoomy);
IMB_freeImBuf(ibuf);
- draw_tracking(sc, ar, clip, zoomx, zoomy);
+ draw_tracking(sc, ar, clip, ibuf->x, ibuf->y, zoomx, zoomy);
}
draw_movieclip_cache(sc, ar, clip, scene);
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-12 13:17:54 UTC (rev 38332)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/tracking_ops.c
2011-07-12 13:35:25 UTC (rev 38333)
@@ -1019,14 +1019,11 @@
/* set blender camera focal length so result would look fine
there */
if(focal) {
- int width, height;
Camera *camera= (Camera*)scene->camera->data;
- BKE_movieclip_approx_size(clip, &width, &height);
+ if(clip->lastsize[0])
+ camera->lens=
focal*32.0f/(float)clip->lastsize[0];
- if(width)
- camera->lens= focal*32.0f/(float)width;
-
WM_event_add_notifier(C, NC_OBJECT, camera);
}
}
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-12 13:17:54 UTC (rev 38332)
+++ branches/soc-2011-tomato/source/blender/makesdna/DNA_movieclip_types.h
2011-07-12 13:35:25 UTC (rev 38333)
@@ -53,7 +53,8 @@
char name[240]; /* file path */
int source; /* sequence or movie */
- int lastframe; /* last accessed frame */
+ int lastframe; /* last accessed frame number */
+ int lastsize[2]; /* size of last accessed frame */
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-12 13:17:54 UTC (rev 38332)
+++ branches/soc-2011-tomato/source/blender/makesrna/intern/rna_movieclip.c
2011-07-12 13:35:25 UTC (rev 38333)
@@ -62,12 +62,9 @@
static void rna_MovieClip_size_get(PointerRNA *ptr, int *values)
{
MovieClip *clip= (MovieClip*)ptr->data;
- int width, height;
- BKE_movieclip_approx_size(clip, &width, &height);
-
- values[0]= height;
- values[1]= width;
+ values[0]= clip->lastsize[0];
+ values[1]= clip->lastsize[1];
}
static void rna_MovieClip_resolution_get(PointerRNA *ptr, float *values)
Modified: branches/soc-2011-tomato/source/blender/makesrna/intern/rna_tracking.c
===================================================================
--- branches/soc-2011-tomato/source/blender/makesrna/intern/rna_tracking.c
2011-07-12 13:17:54 UTC (rev 38332)
+++ branches/soc-2011-tomato/source/blender/makesrna/intern/rna_tracking.c
2011-07-12 13:35:25 UTC (rev 38333)
@@ -123,12 +123,8 @@
float val= camera->focal;
if(camera->units==CAMERA_UNITS_MM) {
- int width, height;
-
- BKE_movieclip_approx_size(clip, &width, &height);
-
- if(width)
- val= val*camera->sensor_width/(float)width;
+ if(clip->lastsize[0])
+ val= val*camera->sensor_width/(float)clip->lastsize[0];
}
return val;
@@ -140,12 +136,8 @@
MovieTrackingCamera *camera= &clip->tracking.camera;
if(camera->units==CAMERA_UNITS_MM) {
- int width, height;
-
- BKE_movieclip_approx_size(clip, &width, &height);
-
- if(width)
- value= width*value/camera->sensor_width;
+ if(clip->lastsize[0])
+ value= clip->lastsize[0]*value/camera->sensor_width;
}
camera->focal= value;
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs