[Bf-committers] [Patch] Draw object in BoundBox when transform

LECOCQ Guillaume lecocqguillaume at gmail.com
Wed Mar 30 15:21:32 CEST 2005


Hello, I make a patch for a french user who wants to works with his
big scene without wit for the redraw.

He has some object with some vertice, if he moves an object, turn the
view, ... Blender redraw slowly all times.
The idea : when moves, rotates, turns view, ... all objects in the
current area is drawn in BoundBox and after make the change, all
objects return to there drawtype state.

I make a toggle button in "view & control" (in the info area) to
choose between normal or boundbox mode. I think after I will make a
slider to choose the limit of vertices for draw the boundbox.

Patch :

Index: source/blender/makesdna/DNA_userdef_types.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/makesdna/DNA_userdef_types.h,v
retrieving revision 1.36
diff -u -r1.36 DNA_userdef_types.h
--- source/blender/makesdna/DNA_userdef_types.h	21 Mar 2005 14:20:04 -0000	1.36
+++ source/blender/makesdna/DNA_userdef_types.h	30 Mar 2005 12:20:12 -0000
@@ -174,6 +174,7 @@
 #define USER_TWOBUTTONMOUSE		4096
 #define USER_NONUMPAD			8192
 #define USER_LMOUSESELECT		16384
+#define USER_DRAWTYPE                                          32768
 
 /* viewzom */
 #define USER_ZOOM_CONT			0
Index: source/blender/src/space.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/space.c,v
retrieving revision 1.242
diff -u -r1.242 space.c
--- source/blender/src/space.c	28 Mar 2005 14:00:49 -0000	1.242
+++ source/blender/src/space.c	30 Mar 2005 12:20:12 -0000
@@ -2452,6 +2452,19 @@
 			&(U.flag), 0, 0, 0, 0,
 			"Emulates Middle Mouse with Alt+LeftMouse (doesnt work with Left
Mouse Select option)");
 		
+		uiDefBut(block, LABEL,0,"View when transform",
+			(xpos+(2*edgsp)+(3*mpref)+(3*midsp)),y2label+5,mpref,buth,
+			0, 0, 0, 0, 0, "");
+
+		uiBlockBeginAlign(block);
+		uiDefButBitS(block, TOGN, USER_DRAWTYPE, B_DRAWINFO, "Normal",
+			(xpos+edgsp+(3*mpref)+(4*midsp)),y1,(mpref/2),buth,
+			&(U.flag), 0, 0, 0, 0, "Don't change the drawtype in transformation");
+		uiDefButBitS(block, TOG, USER_DRAWTYPE, B_DRAWINFO, "BoundBox",
+			(xpos+edgsp+(3*mpref)+(4*midsp)+(mpref/2)),y1,(mpref/2),buth,
+			&(U.flag), 0, 0, 0, 0, "Make drawtype=BOUND_BOX when transform
			(without widgets)");
+		
+		uiBlockEndAlign(block);
 			
 		uiDefBut(block, LABEL,0,"Middle Mouse Button:",
 			(xpos+(2*edgsp)+(4*mpref)+(4*midsp)),y6label,mpref,buth,
Index: source/blender/src/transform.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/transform.c,v
retrieving revision 1.66
diff -u -r1.66 transform.c
--- source/blender/src/transform.c	29 Mar 2005 17:05:43 -0000	1.66
+++ source/blender/src/transform.c	30 Mar 2005 12:22:07 -0000
@@ -1420,11 +1420,17 @@
 void Transform(int mode, int context) 
 {
 	int ret_val = 0;
-	short pmval[2] = {0, 0}, mval[2], val, oldprop;
+	short pmval[2] = {0, 0}, mval[2], val, oldprop,savedrawtype;
 	float mati[3][3];
 	unsigned short event;
 	char cmode = '\0';
 
+	if ((G.vd->drawtype!=OB_BOUNDBOX) && (U.flag & USER_DRAWTYPE)){
+		savedrawtype=G.vd->drawtype;
+		G.vd->drawtype=OB_BOUNDBOX;
+	}
+
+
 	/* STUPID HACK, but this needs fixing right now */
 	if (G.f & G_PROPORTIONAL)
 		oldprop = 1;
@@ -1754,6 +1760,7 @@
 
 	
 	/* send events out for redraws */
+	if (U.flag & USER_DRAWTYPE) G.vd->drawtype=savedrawtype;
 	allqueue(REDRAWVIEW3D, 0);
 	allqueue(REDRAWBUTSOBJECT, 0);
 	scrarea_queue_headredraw(curarea);
@@ -1762,10 +1769,13 @@
 void ManipulatorTransform(int mode) 
 {
 	int ret_val = 0;
-	short pmval[2] = {0, 0}, mval[2], val;
+	short pmval[2] = {0, 0}, mval[2], val,savedrawtype;
 	unsigned short event;
 
-
+	if ((G.vd->drawtype!=OB_BOUNDBOX) && (U.flag & USER_DRAWTYPE)){
+		savedrawtype=G.vd->drawtype;
+		G.vd->drawtype=OB_BOUNDBOX;
+	}
 	/* stupid PET initialisation code */
 	/* START */
 	if (Trans.propsize == 0.0f) {
@@ -1911,6 +1921,7 @@
 	}
 	
 	/* send events out for redraws */
+	if (U.flag & USER_DRAWTYPE) G.vd->drawtype=savedrawtype;
 	allqueue(REDRAWVIEW3D, 0);
 	allqueue(REDRAWBUTSOBJECT, 0);
 	scrarea_queue_headredraw(curarea);
Index: source/blender/src/view.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/view.c,v
retrieving revision 1.41
diff -u -r1.41 view.c
--- source/blender/src/view.c	19 Mar 2005 21:08:13 -0000	1.41
+++ source/blender/src/view.c	30 Mar 2005 12:20:12 -0000
@@ -410,7 +410,7 @@
 	float firstvec[3], newvec[3], dvec[3];
 	float oldquat[4], q1[4], si, phi, dist0;
 	int firsttime=1;
-	short mvalball[2], mval[2], mvalo[2];
+	short mvalball[2], mval[2], mvalo[2],savedrawtype;
 	
 	/* sometimes this routine is called from headerbuttons */
 	areawinset(curarea->win);
@@ -427,7 +427,10 @@
 	calctrackballvec(&curarea->winrct, mvalo, firstvec);
 
 	/* cumultime(0); */
-
+	if ((G.vd->drawtype!=OB_BOUNDBOX)&&(U.flag&USER_DRAWTYPE)){
+		savedrawtype=G.vd->drawtype;
+		G.vd->drawtype=OB_BOUNDBOX;
+	}
 	while(TRUE) {
 		getmouseco_sc(mval);
 		
@@ -582,6 +585,12 @@
 		/* this in the end, otherwise get_mbut does not work on a PC... */
 		if( !(get_mbut() & (L_MOUSE|M_MOUSE))) break;
 	}
+	if (U.flag & USER_DRAWTYPE){
+		G.vd->drawtype=savedrawtype;
+		scrarea_do_windraw(curarea);
+		screen_swapbuffers();
+	}
+
 }
 
 short v3d_windowmode=0;


More information about the Bf-committers mailing list