[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39187] branches/soc-2011-tomato/source/ blender: Camera tracking integration

Sergey Sharybin g.ulairi at gmail.com
Mon Aug 8 18:30:10 CEST 2011


Revision: 39187
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39187
Author:   nazgul
Date:     2011-08-08 16:30:09 +0000 (Mon, 08 Aug 2011)
Log Message:
-----------
Camera tracking integration
===========================

Added grease pencil to clip editor.
Idea is to use it for supervised camera calibraiton.

"Disable Marker" hotkey was changed to Shift-D

Modified Paths:
--------------
    branches/soc-2011-tomato/source/blender/blenloader/intern/readfile.c
    branches/soc-2011-tomato/source/blender/editors/gpencil/drawgpencil.c
    branches/soc-2011-tomato/source/blender/editors/gpencil/editaction_gpencil.c
    branches/soc-2011-tomato/source/blender/editors/gpencil/gpencil_edit.c
    branches/soc-2011-tomato/source/blender/editors/gpencil/gpencil_paint.c
    branches/soc-2011-tomato/source/blender/editors/space_clip/clip_buttons.c
    branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c
    branches/soc-2011-tomato/source/blender/editors/space_clip/clip_intern.h
    branches/soc-2011-tomato/source/blender/editors/space_clip/space_clip.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

Modified: branches/soc-2011-tomato/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenloader/intern/readfile.c	2011-08-08 14:50:10 UTC (rev 39186)
+++ branches/soc-2011-tomato/source/blender/blenloader/intern/readfile.c	2011-08-08 16:30:09 UTC (rev 39187)
@@ -5708,6 +5708,8 @@
 	if(fd->movieclipmap) clip->cache= newmclipadr(fd, clip->cache);
 	else clip->cache= NULL;
 
+	clip->gpd= newlibadr_us(fd, clip->id.lib, clip->gpd);
+
 	tracking->reconstruction.cameras= newdataadr(fd, tracking->reconstruction.cameras);
 
 	link_list(fd, &tracking->tracks);

Modified: branches/soc-2011-tomato/source/blender/editors/gpencil/drawgpencil.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/gpencil/drawgpencil.c	2011-08-08 14:50:10 UTC (rev 39186)
+++ branches/soc-2011-tomato/source/blender/editors/gpencil/drawgpencil.c	2011-08-08 16:30:09 UTC (rev 39187)
@@ -690,6 +690,7 @@
 	/* calculate rect */
 	switch (sa->spacetype) {
 		case SPACE_IMAGE: /* image */
+		case SPACE_CLIP: /* clip */
 		{
 			
 			/* just draw using standard scaling (settings here are currently ignored anyways) */
@@ -763,7 +764,7 @@
 	
 	/* special hack for Image Editor */
 	// FIXME: the opengl poly-strokes don't draw at right thickness when done this way, so disabled
-	if (sa->spacetype == SPACE_IMAGE)
+	if (ELEM(sa->spacetype, SPACE_IMAGE, SPACE_CLIP))
 		dflag |= GP_DRAWDATA_IEDITHACK;
 	
 	/* draw it! */

Modified: branches/soc-2011-tomato/source/blender/editors/gpencil/editaction_gpencil.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/gpencil/editaction_gpencil.c	2011-08-08 14:50:10 UTC (rev 39186)
+++ branches/soc-2011-tomato/source/blender/editors/gpencil/editaction_gpencil.c	2011-08-08 16:30:09 UTC (rev 39187)
@@ -511,6 +511,7 @@
 								
 							case SPACE_NODE: /* Nodes Editor: either screen-aligned or view-aligned */
 							case SPACE_IMAGE: /* Image Editor: either screen-aligned or view\image-aligned */
+							case SPACE_CLIP: /* Image Editor: either screen-aligned or view\image-aligned */
 								if ((gps->flag == 0) || (gps->flag & GP_STROKE_2DSPACE))
 									stroke_ok= 1;
 								break;

Modified: branches/soc-2011-tomato/source/blender/editors/gpencil/gpencil_edit.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/gpencil/gpencil_edit.c	2011-08-08 14:50:10 UTC (rev 39186)
+++ branches/soc-2011-tomato/source/blender/editors/gpencil/gpencil_edit.c	2011-08-08 16:30:09 UTC (rev 39187)
@@ -71,6 +71,7 @@
 
 #include "ED_gpencil.h"
 #include "ED_view3d.h"
+#include "ED_clip.h"
 
 #include "gpencil_intern.h"
 
@@ -139,6 +140,19 @@
 			}
 				break;
 				
+			case SPACE_CLIP: /* Nodes Editor */
+			{
+				SpaceClip *sc= (SpaceClip *)CTX_wm_space_data(C);
+				MovieClip *clip= ED_space_clip(sc);
+
+				if(clip) {
+					/* for now, as long as there's a clip, default to using that in Clip Editor */
+					if (ptr) RNA_id_pointer_create(&clip->id, ptr);
+					return &clip->gpd;
+				}
+			}
+				break;
+				
 			default: /* unsupported space */
 				return NULL;
 		}

Modified: branches/soc-2011-tomato/source/blender/editors/gpencil/gpencil_paint.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/gpencil/gpencil_paint.c	2011-08-08 14:50:10 UTC (rev 39186)
+++ branches/soc-2011-tomato/source/blender/editors/gpencil/gpencil_paint.c	2011-08-08 16:30:09 UTC (rev 39187)
@@ -1026,7 +1026,28 @@
 #endif
 		}
 			break;
-
+		case SPACE_CLIP:
+		{
+			//SpaceClip *sc= curarea->spacedata.first;
+			
+			/* set the current area */
+			p->sa= curarea;
+			p->ar= ar;
+			p->v2d= &ar->v2d;
+			//p->ibuf= BKE_image_get_ibuf(sima->image, &sima->iuser);
+			
+#if 0 // XXX disabled for now
+			/* check that gpencil data is allowed to be drawn */
+			if ((sc->flag & SC_DISPGP)==0) {
+				p->status= GP_STATUS_ERROR;
+				if (G.f & G_DEBUG)
+					printf("Error: In active view, Grease Pencil not shown \n");
+				return p;
+			}
+#endif
+		}
+			break;
+			
 		/* unsupported views */
 		default:
 		{
@@ -1211,6 +1232,12 @@
 					p->gpd->sbuffer_sflag |= GP_STROKE_2DSPACE;
 			}
 				break;
+				
+			case SPACE_CLIP:
+			{
+				p->gpd->sbuffer_sflag |= GP_STROKE_2DSPACE;
+			}
+				break;
 		}
 	}
 }

Modified: branches/soc-2011-tomato/source/blender/editors/space_clip/clip_buttons.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_clip/clip_buttons.c	2011-08-08 14:50:10 UTC (rev 39186)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/clip_buttons.c	2011-08-08 16:30:09 UTC (rev 39187)
@@ -51,6 +51,7 @@
 #include "BKE_tracking.h"
 
 #include "ED_clip.h"
+#include "ED_gpencil.h"
 
 #include "UI_interface.h"
 #include "UI_resources.h"
@@ -303,6 +304,13 @@
 	pt->poll= clip_panel_marker_poll;
 
 	BLI_addtail(&art->paneltypes, pt);
+
+	pt= MEM_callocN(sizeof(PanelType), "spacetype clip panel gpencil");
+	strcpy(pt->idname, "CLIP_PT_gpencil");
+	strcpy(pt->label, "Grease Pencil");
+	pt->draw= gpencil_panel_standard;
+	pt->flag|= PNL_DEFAULT_CLOSED;
+	BLI_addtail(&art->paneltypes, pt);
 }
 
 /********************* MovieClip Template ************************/

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-08-08 14:50:10 UTC (rev 39186)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c	2011-08-08 16:30:09 UTC (rev 39187)
@@ -51,6 +51,7 @@
 
 #include "ED_screen.h"
 #include "ED_clip.h"
+#include "ED_gpencil.h"
 
 #include "BIF_gl.h"
 #include "BIF_glutil.h"
@@ -1019,3 +1020,26 @@
 
 	draw_movieclip_cache(sc, ar, clip, scene);
 }
+
+/* draw grease pencil */
+void draw_clip_grease_pencil(bContext *C, int onlyv2d)
+{
+	SpaceClip *sc= CTX_wm_space_clip(C);
+	MovieClip *clip= ED_space_clip(sc);
+	ImBuf *ibuf;
+
+	if(/*(sc->flag&SI_DISPGP)==0 ||*/! clip)
+		return;
+
+	if(onlyv2d) {
+		ibuf= ED_space_clip_acquire_buffer(sc);
+
+		if(ibuf) {
+				draw_gpencil_2dimage(C, ibuf);
+
+			IMB_freeImBuf(ibuf);
+		}
+	} else {
+		draw_gpencil_view2d(C, 0);
+	}
+}

Modified: branches/soc-2011-tomato/source/blender/editors/space_clip/clip_intern.h
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_clip/clip_intern.h	2011-08-08 14:50:10 UTC (rev 39186)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/clip_intern.h	2011-08-08 16:30:09 UTC (rev 39187)
@@ -102,7 +102,7 @@
 
 /* clip_draw.c */
 void draw_clip_main(struct SpaceClip *sc, struct ARegion *ar, struct Scene *scene);
-void draw_clip_track_widget(const bContext *C, void *poin, void *arg1, void *arg2, rcti *rect);
+void draw_clip_grease_pencil(struct bContext *C, int onlyv2d);
 
 /* clip_buttons.c */
 void ED_clip_buttons_register(struct ARegionType *art);

Modified: branches/soc-2011-tomato/source/blender/editors/space_clip/space_clip.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_clip/space_clip.c	2011-08-08 14:50:10 UTC (rev 39186)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/space_clip.c	2011-08-08 16:30:09 UTC (rev 39187)
@@ -395,7 +395,7 @@
 
 	WM_keymap_add_item(keymap, "CLIP_OT_slide_marker", LEFTMOUSE, KM_PRESS, 0, 0);
 
-	kmi= WM_keymap_add_item(keymap, "CLIP_OT_disable_markers", DKEY, KM_PRESS, 0, 0);
+	kmi= WM_keymap_add_item(keymap, "CLIP_OT_disable_markers", DKEY, KM_PRESS, KM_SHIFT, 0);
 	RNA_enum_set(kmi->ptr, "action", 2);	/* toggle */
 
 	/* tracks */
@@ -560,12 +560,30 @@
 
 	/* data... */
 	movieclip_main_area_set_view2d(sc, ar);
+
 	draw_clip_main(sc, ar, scene);
 
+	/* Grease Pencil */
+	draw_clip_grease_pencil((bContext *)C, 1);
+
 	/* reset view matrix */
 	UI_view2d_view_restore(C);
+
+	/* draw Grease Pencil - screen space only */
+	draw_clip_grease_pencil((bContext *)C, 0);
 }
 
+static void clip_main_area_listener(ARegion *ar, wmNotifier *wmn)
+{
+	/* context changes */
+	switch(wmn->category) {
+		case NC_SCREEN:
+			if (wmn->data==ND_GPENCIL)
+				ED_region_tag_redraw(ar);
+		break;
+	}
+}
+
 /****************** header region ******************/
 
 /* add handlers, stuff you only do once or on area/region changes */
@@ -635,6 +653,21 @@
 	ED_region_panels(C, ar, 1, NULL, -1);
 }
 
+static void clip_properties_area_listener(ARegion *ar, wmNotifier *wmn)
+{
+	/* context changes */
+	switch(wmn->category) {
+		case NC_SCREEN:
+			if (wmn->data==ND_GPENCIL)
+				ED_region_tag_redraw(ar);
+			break;
+		case NC_BRUSH:
+			if(wmn->action==NA_EDITED)
+				ED_region_tag_redraw(ar);
+			break;
+	}
+}
+
 /********************* registration ********************/
 
 /* only called once, from space/spacetypes.c */
@@ -661,7 +694,8 @@
 	art->regionid= RGN_TYPE_WINDOW;
 	art->init= clip_main_area_init;
 	art->draw= clip_main_area_draw;
-	art->keymapflag= ED_KEYMAP_FRAMES|ED_KEYMAP_UI;
+	art->listener= clip_main_area_listener;
+	art->keymapflag= ED_KEYMAP_FRAMES|ED_KEYMAP_UI|ED_KEYMAP_GPENCIL;
 
 	BLI_addhead(&st->regiontypes, art);
 
@@ -672,6 +706,7 @@
 	art->keymapflag= ED_KEYMAP_FRAMES|ED_KEYMAP_UI;
 	art->init= clip_properties_area_init;
 	art->draw= clip_properties_area_draw;
+	art->listener= clip_properties_area_listener;
 	BLI_addhead(&st->regiontypes, art);
 	ED_clip_buttons_register(art);
 

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-08-08 14:50:10 UTC (rev 39186)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/tracking_ops.c	2011-08-08 16:30:09 UTC (rev 39187)
@@ -617,7 +617,6 @@
 	ot->idname= "CLIP_OT_slide_marker";
 
 	/* api callbacks */
-	//ot->exec= slide_marker_exec;
 	ot->poll= space_clip_frame_poll;
 	ot->invoke= slide_marker_invoke;
 	ot->modal= slide_marker_modal;

Modified: branches/soc-2011-tomato/source/blender/makesdna/DNA_movieclip_types.h
===================================================================

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list