[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47710] trunk/blender/source/blender: Grease Pencil - Support for Grease Pencil in the Sequence Editor preview/ image

Joshua Leung aligorith at gmail.com
Mon Jun 11 02:21:58 CEST 2012


Revision: 47710
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47710
Author:   aligorith
Date:     2012-06-11 00:21:50 +0000 (Mon, 11 Jun 2012)
Log Message:
-----------
Grease Pencil - Support for Grease Pencil in the Sequence Editor preview/image
space works again

This commit restores the support for using Grease Pencil in the Sequence Editor
image preview region, making it possible to scribble on footage for review
purposes again. Due to internal changes in how the Sequencer handles the image
drawing for this stuff (i.e. it is now fully based on View2D instead of trying
to implement its own little crazy offset+zoom stuff), a lot of the old code for
handling those offsets is no longer needed. Instead, one of the "standard" cases
is now used, and works quite well.

Bugfixes:
* View-space Grease Pencil drawing was done in wrong place (before view2d
restore)
* Grease Pencil entry in RNA had wrong/missing type

Credits:
* DingTo - initial patch/attempt at restoring support
* Aligorith - solved the "offset problems"

Modified Paths:
--------------
    trunk/blender/source/blender/editors/gpencil/drawgpencil.c
    trunk/blender/source/blender/editors/gpencil/gpencil_edit.c
    trunk/blender/source/blender/editors/gpencil/gpencil_paint.c
    trunk/blender/source/blender/editors/include/ED_gpencil.h
    trunk/blender/source/blender/editors/space_sequencer/sequencer_buttons.c
    trunk/blender/source/blender/editors/space_sequencer/sequencer_draw.c
    trunk/blender/source/blender/editors/space_sequencer/sequencer_intern.h
    trunk/blender/source/blender/editors/space_sequencer/space_sequencer.c
    trunk/blender/source/blender/makesrna/intern/rna_space.c

Modified: trunk/blender/source/blender/editors/gpencil/drawgpencil.c
===================================================================
--- trunk/blender/source/blender/editors/gpencil/drawgpencil.c	2012-06-10 22:22:26 UTC (rev 47709)
+++ trunk/blender/source/blender/editors/gpencil/drawgpencil.c	2012-06-11 00:21:50 UTC (rev 47710)
@@ -37,10 +37,8 @@
 
 #include "BLO_sys_types.h"
 
-#include "IMB_imbuf_types.h"
-
-#include "BLI_math.h"
 #include "BLI_blenlib.h"
+#include "BLI_math.h"
 #include "BLI_utildefines.h"
 
 #include "DNA_gpencil_types.h"
@@ -53,8 +51,6 @@
 #include "BKE_global.h"
 #include "BKE_gpencil.h"
 
-
-
 #include "WM_api.h"
 
 #include "BIF_gl.h"
@@ -64,7 +60,6 @@
 #include "ED_sequencer.h"
 #include "ED_view3d.h"
 
-
 #include "gpencil_intern.h"
 
 /* ************************************************** */
@@ -225,7 +220,7 @@
 			
 			/* need to roll-back one point to ensure that there are no gaps in the stroke */
 			if (i != 0) glVertex3fv(&(pt - 1)->x);
-
+			
 			/* now the point we want... */
 			glVertex3fv(&pt->x);
 			
@@ -340,7 +335,7 @@
 				mt[1] = m2[1] * pthick * 0.5f;
 				sc[0] = s0[0] - (m1[0] * pthick * 0.75f);
 				sc[1] = s0[1] - (m1[1] * pthick * 0.75f);
-
+				
 				t0[0] = sc[0] - mt[0];
 				t0[1] = sc[1] - mt[1];
 				t1[0] = sc[0] + mt[0];
@@ -382,7 +377,7 @@
 				mt[1] = mb[1] * pthick;
 				athick = len_v2(mt);
 				dfac = pthick - (athick * 2);
-
+				
 				if (((athick * 2.0f) < pthick) && (IS_EQF(athick, pthick) == 0)) {
 					mt[0] += (mb[0] * dfac);
 					mt[1] += (mb[1] * dfac);
@@ -429,7 +424,7 @@
 				mt[1] = m2[1] * pthick * 0.5f;
 				sc[0] = s1[0] + (m1[0] * pthick * 0.75f);
 				sc[1] = s1[1] + (m1[1] * pthick * 0.75f);
-
+				
 				t0[0] = sc[0] - mt[0];
 				t0[1] = sc[1] - mt[1];
 				t1[0] = sc[0] + mt[0];
@@ -669,7 +664,7 @@
 // ............................
 
 /* draw grease-pencil sketches to specified 2d-view that uses ibuf corrections */
-void draw_gpencil_2dimage(bContext *C /* , ImBuf *ibuf */)
+void draw_gpencil_2dimage(bContext *C)
 {
 	ScrArea *sa = CTX_wm_area(C);
 	ARegion *ar = CTX_wm_region(C);
@@ -699,35 +694,20 @@
 			dflag |= GP_DRAWDATA_ONLYV2D | GP_DRAWDATA_IEDITHACK;
 		}
 		break;
-#if 0   /* removed since 2.5x, needs to be added back */
 		case SPACE_SEQ: /* sequence */
 		{
-			SpaceSeq *sseq = (SpaceSeq *)sa->spacedata.first;
-			float zoom, zoomx, zoomy;
-
-			/* check that we have grease-pencil stuff to draw */
-			if (ELEM(NULL, sa, ibuf)) return;
-
-			/* calculate accessory values */
-			zoom = (float)(SEQ_ZOOM_FAC(sseq->zoom));
-			if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
-				/* XXX sequencer zoom should store it? */
-				zoomx = zoom; //  * (G.scene->r.xasp / G.scene->r.yasp);
-				zoomy = zoom;
-			} 
-			else
-				zoomx = zoomy = zoom;
+			/* just draw using standard scaling (settings here are currently ignored anyways) */
+			offsx = 0;
+			offsy = 0;
+			sizex = ar->winx;
+			sizey = ar->winy;
 			
-			/* calculate transforms (Note: we use ibuf here, as we have it) */
-			sizex = (int)(zoomx * ibuf->x);
-			sizey = (int)(zoomy * ibuf->y);
-			offsx = (int)( (ar->winx - sizex) / 2 + sseq->xof);
-			offsy = (int)( (ar->winy - sizey) / 2 + sseq->yof);
-			
-			dflag |= GP_DRAWDATA_ONLYI2D;
+			/* NOTE: I2D was used in 2.4x, but the old settings for that have been deprecated 
+			 * and everything moved to standard View2d 
+			 */
+			dflag |= GP_DRAWDATA_ONLYV2D;
 		}
 		break;
-#endif
 		default: /* for spacetype not yet handled */
 			offsx = 0;
 			offsy = 0;

Modified: trunk/blender/source/blender/editors/gpencil/gpencil_edit.c
===================================================================
--- trunk/blender/source/blender/editors/gpencil/gpencil_edit.c	2012-06-10 22:22:26 UTC (rev 47709)
+++ trunk/blender/source/blender/editors/gpencil/gpencil_edit.c	2012-06-11 00:21:50 UTC (rev 47710)
@@ -80,6 +80,7 @@
 /* Get pointer to active Grease Pencil datablock, and an RNA-pointer to trace back to whatever owns it */
 bGPdata **gpencil_data_get_pointers(bContext *C, PointerRNA *ptr)
 {
+	ID *screen_id = (ID *)CTX_wm_screen(C);
 	Scene *scene = CTX_data_scene(C);
 	ScrArea *sa = CTX_wm_area(C);
 	
@@ -122,9 +123,12 @@
 				
 			case SPACE_SEQ: /* Sequencer */
 			{
-				//SpaceSeq *sseq= (SpaceSeq *)CTX_wm_space_data(C);
+				SpaceSeq *sseq = (SpaceSeq *)CTX_wm_space_data(C);
 				
-				/* return the GP data for the active strips/image/etc. */
+				/* for now, Grease Pencil data is associated with the space (actually preview region only) */
+				// XXX our convention for everything else is to link to data though...
+				if (ptr) RNA_pointer_create(screen_id, &RNA_SpaceSequenceEditor, sseq, ptr);
+				return &sseq->gpd;
 			}
 			break;
 				
@@ -134,7 +138,7 @@
 				
 				/* for now, Grease Pencil data is associated with the space... */
 				// XXX our convention for everything else is to link to data though...
-				if (ptr) RNA_pointer_create((ID *)CTX_wm_screen(C), &RNA_SpaceImageEditor, sima, ptr);
+				if (ptr) RNA_pointer_create(screen_id, &RNA_SpaceImageEditor, sima, ptr);
 				return &sima->gpd;
 			}
 			break;
@@ -143,7 +147,7 @@
 			{
 				SpaceClip *sc = (SpaceClip *)CTX_wm_space_data(C);
 				MovieClip *clip = ED_space_clip(sc);
-
+				
 				if (clip) {
 					if (sc->gpencil_src == SC_GPENCIL_SRC_TRACK) {
 						MovieTrackingTrack *track = BKE_tracking_active_track(&clip->tracking);
@@ -214,7 +218,7 @@
 	else {
 		/* decrement user count and add new datablock */
 		bGPdata *gpd = (*gpd_ptr);
-
+		
 		id_us_min(&gpd->id);
 		*gpd_ptr = gpencil_data_addnew("GPencil");
 	}
@@ -479,7 +483,7 @@
 
 	if (v3d) {
 		RegionView3D *rv3d = ar->regiondata;
-
+		
 		/* for camera view set the subrect */
 		if (rv3d->persp == RV3D_CAMOB) {
 			Scene *scene = CTX_data_scene(C);
@@ -523,26 +527,26 @@
 	/* add points */
 	for (i = 0, bezt = nu->bezt; i < tot; i++, pt++, bezt++) {
 		float h1[3], h2[3];
-
+		
 		if (i) interp_v3_v3v3(h1, p3d_cur, p3d_prev, 0.3);
 		else interp_v3_v3v3(h1, p3d_cur, p3d_next, -0.3);
-
+		
 		if (i < tot - 1) interp_v3_v3v3(h2, p3d_cur, p3d_next, 0.3);
 		else interp_v3_v3v3(h2, p3d_cur, p3d_prev, -0.3);
-
+		
 		copy_v3_v3(bezt->vec[0], h1);
 		copy_v3_v3(bezt->vec[1], p3d_cur);
 		copy_v3_v3(bezt->vec[2], h2);
-
+		
 		/* set settings */
 		bezt->h1 = bezt->h2 = HD_FREE;
 		bezt->f1 = bezt->f2 = bezt->f3 = SELECT;
 		bezt->radius = bezt->weight = pt->pressure * gpl->thickness * 0.1f;
-
+		
 		/* shift coord vects */
 		copy_v3_v3(p3d_prev, p3d_cur);
 		copy_v3_v3(p3d_cur, p3d_next);
-
+		
 		if (i + 2 < tot) {
 			gp_strokepoint_convertcoords(C, gps, pt + 2, p3d_next, subrect);
 		}

Modified: trunk/blender/source/blender/editors/gpencil/gpencil_paint.c
===================================================================
--- trunk/blender/source/blender/editors/gpencil/gpencil_paint.c	2012-06-10 22:22:26 UTC (rev 47709)
+++ trunk/blender/source/blender/editors/gpencil/gpencil_paint.c	2012-06-11 00:21:50 UTC (rev 47710)
@@ -79,15 +79,6 @@
 	rctf *subrect;      /* for using the camera rect within the 3d view */
 	rctf subrect_data;
 	
-	
-#if 0 // XXX review this 2d image stuff...
-	ImBuf *ibuf;        /* needed for GP_STROKE_2DIMAGE */
-	struct IBufViewSettings {
-		int offsx, offsy;           /* offsets */
-		int sizex, sizey;           /* dimensions to use as scale-factor */
-	} im2d_settings;    /* needed for GP_STROKE_2DIMAGE */
-#endif
-	
 	PointerRNA ownerPtr; /* pointer to owner of gp-datablock */
 	bGPdata *gpd;       /* gp-datablock layer comes from */
 	bGPDlayer *gpl;     /* layer we're working on */
@@ -269,7 +260,7 @@
 			int mval_prj[2];
 			float rvec[3], dvec[3];
 			float mval_f[2];
-
+			
 			/* Current method just converts each point in screen-coordinates to
 			 * 3D-coordinates using the 3D-cursor as reference. In general, this
 			 * works OK, but it could of course be improved.
@@ -283,7 +274,7 @@
 			
 			/* method taken from editview.c - mouse_cursor() */
 			project_int_noclip(p->ar, rvec, mval_prj);
-
+			
 			VECSUB2D(mval_f, mval_prj, mval);
 			ED_view3d_win_to_delta(p->ar, mval_f, dvec);
 			sub_v3_v3v3(out, rvec, dvec);
@@ -296,25 +287,6 @@
 		mul_v3_m4v3(out, p->imat, out);
 	}
 	
-#if 0
-	/* 2d - on image 'canvas' (assume that p->v2d is set) */
-	else if (gpd->sbuffer_sflag & GP_STROKE_2DIMAGE) {
-		int sizex, sizey, offsx, offsy;
-		
-		/* get stored settings 
-		 *	- assume that these have been set already (there are checks that set sane 'defaults' just in case)
-		 */
-		sizex = p->im2d_settings.sizex;
-		sizey = p->im2d_settings.sizey;
-		offsx = p->im2d_settings.offsx;
-		offsy = p->im2d_settings.offsy;
-		
-		/* calculate new points */
-		out[0] = (float)(mval[0] - offsx) / (float)sizex;
-		out[1] = (float)(mval[1] - offsy) / (float)sizey;
-	}
-#endif
-	
 	/* 2d - relative to screen (viewport area) */
 	else {
 		if (p->subrect == NULL) { /* normal 3D view */
@@ -393,11 +365,11 @@
 	else if (p->paintmode == GP_PAINTMODE_DRAW_POLY) {
 		/* get pointer to destination point */
 		pt = (tGPspoint *)(gpd->sbuffer);
-
+		
 		/* store settings */
 		copy_v2_v2_int(&pt->x, mval);
 		pt->pressure = pressure;
-
+		
 		/* if there's stroke for this poly line session add (or replace last) point
 		 * to stroke. This allows to draw lines more interactively (see new segment
 		 * during mouse slide, i.e.) 
@@ -405,36 +377,36 @@
 		if (gp_stroke_added_check(p)) {
 			bGPDstroke *gps = p->gpf->strokes.last;
 			bGPDspoint *pts;
-
+			
 			/* first time point is adding to temporary buffer -- need to allocate new point in stroke */
 			if (gpd->sbuffer_size == 0) {
 				gps->points = MEM_reallocN(gps->points, sizeof(bGPDspoint) * (gps->totpoints + 1));
 				gps->totpoints++;
 			}
-
+			
 			pts = &gps->points[gps->totpoints - 1];
-
+			
 			/* special case for poly lines: normally, depth is needed only when creating new stroke from buffer,
 			 * but poly lines are converting to stroke instantly, so initialize depth buffer before converting coordinates 
 			 */
 			if (gpencil_project_check(p)) {
 				View3D *v3d = p->sa->spacedata.first;
-
+				
 				view3d_region_operator_needs_opengl(p->win, p->ar);
 				ED_view3d_autodist_init(p->scene, p->ar, v3d, (p->gpd->flag & GP_DATA_DEPTH_STROKE) ? 1 : 0);
 			}
-
+			
 			/* convert screen-coordinates to appropriate coordinates (and store them) */
 			gp_stroke_convertcoords(p, &pt->x, &pts->x, NULL);
-
+			
 			/* copy pressure */
 			pts->pressure = pt->pressure;
 		}
-
+		
 		/* increment counters */
 		if (gpd->sbuffer_size == 0)
 			gpd->sbuffer_size++;
-
+		
 		return GP_STROKEADD_NORMAL;
 	}

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list