[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [45625] branches/soc-2011-tomato/source/ blender: Camera tracking: if there's no image for current frame display

Sergey Sharybin sergey.vfx at gmail.com
Sat Apr 14 14:02:54 CEST 2012


Revision: 45625
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45625
Author:   nazgul
Date:     2012-04-14 12:02:54 +0000 (Sat, 14 Apr 2012)
Log Message:
-----------
Camera tracking: if there's no image for current frame display
default grid and allow to interact with tracks for operators
which doesn't require image.

Modified Paths:
--------------
    branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c
    branches/soc-2011-tomato/source/blender/editors/include/ED_screen.h
    branches/soc-2011-tomato/source/blender/editors/screen/area.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/editors/space_image/image_draw.c
    branches/soc-2011-tomato/source/blender/editors/transform/transform_conversions.c

Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c	2012-04-14 12:02:47 UTC (rev 45624)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c	2012-04-14 12:02:54 UTC (rev 45625)
@@ -925,8 +925,8 @@
 			real_ibuf_size(clip, user, ibuf, width, height);
 		}
 		else {
-			*width = 0;
-			*height = 0;
+			*width = clip->lastsize[0];
+			*height = clip->lastsize[1];
 		}
 
 		if (ibuf)

Modified: branches/soc-2011-tomato/source/blender/editors/include/ED_screen.h
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/include/ED_screen.h	2012-04-14 12:02:47 UTC (rev 45624)
+++ branches/soc-2011-tomato/source/blender/editors/include/ED_screen.h	2012-04-14 12:02:54 UTC (rev 45625)
@@ -66,6 +66,7 @@
 void	ED_region_toggle_hidden(struct bContext *C, struct ARegion *ar);
 void	region_scissor_winrct(struct ARegion *ar, struct rcti *winrct);
 void	ED_region_info_draw(struct ARegion *ar, const char *text, int block, float alpha);
+void	ED_region_grid_draw(struct ARegion *ar, float zoomx, float zoomy);
 
 /* spaces */
 void	ED_spacetypes_init(void);

Modified: branches/soc-2011-tomato/source/blender/editors/screen/area.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/screen/area.c	2012-04-14 12:02:47 UTC (rev 45624)
+++ branches/soc-2011-tomato/source/blender/editors/screen/area.c	2012-04-14 12:02:54 UTC (rev 45625)
@@ -1813,3 +1813,63 @@
 	BLF_position(fontid, 12, rect.ymin + 5, 0.0f);
 	BLF_draw(fontid, text, BLF_DRAW_STR_DUMMY_MAX);
 }
+
+void ED_region_grid_draw(ARegion *ar, float zoomx, float zoomy)
+{
+	float gridsize, gridstep = 1.0f / 32.0f;
+	float fac, blendfac;
+	int x1, y1, x2, y2;
+
+	/* the image is located inside (0,0),(1, 1) as set by view2d */
+	UI_ThemeColorShade(TH_BACK, 20);
+
+	UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x1, &y1);
+	UI_view2d_to_region_no_clip(&ar->v2d, 1.0f, 1.0f, &x2, &y2);
+	glRectf(x1, y1, x2, y2);
+
+	/* gridsize adapted to zoom level */
+	gridsize = 0.5f * (zoomx + zoomy);
+	if (gridsize <= 0.0f)
+		return;
+
+	if (gridsize < 1.0f) {
+		while (gridsize < 1.0f) {
+			gridsize *= 4.0f;
+			gridstep *= 4.0f;
+		}
+	}
+	else {
+		while (gridsize >= 4.0f) {
+			gridsize /= 4.0f;
+			gridstep /= 4.0f;
+		}
+	}
+
+	/* the fine resolution level */
+	blendfac = 0.25f * gridsize - floorf(0.25f * gridsize);
+	CLAMP(blendfac, 0.0f, 1.0f);
+	UI_ThemeColorShade(TH_BACK, (int)(20.0f * (1.0f - blendfac)));
+
+	fac = 0.0f;
+	glBegin(GL_LINES);
+	while (fac < 1.0f) {
+		glVertex2f(x1, y1 * (1.0f - fac) + y2 * fac);
+		glVertex2f(x2, y1 * (1.0f - fac) + y2 * fac);
+		glVertex2f(x1 * (1.0f - fac) + x2 * fac, y1);
+		glVertex2f(x1 * (1.0f - fac) + x2 * fac, y2);
+		fac += gridstep;
+	}
+
+	/* the large resolution level */
+	UI_ThemeColor(TH_BACK);
+
+	fac = 0.0f;
+	while (fac < 1.0f) {
+		glVertex2f(x1, y1 * (1.0f - fac) + y2 * fac);
+		glVertex2f(x2, y1 * (1.0f - fac) + y2 * fac);
+		glVertex2f(x1 * (1.0f - fac) + x2 * fac, y1);
+		glVertex2f(x1 * (1.0f - fac) + x2 * fac, y2);
+		fac += 4.0f * gridstep;
+	}
+	glEnd();
+}

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	2012-04-14 12:02:47 UTC (rev 45624)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c	2012-04-14 12:02:54 UTC (rev 45625)
@@ -1400,7 +1400,12 @@
 	if (ibuf) {
 		draw_movieclip_buffer(sc, ar, ibuf, width, height, zoomx, zoomy);
 		IMB_freeImBuf(ibuf);
+	}
+	else {
+		ED_region_grid_draw(ar, zoomx, zoomy);
+	}
 
+	if (width && height) {
 		draw_tracking_tracks(sc, ar, clip, width, height, zoomx, zoomy);
 		draw_distortion(sc, ar, clip, width, height, zoomx, zoomy);
 	}

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	2012-04-14 12:02:47 UTC (rev 45624)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/tracking_ops.c	2012-04-14 12:02:54 UTC (rev 45625)
@@ -92,6 +92,25 @@
 	return FALSE;
 }
 
+static int space_clip_size_poll(bContext *C)
+{
+	SpaceClip *sc = CTX_wm_space_clip(C);
+
+	if (sc) {
+		MovieClip *clip = ED_space_clip(sc);
+
+		if (clip) {
+			int width, height;
+
+			BKE_movieclip_get_size(clip, &sc->user, &width, &height);
+
+			return width > 0 && height > 0;
+		}
+	}
+
+	return FALSE;
+}
+
 /********************** add marker operator *********************/
 
 static void add_marker(SpaceClip *sc, float x, float y)
@@ -156,7 +175,7 @@
 	/* api callbacks */
 	ot->invoke = add_marker_invoke;
 	ot->exec = add_marker_exec;
-	ot->poll = space_clip_frame_poll;
+	ot->poll = space_clip_size_poll;
 
 	/* flags */
 	ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -643,7 +662,7 @@
 	ot->idname = "CLIP_OT_slide_marker";
 
 	/* api callbacks */
-	ot->poll = space_clip_frame_poll;
+	ot->poll = space_clip_size_poll;
 	ot->invoke = slide_marker_invoke;
 	ot->modal = slide_marker_modal;
 
@@ -1200,7 +1219,7 @@
 
 	/* api callbacks */
 	ot->exec = select_groped_exec;
-	ot->poll = space_clip_frame_poll;
+	ot->poll = space_clip_size_poll;
 
 	/* flags */
 	ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -2016,7 +2035,7 @@
 
 static int set_orientation_poll(bContext *C)
 {
-	if (space_clip_frame_poll(C)) {
+	if (space_clip_size_poll(C)) {
 		Scene *scene = CTX_data_scene(C);
 		SpaceClip *sc = CTX_wm_space_clip(C);
 		MovieClip *clip = ED_space_clip(sc);
@@ -2626,7 +2645,7 @@
 
 static int set_solution_scale_poll(bContext *C)
 {
-	if (space_clip_frame_poll(C)) {
+	if (space_clip_size_poll(C)) {
 		SpaceClip *sc = CTX_wm_space_clip(C);
 		MovieClip *clip = ED_space_clip(sc);
 		MovieTracking *tracking = &clip->tracking;
@@ -2974,7 +2993,7 @@
 
 	/* api callbacks */
 	ot->exec = frame_jump_exec;
-	ot->poll = space_clip_frame_poll;
+	ot->poll = ED_space_clip_poll;
 
 	/* flags */
 	ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -3031,7 +3050,7 @@
 
 	/* api callbacks */
 	ot->exec = join_tracks_exec;
-	ot->poll = space_clip_frame_poll;
+	ot->poll = space_clip_size_poll;
 
 	/* flags */
 	ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;

Modified: branches/soc-2011-tomato/source/blender/editors/space_image/image_draw.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_image/image_draw.c	2012-04-14 12:02:47 UTC (rev 45624)
+++ branches/soc-2011-tomato/source/blender/editors/space_image/image_draw.c	2012-04-14 12:02:54 UTC (rev 45625)
@@ -334,65 +334,6 @@
 
 /* image drawing */
 
-static void draw_image_grid(ARegion *ar, float zoomx, float zoomy)
-{
-	float gridsize, gridstep = 1.0f / 32.0f;
-	float fac, blendfac;
-	int x1, y1, x2, y2;
-	
-	/* the image is located inside (0,0),(1, 1) as set by view2d */
-	UI_ThemeColorShade(TH_BACK, 20);
-
-	UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x1, &y1);
-	UI_view2d_to_region_no_clip(&ar->v2d, 1.0f, 1.0f, &x2, &y2);
-	glRectf(x1, y1, x2, y2);
-
-	/* gridsize adapted to zoom level */
-	gridsize = 0.5f * (zoomx + zoomy);
-	if (gridsize <= 0.0f) return;
-	
-	if (gridsize < 1.0f) {
-		while (gridsize < 1.0f) {
-			gridsize *= 4.0f;
-			gridstep *= 4.0f;
-		}
-	}
-	else {
-		while (gridsize >= 4.0f) {
-			gridsize /= 4.0f;
-			gridstep /= 4.0f;
-		}
-	}
-	
-	/* the fine resolution level */
-	blendfac = 0.25f * gridsize - floorf(0.25f * gridsize);
-	CLAMP(blendfac, 0.0f, 1.0f);
-	UI_ThemeColorShade(TH_BACK, (int)(20.0f * (1.0f - blendfac)));
-	
-	fac = 0.0f;
-	glBegin(GL_LINES);
-	while (fac < 1.0f) {
-		glVertex2f(x1, y1 * (1.0f - fac) + y2 * fac);
-		glVertex2f(x2, y1 * (1.0f - fac) + y2 * fac);
-		glVertex2f(x1 * (1.0f - fac) + x2 * fac, y1);
-		glVertex2f(x1 * (1.0f - fac) + x2 * fac, y2);
-		fac += gridstep;
-	}
-	
-	/* the large resolution level */
-	UI_ThemeColor(TH_BACK);
-	
-	fac = 0.0f;
-	while (fac < 1.0f) {
-		glVertex2f(x1, y1 * (1.0f - fac) + y2 * fac);
-		glVertex2f(x2, y1 * (1.0f - fac) + y2 * fac);
-		glVertex2f(x1 * (1.0f - fac) + x2 * fac, y1);
-		glVertex2f(x1 * (1.0f - fac) + x2 * fac, y2);
-		fac += 4.0f * gridstep;
-	}
-	glEnd();
-}
-
 static void sima_draw_alpha_pixels(float x1, float y1, int rectx, int recty, unsigned int *recti)
 {
 	
@@ -781,7 +722,7 @@
 
 	/* draw the image or grid */
 	if (ibuf == NULL)
-		draw_image_grid(ar, zoomx, zoomy);
+		ED_region_grid_draw(ar, zoomx, zoomy);
 	else if (sima->flag & SI_DRAW_TILE)
 		draw_image_buffer_repeated(sima, ar, scene, ima, ibuf, zoomx, zoomy);
 	else if (ima && (ima->tpageflag & IMA_TILES))

Modified: branches/soc-2011-tomato/source/blender/editors/transform/transform_conversions.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/transform/transform_conversions.c	2012-04-14 12:02:47 UTC (rev 45624)
+++ branches/soc-2011-tomato/source/blender/editors/transform/transform_conversions.c	2012-04-14 12:02:54 UTC (rev 45625)
@@ -5753,10 +5753,13 @@
 	ARegion *ar = CTX_wm_region(C);
 	SpaceClip *sc = CTX_wm_space_clip(C);
 	MovieClip *clip = ED_space_clip(sc);
+	int width, height;
 
 	t->total = 0;
 
-	if (!clip || !BKE_movieclip_has_frame(clip, &sc->user))
+	BKE_movieclip_get_size(clip, &sc->user, &width, &height);
+
+	if (!clip || width == 0 || height == 0)
 		return;
 
 	if (!ELEM(t->mode, TFM_RESIZE, TFM_TRANSLATION))




More information about the Bf-blender-cvs mailing list