[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12447] trunk/blender/source/blender: * Two usability tweaks in adding objects, with user prefs

Matt Ebb matt at mke3.net
Wed Oct 31 22:55:06 CET 2007


Revision: 12447
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12447
Author:   broken
Date:     2007-10-31 22:55:06 +0100 (Wed, 31 Oct 2007)

Log Message:
-----------
* Two usability tweaks in adding objects, with user prefs

This changes the default behaviour in adding new objects, which has been
discussed for a long time, in person, on the funboard, and in the tracker,
and was agreed to be implemented during the 2.5 release cycle, so here it is.
They have been made default, with preferences to bring back old behaviour since 
although people like myself still prefer the new default anyway, it will benefit 
new users the most. 

The preferences are in the 'Edit Methods' section, changing back to old behaviour
is as simple as a click of a button.

- Switch to edit mode preference 

By default, now adding a new object doesn't automatically switch to edit mode.
Not only can this be annoying (most of the time when setting up scenes and models
I don't want to edit it straight away anyway), but it's a major hurdle in the learning
curve that new users have had to deal with at a very early stage.

Blender's different modes are an important part of understanding how the software works
and should have clear behaviour. The problem is that when a user selects something from
the add menu, he's not telling Blender to change modes, he wants to add an object.
But Blender then goes ahead and changes modes underneath him anyway, something that was 
never explicitly asked for, something that's unrelated to the mental task at hand, and 
fundamentally important to the operation of the software.

We observed plenty of people struggling with this during the training sessions that 
we ran during Project Orange, and there's also no shortage of "why can't I select 
other objects" questions on the forums.

- Aligned to View preference

Now by default, adding a new object doesn't rotate it so it's aligned facing the view, 
but rather, it's remains unrotated in world space. This is something that's more of 
a convenience issue (allowing people like me to stop the 'Add->Tab->Alt R dance), 
but also makes things easier for new users, especially when doing things like rigging.

For a lot of tools in Blender, like curve deform, path cycling, constraints, it's necessary
for your objects' local axes to be aligned. This requirement isn't that obvious, and I've 
had to debug rigs a few times from the animator in our studio, who has everything set up
correctly, but he just happened to be in a different vie at the time he added the object,
so they're misaligned and causing problems. Having all objects get created aligned to
worldspace, by default, makes a lot of these problems go away. It's much more understandable
when rotations are caused by something you've done explicitly, rather than as a side effect
of the software.

For convenience as well, most of the time, when I'm working in context and I decide I need a new object, 
particularly working on production scenes that involve more than just one model, an Alt R 
is almost always required after adding, since I don't want to have to disrupt the current 
view of the scene by switching to top view, just to add an object. It's a bit arbitrary, 
the view from which you want to look at your objects isn't usually the way you want them to
be looking at you.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/object.c
    trunk/blender/source/blender/makesdna/DNA_userdef_types.h
    trunk/blender/source/blender/src/editarmature.c
    trunk/blender/source/blender/src/editcurve.c
    trunk/blender/source/blender/src/editmesh_add.c
    trunk/blender/source/blender/src/space.c

Modified: trunk/blender/source/blender/blenkernel/intern/object.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/object.c	2007-10-31 20:56:50 UTC (rev 12446)
+++ trunk/blender/source/blender/blenkernel/intern/object.c	2007-10-31 21:55:06 UTC (rev 12447)
@@ -916,13 +916,15 @@
 		VECCOPY(ob->loc, G.scene->cursor);
 	}
 
-	v3d->viewquat[0]= -v3d->viewquat[0];
-	if (ob->transflag & OB_QUAT) {
-		QUATCOPY(ob->quat, v3d->viewquat);
-	} else {
-		QuatToEul(v3d->viewquat, ob->rot);
+	if (U.flag & USER_ADD_VIEWALIGNED) {
+		v3d->viewquat[0]= -v3d->viewquat[0];
+		if (ob->transflag & OB_QUAT) {
+			QUATCOPY(ob->quat, v3d->viewquat);
+		} else {
+			QuatToEul(v3d->viewquat, ob->rot);
+		}
+		v3d->viewquat[0]= -v3d->viewquat[0];
 	}
-	v3d->viewquat[0]= -v3d->viewquat[0];
 }
 
 SoftBody *copy_softbody(SoftBody *sb)

Modified: trunk/blender/source/blender/makesdna/DNA_userdef_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_userdef_types.h	2007-10-31 20:56:50 UTC (rev 12446)
+++ trunk/blender/source/blender/makesdna/DNA_userdef_types.h	2007-10-31 21:55:06 UTC (rev 12447)
@@ -212,7 +212,10 @@
 #define USER_FILECOMPRESS		(1 << 15)
 #define USER_SAVE_PREVIEWS		(1 << 16)
 #define USER_CUSTOM_RANGE		(1 << 17)
+#define USER_ADD_EDITMODE		(1 << 18)
+#define USER_ADD_VIEWALIGNED	(1 << 19)
 
+
 /* viewzom */
 #define USER_ZOOM_CONT			0
 #define USER_ZOOM_SCALE			1

Modified: trunk/blender/source/blender/src/editarmature.c
===================================================================
--- trunk/blender/source/blender/src/editarmature.c	2007-10-31 20:56:50 UTC (rev 12446)
+++ trunk/blender/source/blender/src/editarmature.c	2007-10-31 21:55:06 UTC (rev 12447)
@@ -55,6 +55,7 @@
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_space_types.h"
+#include "DNA_userdef_types.h"
 #include "DNA_view3d_types.h"
 #include "DNA_modifier_types.h"
 
@@ -1485,7 +1486,7 @@
 	return bone;
 }
 
-static void add_primitive_bone(Object *ob)
+static void add_primitive_bone(Object *ob, short newob)
 {
 	float		obmat[3][3], curs[3], viewmat[3][3], totmat[3][3], imat[3][3];
 	EditBone	*bone;
@@ -1496,7 +1497,9 @@
 	Mat4Invert(G.obedit->imat, G.obedit->obmat);
 	Mat4MulVecfl(G.obedit->imat, curs);
 
-	Mat3CpyMat4(obmat, G.vd->viewmat);
+	if ( !(newob) || U.flag & USER_ADD_VIEWALIGNED) Mat3CpyMat4(obmat, G.vd->viewmat);
+	else Mat3One(obmat);
+	
 	Mat3CpyMat4(viewmat, G.obedit->obmat);
 	Mat3MulMat3(totmat, obmat, viewmat);
 	Mat3Inv(imat, totmat);
@@ -1507,12 +1510,18 @@
 	bone= add_editbone("Bone");
 
 	VECCOPY(bone->head, curs);
-	VecAddf(bone->tail, bone->head, imat[1]);	// bone with unit length 1
 	
+	if ( !(newob) || U.flag & USER_ADD_VIEWALIGNED)
+		VecAddf(bone->tail, bone->head, imat[1]);	// bone with unit length 1
+	else
+		VecAddf(bone->tail, bone->head, imat[2]);	// bone with unit length 1, pointing up Z
+	
 }
 
 void add_primitiveArmature(int type)
 {
+	short newob=0;
+	
 	if(G.scene->id.lib) return;
 	
 	/* this function also comes from an info window */
@@ -1534,13 +1543,18 @@
 		
 		make_editArmature();
 		setcursor_space(SPACE_VIEW3D, CURSOR_EDIT);
+		newob=1;
 	}
 	
 	/* no primitive support yet */
-	add_primitive_bone(G.obedit);
+	add_primitive_bone(G.obedit, newob);
 	
 	countall(); // flushes selection!
 
+	if ( (newob) && !(U.flag & USER_ADD_EDITMODE)) {
+		exit_editmode(2);
+	}
+	
 	allqueue(REDRAWALL, 0);
 	BIF_undo_push("Add primitive");
 }

Modified: trunk/blender/source/blender/src/editcurve.c
===================================================================
--- trunk/blender/source/blender/src/editcurve.c	2007-10-31 20:56:50 UTC (rev 12446)
+++ trunk/blender/source/blender/src/editcurve.c	2007-10-31 21:55:06 UTC (rev 12447)
@@ -2514,6 +2514,10 @@
 	
 }
 
+/* from what I can gather, the mode==0 magic number spins and bridges the nurbs based on the 
+ * orientation of the global 3d view (yuck yuck!) mode==1 does the same, but doesn't bridge up
+ * up the new geometry, mode==2 now does the same as 0, but aligned to world axes, not the view.
+*/
 static void spin_nurb(float *dvec, short mode)
 {
 	Nurb *nu;
@@ -2525,7 +2529,8 @@
 	if(G.vd==0 || G.obedit==0 || G.obedit->type!=OB_SURF) return;
 	if( (G.vd->lay & G.obedit->lay)==0 ) return;
 
-	Mat3CpyMat4(persmat, G.vd->viewmat);
+	if (mode != 2) Mat3CpyMat4(persmat, G.vd->viewmat);
+	else Mat3One(persmat);
 	Mat3Inv(persinv, persmat);
 
 	/* imat and center and size */
@@ -2537,7 +2542,7 @@
 	VecSubf(cent, cent, G.obedit->obmat[3]);
 	Mat3MulVecfl(imat,cent);
 
-	if(dvec) {
+	if(dvec || mode==2) {
 		n[0]=n[1]= 0.0;
 		n[2]= 1.0;
 	} else {
@@ -2578,7 +2583,7 @@
 	ok= 1;
 
 	for(a=0;a<7;a++) {
-		if(mode==0) ok= extrudeflagNurb(1);
+		if(mode==0 || mode==2) ok= extrudeflagNurb(1);
 		else adduplicateflagNurb(1);
 		if(ok==0) {
 			error("Can't spin");
@@ -2586,7 +2591,7 @@
 		}
 		rotateflagNurb(1,cent,rotmat);
 
-		if(mode==0) {
+		if(mode==0 || mode==2) {
 			if( (a & 1)==0 ) {
 				rotateflagNurb(1,cent,scalemat1);
 				weightflagNurb(1, 0.25*sqrt(2.0), 1);
@@ -3806,7 +3811,8 @@
 		cent[2]-= G.obedit->obmat[3][2];
 		
 		if (G.vd) {
-			Mat3CpyMat4(imat, G.vd->viewmat);
+			if ( !(newname) || U.flag & USER_ADD_VIEWALIGNED) Mat3CpyMat4(imat, G.vd->viewmat);
+			else Mat3One(imat);
 			Mat3MulVecfl(imat, cent);
 			Mat3MulMat3(cmat, imat, mat);
 			Mat3Inv(imat, cmat);
@@ -4061,7 +4067,7 @@
 				rename_id((ID *)G.obedit->data, "SurfTube");
 			}
 
-			nu= addNurbprim(4, 1, 0);  /* circle */
+			nu= addNurbprim(4, 1, newname);  /* circle */
 			nu->resolu= 32;
 			nu->flag= CU_SMOOTH;
 			BLI_addtail(&editNurb, nu); /* temporal for extrude and translate */
@@ -4116,7 +4122,8 @@
 			makeknots(nu, 1, nu->flagu>>1);
 
 			BLI_addtail(&editNurb, nu); /* temporal for spin */
-			spin_nurb(0, 0);
+			if(newname) spin_nurb(0, 2);
+			else spin_nurb(0, 0);
 
 			makeknots(nu, 2, nu->flagv>>1);
 
@@ -4137,13 +4144,14 @@
 			}
 
 			xzproj= 1;
-			nu= addNurbprim(4, 1, 0);  /* circle */
+			nu= addNurbprim(4, 1, newname);  /* circle */
 			xzproj= 0;
 			nu->resolu= 24;
 			nu->resolv= 32;
 			nu->flag= CU_SMOOTH;
 			BLI_addtail(&editNurb, nu); /* temporal for extrude and translate */
-			spin_nurb(0, 0);
+			if(newname) spin_nurb(0, 2);
+			else spin_nurb(0, 0);
 
 			BLI_remlink(&editNurb, nu);
 
@@ -4256,11 +4264,17 @@
 	DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
 
 	countall();
+	
+	/* if a new object was created, it stores it in Curve, for reload original data and undo */
+	if ( !(newname) || U.flag & USER_ADD_EDITMODE) {
+		if(newname) load_editNurb();
+	} else {
+		exit_editmode(2);
+	}
+	
 	allqueue(REDRAWALL, 0);
 	
-	/* if a new object was created, it stores it in Curve, for reload original data and undo */
-	if(newname) load_editNurb();
-	BIF_undo_push("Add primitive");
+	BIF_undo_push("Add Curve");
 }
 
 void add_primitiveNurb(int type)
@@ -4291,11 +4305,16 @@
 	DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
 
 	countall();
+	
+	/* if a new object was created, it stores it in Curve, for reload original data and undo */
+	if ( !(newname) || U.flag & USER_ADD_EDITMODE) {
+		if(newname) load_editNurb();
+	} else {
+		exit_editmode(2);
+	}
 	allqueue(REDRAWALL, 0);
-
-	/* if a new object was created, it stores it in Curve, for reload original data and undo */
-	if(newname) load_editNurb();
-	else BIF_undo_push("Add primitive");
+	
+	BIF_undo_push("Add Surface");
 }
 
 

Modified: trunk/blender/source/blender/src/editmesh_add.c
===================================================================
--- trunk/blender/source/blender/src/editmesh_add.c	2007-10-31 20:56:50 UTC (rev 12446)
+++ trunk/blender/source/blender/src/editmesh_add.c	2007-10-31 21:55:06 UTC (rev 12447)
@@ -48,6 +48,7 @@
 #include "DNA_scene_types.h"
 #include "DNA_space_types.h"
 #include "DNA_screen_types.h"
+#include "DNA_userdef_types.h"
 #include "DNA_view3d_types.h"
 
 #include "BLI_blenlib.h"
@@ -1178,7 +1179,7 @@
 	char *name=NULL;
 	
 	if(G.scene->id.lib) return;
-
+	
 	/* this function also comes from an info window */
 	if ELEM(curarea->spacetype, SPACE_VIEW3D, SPACE_INFO); else return;
 	if(G.vd==0) return;
@@ -1308,7 +1309,8 @@
 	cent[1]-= G.obedit->obmat[3][1];
 	cent[2]-= G.obedit->obmat[3][2];
 
-	Mat3CpyMat4(imat, G.vd->viewmat);
+	if ( !(newob) || U.flag & USER_ADD_VIEWALIGNED) Mat3CpyMat4(imat, G.vd->viewmat);
+	else Mat3One(imat);
 	Mat3MulVecfl(imat, cent);
 	Mat3MulMat3(cmat, imat, mat);
 	Mat3Inv(imat,cmat);
@@ -1320,8 +1322,7 @@
 	phid= 2*M_PI/tot;
 	phi= .25*M_PI;
 
-	make_prim(type, imat, tot, seg, subdiv, dia, d,
-        ext, fill, cent);
+	make_prim(type, imat, tot, seg, subdiv, dia, d, ext, fill, cent);
 
 	if(type<2) tot = totoud;
 
@@ -1331,12 +1332,18 @@
 	if(type!=0 && type!=13) righthandfaces(1);	/* otherwise monkey has eyes in wrong direction... */
 	countall();
 
+	DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+	
+	/* if a new object was created, it stores it in Mesh, for reload original data and undo */
+	if ( !(newob) || U.flag & USER_ADD_EDITMODE) {
+		if(newob) load_editMesh();
+	} else {
+		exit_editmode(2);
+	}
+	
 	allqueue(REDRAWINFO, 1); 	/* 1, because header->win==0! */	
 	allqueue(REDRAWALL, 0);
-	DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);	
-
-	/* if a new object was created, it stores it in Mesh, for reload original data and undo */
-	if(newob) load_editMesh();	
+	
 	BIF_undo_push(undostr);
 }
 

Modified: trunk/blender/source/blender/src/space.c
===================================================================
--- trunk/blender/source/blender/src/space.c	2007-10-31 20:56:50 UTC (rev 12446)
+++ trunk/blender/source/blender/src/space.c	2007-10-31 21:55:06 UTC (rev 12447)
@@ -3548,16 +3548,28 @@
 
 
 		uiDefBut(block, LABEL,0,"Material linked to:",
-			xpos,y3label,mpref,buth,
+			xpos,y5label,mpref,buth,
 			0, 0, 0, 0, 0, "");
 		uiBlockBeginAlign(block);
 		uiDefButBitI(block, TOGN, USER_MAT_ON_OB, B_DRAWINFO, "ObData",
-			(xpos+edgsp),y2,(mpref/2),buth,
+			(xpos+edgsp),y4,(mpref/2),buth,
 			&(U.flag), 0, 0, 0, 0, "Link new objects' material to the obData block");
 		uiDefButBitI(block, TOG, USER_MAT_ON_OB, B_DRAWINFO, "Object",
-			(xpos+edgsp+(mpref/2)),y2,(mpref/2),buth,
+			(xpos+edgsp+(mpref/2)),y4,(mpref/2),buth,
 			&(U.flag), 0, 0, 0, 0, "Link new objects' material to the object block");
 		uiBlockEndAlign(block);
+		
+		uiDefBut(block, LABEL,0,"Add new objects:",
+			xpos,y3label,mpref,buth,

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list