[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22889] branches/blender2.5/blender/source /blender: Grease Pencil: Various Drawing Fixes

Joshua Leung aligorith at gmail.com
Sun Aug 30 13:37:29 CEST 2009


Revision: 22889
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22889
Author:   aligorith
Date:     2009-08-30 13:37:29 +0200 (Sun, 30 Aug 2009)

Log Message:
-----------
Grease Pencil: Various Drawing Fixes 

* Restored option to have strokes aligned to screen space. By default, this is not enabled (the setting for view-space is the default instead). 

* Fixed bugs related to drawing/erasing in screen space.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenkernel/intern/gpencil.c
    branches/blender2.5/blender/source/blender/editors/gpencil/drawgpencil.c
    branches/blender2.5/blender/source/blender/editors/gpencil/gpencil_buttons.c
    branches/blender2.5/blender/source/blender/editors/gpencil/gpencil_paint.c
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_gpencil.c

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/gpencil.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/gpencil.c	2009-08-30 09:11:24 UTC (rev 22888)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/gpencil.c	2009-08-30 11:37:29 UTC (rev 22889)
@@ -214,6 +214,11 @@
 	/* initial settings */
 	gpd->flag = (GP_DATA_DISPINFO|GP_DATA_EXPAND);
 	
+	/* for now, stick to view is also enabled by default
+	 * since this is more useful...
+	 */
+	gpd->flag |= GP_DATA_VIEWALIGN;
+	
 	return gpd;
 }
 

Modified: branches/blender2.5/blender/source/blender/editors/gpencil/drawgpencil.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/gpencil/drawgpencil.c	2009-08-30 09:11:24 UTC (rev 22888)
+++ branches/blender2.5/blender/source/blender/editors/gpencil/drawgpencil.c	2009-08-30 11:37:29 UTC (rev 22889)
@@ -773,7 +773,7 @@
 	
 	/* pass 2: draw 2d-strokes ------------ > */
 		/* adjust view matrices */
-	wmOrtho2(-0.375f, (float)(ar->winx)-0.375f, -0.375f, (float)(ar->winy)-0.375f);
+	wmOrtho2(-0.375f, (float)(ar->winx)-0.375f, -0.375f, (float)(ar->winy)-0.375f); // XXX may not be correct anymore
 	glLoadIdentity();
 	
 		/* draw it! */

Modified: branches/blender2.5/blender/source/blender/editors/gpencil/gpencil_buttons.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/gpencil/gpencil_buttons.c	2009-08-30 09:11:24 UTC (rev 22888)
+++ branches/blender2.5/blender/source/blender/editors/gpencil/gpencil_buttons.c	2009-08-30 11:37:29 UTC (rev 22889)
@@ -226,9 +226,13 @@
 /* Draw the contents for a grease-pencil panel*/
 static void draw_gpencil_panel (bContext *C, uiLayout *layout, bGPdata *gpd, PointerRNA *ctx_ptr)
 {
+	PointerRNA gpd_ptr;
 	bGPDlayer *gpl;
 	uiLayout *col;
 	
+	/* make new PointerRNA for Grease Pencil block */
+	RNA_id_pointer_create((ID *)gpd, &gpd_ptr);
+	
 	/* draw gpd settings first ------------------------------------- */
 	col= uiLayoutColumn(layout, 0);
 		/* current Grease Pencil block */
@@ -238,19 +242,19 @@
 		/* add new layer button */
 		uiItemO(col, NULL, 0, "GPENCIL_OT_layer_add");
 	
-	/* 'view align' button (naming depends on context) */
-#if 0 // XXX for now, this is enabled by default anyways
-	if (sa->spacetype == SPACE_VIEW3D)
-		uiDefButBitI(block, TOG, GP_DATA_VIEWALIGN, B_REDR, "Sketch in 3D", 170, 205, 150, 20, &gpd->flag, 0, 0, 0, 0, "New strokes are added in 3D-space");
-	else
-		uiDefButBitI(block, TOG, GP_DATA_VIEWALIGN, B_REDR, "Stick to View", 170, 205, 150, 20, &gpd->flag, 0, 0, 0, 0, "New strokes are added on 2d-canvas");
-#endif
-	
 	/* draw each layer --------------------------------------------- */
 	for (gpl= gpd->layers.first; gpl; gpl= gpl->next) {
 		col= uiLayoutColumn(layout, 1);
 			gp_drawui_layer(col, gpd, gpl);
 	}
+	
+	/* draw gpd drawing settings first ------------------------------------- */
+	col= uiLayoutColumn(layout, 0);
+		/* label */
+		uiItemL(col, "Drawing Settings:", 0);
+		
+		/* 'stick to view' option */
+		uiItemR(col, NULL, 0, &gpd_ptr, "view_space_draw", 0);
 }	
 
 

Modified: branches/blender2.5/blender/source/blender/editors/gpencil/gpencil_paint.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/gpencil/gpencil_paint.c	2009-08-30 09:11:24 UTC (rev 22888)
+++ branches/blender2.5/blender/source/blender/editors/gpencil/gpencil_paint.c	2009-08-30 11:37:29 UTC (rev 22889)
@@ -239,8 +239,8 @@
 	
 	/* 2d - relative to screen (viewport area) */
 	else {
-		out[0] = (float)(mval[0]) / (float)(p->sa->winx) * 100;
-		out[1] = (float)(mval[1]) / (float)(p->sa->winy) * 100;
+		out[0] = (float)(mval[0]) / (float)(p->ar->winx) * 100;
+		out[1] = (float)(mval[1]) / (float)(p->ar->winy) * 100;
 	}
 }
 
@@ -310,8 +310,8 @@
 			return GP_STROKEADD_NORMAL;
 	}
 	
-	/* just say it's normal for now, since we don't have another state... */
-	return GP_STROKEADD_NORMAL;
+	/* return invalid state for now... */
+	return GP_STROKEADD_INVALID;
 }
 
 /* smooth a stroke (in buffer) before storing it */
@@ -614,8 +614,8 @@
 		}
 #endif
 		else {
-			x0= (int)(gps->points->x / 100 * p->sa->winx);
-			y0= (int)(gps->points->y / 100 * p->sa->winy);
+			x0= (int)(gps->points->x / 100 * p->ar->winx);
+			y0= (int)(gps->points->y / 100 * p->ar->winy);
 		}
 		
 		/* do boundbox check first */
@@ -671,10 +671,10 @@
 			}
 #endif
 			else {
-				x0= (int)(pt1->x / 100 * p->sa->winx);
-				y0= (int)(pt1->y / 100 * p->sa->winy);
-				x1= (int)(pt2->x / 100 * p->sa->winx);
-				y1= (int)(pt2->y / 100 * p->sa->winy);
+				x0= (int)(pt1->x / 100 * p->ar->winx);
+				y0= (int)(pt1->y / 100 * p->ar->winy);
+				x1= (int)(pt2->x / 100 * p->ar->winx);
+				y1= (int)(pt2->y / 100 * p->ar->winy);
 			}
 			
 			/* check that point segment of the boundbox of the eraser stroke */
@@ -944,15 +944,15 @@
 		p->gpd->sbuffer_sflag |= GP_STROKE_ERASER;
 	
 	/* check if points will need to be made in view-aligned space */
-	// XXX this should be the default? this is something that needs review
-	/*if (p->gpd->flag & GP_DATA_VIEWALIGN)*/ {
+	if (p->gpd->flag & GP_DATA_VIEWALIGN) {
 		switch (p->sa->spacetype) {
 			case SPACE_VIEW3D:
 			{
 				View3D *v3d= (View3D *)p->sa->spacedata.first;
 				RegionView3D *rv3d= p->ar->regiondata;
 				
-				// TODO: this should only happen for scene... otherwise apply correction for object center!
+				// TODO 1: when using objects, make the data stick to the object centers?
+				// TODO 2: what happens when cursor is behind view-camera plane?
 				float *fp= give_cursor(p->scene, v3d);
 				initgrabz(rv3d, fp[0], fp[1], fp[2]);
 				
@@ -1139,7 +1139,7 @@
 			
 			if (G.f & G_DEBUG) 
 				printf("Error: Grease-Pencil Paint - Add Point Invalid \n");
-			// XXX break!
+			return;
 		}
 		
 		/* store used values */

Modified: branches/blender2.5/blender/source/blender/makesrna/intern/rna_gpencil.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_gpencil.c	2009-08-30 09:11:24 UTC (rev 22888)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_gpencil.c	2009-08-30 11:37:29 UTC (rev 22889)
@@ -208,6 +208,7 @@
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_SELECT);
 	RNA_def_property_ui_text(prop, "Selected", "Layer is selected for editing in the DopeSheet.");
 	
+		// XXX keep this option?
 	prop= RNA_def_property(srna, "show_points", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_DRAWDEBUG);
 	RNA_def_property_ui_text(prop, "Show Points", "Draw the points which make up the strokes (for debugging purposes).");
@@ -229,6 +230,11 @@
 	RNA_def_property_collection_sdna(prop, NULL, "layers", NULL);
 	RNA_def_property_struct_type(prop, "GPencilLayer");
 	RNA_def_property_ui_text(prop, "Layers", "Similar to layers in Photoshop.");
+	
+	/* Flags */
+	prop= RNA_def_property(srna, "view_space_draw", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_VIEWALIGN);
+	RNA_def_property_ui_text(prop, "Stick to View", "Newly drawn strokes get added in view space (i.e. sketches stick to data when view is manipulated).");
 }
 
 /* --- */





More information about the Bf-blender-cvs mailing list