[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21539] branches/blender2.5/blender/source /blender/editors: Cleaning up manipulator code a bit

Martin Poirier theeth at yahoo.com
Sun Jul 12 04:01:15 CEST 2009


Revision: 21539
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21539
Author:   theeth
Date:     2009-07-12 04:01:13 +0200 (Sun, 12 Jul 2009)

Log Message:
-----------
Cleaning up manipulator code a bit

Made transform confirm or cancel on mouse up. More inline with button clicking and better for tablets.

Add operator params to make sure Rip and Extrude turn off PET and Mirror correctly.

Note: sorry for all the whitespace changes, I need to reconfigure this editor not to do autocleanup.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/include/ED_transform.h
    branches/blender2.5/blender/source/blender/editors/mesh/editmesh_tools.c
    branches/blender2.5/blender/source/blender/editors/transform/transform.c
    branches/blender2.5/blender/source/blender/editors/transform/transform.h
    branches/blender2.5/blender/source/blender/editors/transform/transform_constraints.c
    branches/blender2.5/blender/source/blender/editors/transform/transform_conversions.c
    branches/blender2.5/blender/source/blender/editors/transform/transform_generics.c
    branches/blender2.5/blender/source/blender/editors/transform/transform_manipulator.c

Modified: branches/blender2.5/blender/source/blender/editors/include/ED_transform.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/ED_transform.h	2009-07-11 22:29:53 UTC (rev 21538)
+++ branches/blender2.5/blender/source/blender/editors/include/ED_transform.h	2009-07-12 02:01:13 UTC (rev 21539)
@@ -1,5 +1,5 @@
 /**
- * $Id: ED_transform.h 21450 2009-07-09 02:45:48Z theeth $
+ * $Id$
  *
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
@@ -119,12 +119,16 @@
 char * BIF_menustringTransformOrientation(const struct bContext *C, char *title); /* the returned value was allocated and needs to be freed after use */
 int BIF_countTransformOrientation(const struct bContext *C);
 
-void BIF_getPropCenter(float *center);
-
 void BIF_TransformSetUndo(char *str);
 
 void BIF_selectOrientation(void);
 
+/* to be able to add operator properties to other operators */
+
+void Properties_Proportional(struct wmOperatorType *ot);
+void Properties_Snapping(struct wmOperatorType *ot, short align);
+void Properties_Constraints(struct wmOperatorType *ot);
+
 /* view3d manipulators */
 void initManipulator(int mode);
 void ManipulatorTransform();

Modified: branches/blender2.5/blender/source/blender/editors/mesh/editmesh_tools.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/mesh/editmesh_tools.c	2009-07-11 22:29:53 UTC (rev 21538)
+++ branches/blender2.5/blender/source/blender/editors/mesh/editmesh_tools.c	2009-07-12 02:01:13 UTC (rev 21539)
@@ -1,4 +1,4 @@
- /* $Id: 
+ /* $Id:
  *
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
@@ -133,7 +133,7 @@
 static int vergface(const void *v1, const void *v2)
 {
 	const struct facesort *x1=v1, *x2=v2;
-	
+
 	if( x1->x > x2->x ) return 1;
 	else if( x1->x < x2->x) return -1;
 	return 0;
@@ -146,7 +146,7 @@
 {
 	EditFace *efa, *efan, *next;
 	float fac;
-	
+
 	efa= em->faces.last;
 	while(efa) {
 		next= efa->prev;
@@ -167,17 +167,17 @@
 					efan= EM_face_from_faces(em, efa, NULL, 1, 2, 3, -1);
 					if(efa->f & SELECT) EM_select_face(efan, 1);
 				}
-				
+
 				BLI_remlink(&em->faces, efa);
 				free_editface(em, efa);
 			}
 		}
 		efa= next;
 	}
-	
+
 	EM_fgon_flags(em);	// redo flags and indices for fgons
 
-	
+
 }
 
 int removedoublesflag(EditMesh *em, short flag, short automerge, float limit)		/* return amount */
@@ -188,7 +188,7 @@
 					Used for "Auto Weld" mode. warning.
 		limit -		Quick manhattan distance between verts.
 	*/
-	
+
 	/* all verts with (flag & 'flag') are being evaluated */
 	EditVert *eve, *v1, *nextve;
 	EditEdge *eed, *e1, *nexted;
@@ -196,8 +196,8 @@
 	xvertsort *sortblock, *sb, *sb1;
 	struct facesort *vlsortblock, *vsb, *vsb1;
 	int a, b, test, amount;
-	
-	
+
+
 	/* flag 128 is cleared, count */
 
 	/* Normal non weld operation */
@@ -223,9 +223,9 @@
 	}
 	qsort(sortblock, amount, sizeof(xvertsort), vergxco);
 
-	
+
 	/* test for doubles */
-	sb= sortblock;	
+	sb= sortblock;
 	if (automerge) {
 		for(a=0; a<amount; a++, sb++) {
 			eve= sb->v1;
@@ -233,12 +233,12 @@
 				sb1= sb+1;
 				for(b=a+1; b<amount && (eve->f & 128)==0; b++, sb1++) {
 					if(sb1->x - sb->x > limit) break;
-					
+
 					/* when automarge, only allow unselected->selected */
 					v1= sb1->v1;
 					if( (v1->f & 128)==0 ) {
 						if ((eve->f & flag)==0 && (v1->f & flag)==1) {
-							if(	(float)fabs(v1->co[0]-eve->co[0])<=limit && 
+							if(	(float)fabs(v1->co[0]-eve->co[0])<=limit &&
 								(float)fabs(v1->co[1]-eve->co[1])<=limit &&
 								(float)fabs(v1->co[2]-eve->co[2])<=limit)
 							{	/* unique bit */
@@ -246,7 +246,7 @@
 								eve->tmp.v = v1;
 							}
 						} else if(	(eve->f & flag)==1 && (v1->f & flag)==0 ) {
-							if(	(float)fabs(v1->co[0]-eve->co[0])<=limit && 
+							if(	(float)fabs(v1->co[0]-eve->co[0])<=limit &&
 								(float)fabs(v1->co[1]-eve->co[1])<=limit &&
 								(float)fabs(v1->co[2]-eve->co[2])<=limit)
 							{	/* unique bit */
@@ -267,10 +267,10 @@
 					/* first test: simpel dist */
 					if(sb1->x - sb->x > limit) break;
 					v1= sb1->v1;
-					
+
 					/* second test: is vertex allowed */
 					if( (v1->f & 128)==0 ) {
-						if(	(float)fabs(v1->co[0]-eve->co[0])<=limit && 
+						if(	(float)fabs(v1->co[0]-eve->co[0])<=limit &&
 							(float)fabs(v1->co[1]-eve->co[1])<=limit &&
 							(float)fabs(v1->co[2]-eve->co[2])<=limit)
 						{
@@ -283,12 +283,12 @@
 		}
 	}
 	MEM_freeN(sortblock);
-	
+
 	if (!automerge)
 		for(eve = em->verts.first; eve; eve=eve->next)
 			if((eve->f & flag) && (eve->f & 128))
 				EM_data_interp_from_verts(em, eve, eve->tmp.v, eve->tmp.v, 0.5f);
-	
+
 	/* test edges and insert again */
 	eed= em->edges.first;
 	while(eed) {
@@ -327,7 +327,7 @@
 		else if(efa->v2->f & 128) efa->f1= 1;
 		else if(efa->v3->f & 128) efa->f1= 1;
 		else if(efa->v4 && (efa->v4->f & 128)) efa->f1= 1;
-		
+
 		if(efa->f1==1) amount++;
 		efa= efa->next;
 	}
@@ -337,12 +337,12 @@
 	while(efa) {
 		nextvl= efa->next;
 		if(efa->f1==1) {
-			
+
 			if(efa->v1->f & 128) efa->v1= efa->v1->tmp.v;
 			if(efa->v2->f & 128) efa->v2= efa->v2->tmp.v;
 			if(efa->v3->f & 128) efa->v3= efa->v3->tmp.v;
 			if(efa->v4 && (efa->v4->f & 128)) efa->v4= efa->v4->tmp.v;
-		
+
 			test= 0;
 			if(efa->v1==efa->v2) test+=1;
 			if(efa->v2==efa->v3) test+=2;
@@ -350,7 +350,7 @@
 			if(efa->v4==efa->v1) test+=8;
 			if(efa->v3==efa->v4) test+=16;
 			if(efa->v2==efa->v4) test+=32;
-			
+
 			if(test) {
 				if(efa->v4) {
 					if(test==1 || test==2) {
@@ -378,7 +378,7 @@
 					amount--;
 				}
 			}
-			
+
 			if(test==0) {
 				/* set edge pointers */
 				efa->e1= findedgelist(em, efa->v1, efa->v2);
@@ -423,9 +423,9 @@
 			}
 			efa= efa->next;
 		}
-		
+
 		qsort(vlsortblock, amount, sizeof(struct facesort), vergface);
-			
+
 		vsb= vlsortblock;
 		for(a=0; a<amount; a++) {
 			efa= vsb->efa;
@@ -433,24 +433,24 @@
 				vsb1= vsb+1;
 
 				for(b=a+1; b<amount; b++) {
-				
+
 					/* first test: same pointer? */
 					if(vsb->x != vsb1->x) break;
-					
+
 					/* second test: is test permitted? */
 					efa= vsb1->efa;
 					if( (efa->f1 & 128)==0 ) {
 						if( compareface(efa, vsb->efa)) efa->f1 |= 128;
-						
+
 					}
 					vsb1++;
 				}
 			}
 			vsb++;
 		}
-		
+
 		MEM_freeN(vlsortblock);
-		
+
 		/* remove double faces */
 		efa= (struct EditFace *)em->faces.first;
 		while(efa) {
@@ -462,7 +462,7 @@
 			efa= nextvl;
 		}
 	}
-	
+
 	/* remove double vertices */
 	a= 0;
 	eve= (struct EditVert *)em->verts.first;
@@ -495,12 +495,12 @@
 		sprintf(msg, "Removed %d vertices", cnt);
 		BKE_report(op->reports, RPT_INFO, msg);
 	}
-		
+
 	DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
 	WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
-	
+
 	BKE_mesh_end_editmesh(obedit->data, em);
-	return OPERATOR_FINISHED;	
+	return OPERATOR_FINISHED;
 }
 
 void MESH_OT_remove_doubles(wmOperatorType *ot)
@@ -508,11 +508,11 @@
 	/* identifiers */
 	ot->name= "Remove Doubles";
 	ot->idname= "MESH_OT_remove_doubles";
-	
+
 	/* api callbacks */
 	ot->exec= removedoublesflag_exec;
 	ot->poll= ED_operator_editmesh;
-	
+
 	/* flags */
 	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 }
@@ -534,18 +534,18 @@
 	xvertsort *sortblock;
 	ListBase tbase;
 	int i, amount;
-	
+
 	em_setup_viewcontext(C, &vc);
-	
+
 	amount = BLI_countlist(&vc.em->verts);
 	sortblock = MEM_callocN(sizeof(xvertsort)*amount,"xsort");
 	for (i=0,eve= vc.em->verts.first; eve; i++,eve=eve->next)
 		if(eve->f & flag)
 			sortblock[i].v1 = eve;
-	
+
 	mesh_foreachScreenVert(&vc, xsortvert_flag__doSetX, sortblock, 0);
 	qsort(sortblock, amount, sizeof(xvertsort), vergxco);
-	
+
 		/* make temporal listbase */
 	tbase.first= tbase.last= 0;
 	for (i=0; i<amount; i++) {
@@ -556,9 +556,9 @@
 			BLI_addtail(&tbase, eve);
 		}
 	}
-	
+
 	addlisttolist(&vc.em->verts, &tbase);
-	
+
 	MEM_freeN(sortblock);
 
 }
@@ -571,7 +571,7 @@
 	struct xvertsort *sortblock, *sb, onth, *newsort;
 	ListBase tbase;
 	int amount, a, b;
-	
+
 	/* count */
 	eve= em->verts.first;
 	amount= 0;
@@ -580,7 +580,7 @@
 		eve= eve->next;
 	}
 	if(amount==0) return;
-	
+
 	/* allocate memory */
 	sb= sortblock= (struct xvertsort *)MEM_mallocN(sizeof(struct xvertsort)*amount,"sortremovedoub");
 	eve= em->verts.first;
@@ -593,7 +593,7 @@
 	}
 
 	BLI_srand(1);
-	
+
 	sb= sortblock;
 	for(a=0; a<amount; a++, sb++) {
 		b= (int)(amount*BLI_drand());
@@ -614,9 +614,9 @@
 		BLI_addtail(&tbase, eve);
 		sb++;
 	}
-	
+
 	addlisttolist(&em->verts, &tbase);
-	
+
 	MEM_freeN(sortblock);
 
 }
@@ -632,11 +632,11 @@
 		if(em->totvertsel==0) nr= 0;
 		else if(em->totvertsel==1) nr= 4;
 		else if(em->totedgesel==0) nr= 4;
-		else if(em->totfacesel==0) 
+		else if(em->totfacesel==0)
 			nr= 3; // pupmenu("Extrude %t|Only Edges%x3|Only Vertices%x4");
 		else if(em->totfacesel==1)
 			nr= 1; // pupmenu("Extrude %t|Region %x1|Only Edges%x3|Only Vertices%x4");
-		else 
+		else
 			nr= 1; // pupmenu("Extrude %t|Region %x1||Individual Faces %x2|Only Edges%x3|Only Vertices%x4");
 	}
 	else if(em->selectmode & SCE_SELECT_EDGE) {
@@ -654,27 +654,27 @@
 		else
 			nr= 1; // pupmenu("Extrude %t|Region %x1||Individual Faces %x2");
 	}
-		
+
 	if(nr<1) return;
 
 	if(nr==1)  transmode= extrudeflag(obedit, em, SELECT, nor);
 	else if(nr==4) transmode= extrudeflag_verts_indiv(em, SELECT, nor);
 	else if(nr==3) transmode= extrudeflag_edges_indiv(em, SELECT, nor);
 	else transmode= extrudeflag_face_indiv(em, SELECT, nor);
-	
+
 	if(transmode==0) {
 		BKE_report(op->reports, RPT_ERROR, "Not a valid selection for extrude");
 	}
 	else {
 		EM_fgon_flags(em);
-		
-			/* We need to force immediate calculation here because 
+
+			/* We need to force immediate calculation here because
 			* transform may use derived objects (which are now stale).
 			*
 			* This shouldn't be necessary, derived queries should be
 			* automatically building this data if invalid. Or something.
 			*/
-//		DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);	
+//		DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
 		object_handle_update(scene, obedit);
 
 		/* individual faces? */
@@ -709,11 +709,12 @@
 
 	DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
 	WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
-	
-	RNA_int_set(op->ptr, "mode", TFM_TRANSLATION);
-	WM_operator_name_call(C, "TFM_OT_transform", WM_OP_INVOKE_REGION_WIN, op->ptr);
-	
-	return OPERATOR_FINISHED;	
+
+	RNA_enum_set(op->ptr, "proportional", 0);
+	RNA_boolean_set(op->ptr, "mirror", 0);
+	WM_operator_name_call(C, "TFM_OT_translation", WM_OP_INVOKE_REGION_WIN, op->ptr);
+

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list