[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34378] trunk/blender/source/blender/ editors: Bugfix [#25684b] Surface and Stroke options are not working with Use

Joshua Leung aligorith at gmail.com
Tue Jan 18 02:04:15 CET 2011


Revision: 34378
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=34378
Author:   aligorith
Date:     2011-01-18 01:04:14 +0000 (Tue, 18 Jan 2011)
Log Message:
-----------
Bugfix [#25684b] Surface and Stroke options are not working with Use
Sketching Sessions.

Fix for secondary issue noted in this bug report. Some of the code for
the fancy 3d view sketching options needed to be moved around so that
there is a clearer "paint/sketch session" and "stroke" separation
between various stages. There's still some more stuff that needs to be
done here before I think it's totally cleaned up.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/gpencil/gpencil_paint.c
    trunk/blender/source/blender/editors/include/ED_view3d.h
    trunk/blender/source/blender/editors/space_view3d/view3d_view.c

Modified: trunk/blender/source/blender/editors/gpencil/gpencil_paint.c
===================================================================
--- trunk/blender/source/blender/editors/gpencil/gpencil_paint.c	2011-01-18 00:10:11 UTC (rev 34377)
+++ trunk/blender/source/blender/editors/gpencil/gpencil_paint.c	2011-01-18 01:04:14 UTC (rev 34378)
@@ -45,6 +45,7 @@
 #include "DNA_object_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_gpencil_types.h"
+#include "DNA_windowmanager_types.h"
 
 #include "UI_view2d.h"
 
@@ -66,6 +67,8 @@
 /* Temporary 'Stroke' Operation data */
 typedef struct tGPsdata {
 	Scene *scene;       /* current scene from context */
+	
+	wmWindow *win;		/* window where painting originated */
 	ScrArea *sa;		/* area where painting originated */
 	ARegion *ar;        /* region where painting originated */
 	View2D *v2d;		/* needed for GP_STROKE_2DSPACE */
@@ -888,8 +891,9 @@
 	/* create new context data */
 	p= MEM_callocN(sizeof(tGPsdata), "GPencil Drawing Data");
 	
-	/* pass on current scene */
+	/* pass on current scene and window */
 	p->scene= CTX_data_scene(C);
+	p->win= CTX_wm_window(C);
 	
 	switch (curarea->spacetype) {
 		/* supported views first */
@@ -910,12 +914,6 @@
 					printf("Error: 3D-View active region doesn't have any region data, so cannot be drawable \n");
 				return p;
 			}
-			
-			/* for camera view set the subrect */
-			if(rv3d->persp == RV3D_CAMOB) {
-				view3d_calc_camera_border(p->scene, p->ar, NULL, v3d, &p->subrect_data, -1); /* negative shift */
-				p->subrect= &p->subrect_data;
-			}
 
 #if 0 // XXX will this sort of antiquated stuff be restored?
 			/* check that gpencil data is allowed to be drawn */
@@ -1097,9 +1095,17 @@
 		switch (p->sa->spacetype) {
 			case SPACE_VIEW3D:
 			{
+				View3D *v3d= p->sa->spacedata.first;
 				RegionView3D *rv3d= p->ar->regiondata;
 				float rvec[3];
 				
+				/* for camera view set the subrect */
+				if (rv3d->persp == RV3D_CAMOB) {
+					view3d_calc_camera_border(p->scene, p->ar, NULL, v3d, &p->subrect_data, -1); /* negative shift */
+					p->subrect= &p->subrect_data;
+				}
+				
+				/* get reference point for 3d space placement */
 				gp_get_3d_reference(p, rvec);
 				initgrabz(rv3d, rvec[0], rvec[1], rvec[2]);
 				
@@ -1172,6 +1178,17 @@
 /* finish off a stroke (clears buffer, but doesn't finish the paint operation) */
 static void gp_paint_strokeend (tGPsdata *p)
 {
+	/* for surface sketching, need to set the right OpenGL context stuff so that 
+	 * the conversions will project the values correctly...
+	 */
+	if (gpencil_project_check(p)) {
+		View3D *v3d= p->sa->spacedata.first;
+		
+		/* need to restore the original projection settings before packing up */
+		view3d_region_operator_needs_opengl(p->win, p->ar);
+		view_autodist_init(p->scene, p->ar, v3d, (p->gpd->flag & GP_DATA_DEPTH_STROKE) ? 1:0);
+	}
+	
 	/* check if doing eraser or not */
 	if ((p->gpd->sbuffer_sflag & GP_STROKE_ERASER) == 0) {
 		/* smooth stroke before transferring? */
@@ -1247,14 +1264,6 @@
 	}
 	
 	/* cleanup */
-	if (gpencil_project_check(p)) {
-		View3D *v3d= p->sa->spacedata.first;
-		
-		/* need to restore the original projection settings before packing up */
-		view3d_operator_needs_opengl(C);
-		view_autodist_init(p->scene, p->ar, v3d, (p->gpd->flag & GP_DATA_DEPTH_STROKE) ? 1:0);
-	}
-
 	gp_paint_cleanup(p);
 	gp_session_cleanup(p);
 	
@@ -1573,7 +1582,7 @@
 			if (GPENCIL_SKETCH_SESSIONS_ON(p->scene)) {
 				/* end stroke only, and then wait to resume painting soon */
 				//printf("\t\tGP - end stroke only\n");
-				gp_paint_strokeend(p);
+				gp_paint_cleanup(p);
 				p->status= GP_STATUS_IDLING;
 				
 				/* we've just entered idling state, so this event was processed (but no others yet) */

Modified: trunk/blender/source/blender/editors/include/ED_view3d.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_view3d.h	2011-01-18 00:10:11 UTC (rev 34377)
+++ trunk/blender/source/blender/editors/include/ED_view3d.h	2011-01-18 01:04:14 UTC (rev 34378)
@@ -47,6 +47,7 @@
 struct Scene;
 struct View3D;
 struct ViewContext;
+struct wmWindow;
 
 
 /* for derivedmesh drawing callbacks, for view3d_select, .... */
@@ -144,6 +145,7 @@
 
 void view3d_set_viewcontext(struct bContext *C, struct ViewContext *vc);
 void view3d_operator_needs_opengl(const struct bContext *C);
+void view3d_region_operator_needs_opengl(struct wmWindow *win, struct ARegion *ar);
 void view3d_get_view_aligned_coordinate(struct ViewContext *vc, float *fp, short mval[2]);
 void view3d_get_transformation(struct ARegion *ar, struct RegionView3D *rv3d, struct Object *ob, struct bglMats *mats);
 

Modified: trunk/blender/source/blender/editors/space_view3d/view3d_view.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_view.c	2011-01-18 00:10:11 UTC (rev 34377)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_view.c	2011-01-18 01:04:14 UTC (rev 34378)
@@ -69,15 +69,21 @@
    opengl drawing context */
 void view3d_operator_needs_opengl(const bContext *C)
 {
+	wmWindow *win = CTX_wm_window(C);
 	ARegion *ar= CTX_wm_region(C);
+	
+	view3d_region_operator_needs_opengl(win, ar);
+}
 
+void view3d_region_operator_needs_opengl(wmWindow *win, ARegion *ar)
+{
 	/* for debugging purpose, context should always be OK */
-	if(ar->regiontype!=RGN_TYPE_WINDOW)
-		printf("view3d_operator_needs_opengl error, wrong region\n");
+	if ((ar == NULL) || (ar->regiontype!=RGN_TYPE_WINDOW))
+		printf("view3d_region_operator_needs_opengl error, wrong region\n");
 	else {
 		RegionView3D *rv3d= ar->regiondata;
 		
-		wmSubWindowSet(CTX_wm_window(C), ar->swinid);
+		wmSubWindowSet(win, ar->swinid);
 		glMatrixMode(GL_PROJECTION);
 		glLoadMatrixf(rv3d->winmat);
 		glMatrixMode(GL_MODELVIEW);




More information about the Bf-blender-cvs mailing list