[Bf-committers] New Transform patch.

joeedh joeeagar at prodigy.net
Fri Feb 25 20:18:36 CET 2005


Hi.  Here is a patch that makes it so that constraints in the new 
transform are enforced as you're picking them.  I find this to make the 
new middlemouse constraint picking to be a lot more useable.

joeedh
-------------- next part --------------
Index: blender/source/blender/src/transform.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/transform.c,v
retrieving revision 1.12
diff -r1.12 transform.c
84a85
> #include "BIF_meshHE.h"
598a600,725
> static void createTransHEEditVerts(void)
> {
> 	TransData *tob = NULL;
> 	int totsel = 0;
> 	HE_EditMesh *em = G.he_editMesh;
> 	HE_EditVert *eve;
> 	float mtx[3][3], smtx[3][3];
> 	
> 	// transform now requires awareness for select mode, so we tag the f1 flags in verts
> 	if(G.scene->selectmode & SCE_SELECT_VERTEX) {
> 		for(eve= em->verts.first; eve; eve= eve->link.next) {
> 			if(eve->h==0 && (eve->f & SELECT)) {
> 				eve->f1= SELECT;
> 				Trans.total++;
> 			}
> 			else
> 				eve->f1= 0;
> 		}
> 	}
> 	else if(G.scene->selectmode & SCE_SELECT_EDGE) {
> 		HE_EditEdgeInfo *ieed;
> 		for(eve= em->verts.first; eve; eve= eve->link.next) eve->f1= 0;
> 		for(ieed= em->einfo.first; ieed; ieed= ieed->link.next) {
> 			if(ieed->h==0 && (ieed->f & SELECT))
> 				ieed->e1->v1->f1= ieed->e1->v2->f1= SELECT;
> 		}
> 		for(eve= em->verts.first; eve; eve= eve->link.next)
> 			if(eve->f1)
> 				Trans.total++;
> 	}
> 	else {
> 		HE_EditFace *efa;
> 		HE_EditEdge *eed;
> 		for(eve= em->verts.first; eve; eve= eve->link.next) eve->f1= 0;
> 		for(efa= em->faces.first; efa; efa= efa->link.next) {
> 			if(efa->h==0 && (efa->f & SELECT)) {
> 				eed = efa->edge;
> 				do {
> 				    eed->v1->f1 = SELECT;
> 				    eed=eed->enext;
> 			    } while (eed != efa->edge);        
> 			}
> 		}
> 		for(eve= em->verts.first; eve; eve= eve->link.next)
> 			if(eve->f1)
> 				Trans.total++;
> 	}
> 	
> 	totsel = Trans.total;
> 	/* proportional edit exception... */
> 	if((G.f & G_PROPORTIONAL) && Trans.total) {
> 		for(eve= em->verts.first; eve; eve= eve->link.next) {
> 			if(eve->h==0 && (!(eve->f1 & SELECT))) {
> 				eve->f1 = 2;
> 				Trans.total++;
> 			}
> 		}
> 	}
> 
> 	/* and now make transverts */
>     if (!Trans.total) return;
> 	
> 	Mat3CpyMat4(mtx, G.obedit->obmat);
> 	Mat3Inv(smtx, mtx);
> 
>     tob = Trans.data = MEM_mallocN(Trans.total*sizeof(TransData), "TransEditVert");
> 
> 	for (eve=em->verts.first; eve; eve=eve->link.next)
> 	{
> 		if (eve->f1 == SELECT) {
> 			tob->flag = 0;
> 			tob->loc = eve->co;
> 			VECCOPY(tob->center, tob->loc);
> 			VECCOPY(tob->iloc, tob->loc);
> 			tob->ext = NULL;
> 
> 			tob->flag |= TD_SELECTED;
> 
> 			Mat3CpyMat3(tob->smtx, smtx);
> 			Mat3CpyMat3(tob->mtx, mtx);
> 
> 			tob->dist = 0.0f;
> 
> 			tob++;
> 		}	
> 	}	
> 
> 	/* PROPORTIONAL*/
> 	if (G.f & G_PROPORTIONAL) {
> 		for (eve=em->verts.first; eve; eve=eve->link.next)
> 		{
> 			TransData *td;
> 			int i;
> 			float dist, vec[3];
> 			if (eve->f1 == 2) {
> 
> 				tob->flag = 0;
> 				tob->loc = eve->co;
> 				VECCOPY(tob->center, tob->loc);
> 				VECCOPY(tob->iloc, tob->loc);
> 				tob->ext = NULL;
> 
> 				Mat3CpyMat3(tob->smtx, smtx);
> 				Mat3CpyMat3(tob->mtx, mtx);
> 			
> 				tob->dist = -1;
> 
> 				td = Trans.data;
> 				for (i = 0; i < totsel; i++, td++) {
> 					VecSubf(vec, tob->center, td->center);
> 					Mat3MulVecfl(mtx, vec);
> 					dist = Normalise(vec);
> 					if (tob->dist == -1) {
> 						tob->dist = dist;
> 					}
> 					else if (dist < tob->dist) {
> 						tob->dist = dist;
> 					}
> 				}
> 
> 				tob++;
> 			}	
> 		}	
> 	}
> }    
> 
1142a1270,1272
>    		else if (G.obedit->type==OB_HEMESH) {
>    		    createTransHEEditVerts();
>    		}    
1174c1304
< 	unsigned short event;
---
> 	unsigned short event, conmode=0;
1247a1378
> 			if (conmode==1) chooseConstraint(&Trans);
1250a1382
> 
1263a1396,1398
> 					chooseConstraint(&Trans);
> 					conmode = 1;
> 					Trans.con.mode |= DRAWALL;
1333a1469,1470
> 					conmode = 0;
> 					Trans.con.mode &= ~DRAWALL;
Index: blender/source/blender/src/transform.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/transform.h,v
retrieving revision 1.8
diff -r1.8 transform.h
139a140
> #define DRAWALL			16
Index: blender/source/blender/src/transform_constraints.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/transform_constraints.c,v
retrieving revision 1.5
diff -r1.5 transform_constraints.c
310c310
< 	if (tc->mode & CONAXIS0) {
---
> 	if (tc->mode & (CONAXIS0|DRAWALL)) {
316c316
< 	if (tc->mode & CONAXIS1) {
---
> 	if (tc->mode & (CONAXIS1|DRAWALL)) {
322c322
< 	if (tc->mode & CONAXIS2) {
---
> 	if (tc->mode & (CONAXIS2|DRAWALL)) {
Index: blender/source/blender/src/transform_generics.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/transform_generics.c,v
retrieving revision 1.7
diff -r1.7 transform_generics.c
163,164c163,166
< 		}
< 		else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) {
---
> 		} else if (G.obedit->type == OB_HEMESH) {
> 		    HE_recalcnormals();
> 		    makeDispList(G.obedit);
> 		} else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) {
333c335
< 		col[0] = col[1] = col[2] = 200;
---
> 		col[0] = col[1] = col[2] = 245;
693c695
< }
\ No newline at end of file
---
> } 	


More information about the Bf-committers mailing list