[Bf-committers] Patch for bug 1355

bf-committers@blender.org bf-committers@blender.org
Sat, 12 Jun 2004 14:49:22 -0500


On 12 Jun 2004 at 14:12, Jiri Hnidek wrote:
hey,
Sorry I thought I removed that one. It stood for the dot product of 
the face centroid with itself.

> Hi,
> it works for me, but can you tell me: "What is meaning of variable 
> dotcent?" ;-)
> 
> Jiri
> 
> >Here is a patch for bug number 1355 the recalc normals inside and 
> >outside function was broken. It gave strange results in cases where 
> >the object origin was not at the selected mesh centroid. I added code 
> >to account for differing mesh and object centres.
> >  
> >
> >Index: source/blender/src/editmesh.c
> >===================================================================
> >RCS file: /cvsroot/bf-blender/blender/source/blender/src/editmesh.c,v
> >retrieving revision 1.88
> >diff -u -r1.88 editmesh.c
> >--- source/blender/src/editmesh.c	5 Jun 2004 05:55:14 -0000	1.88
> >+++ source/blender/src/editmesh.c	11 Jun 2004 17:03:44 -0000
> >@@ -1757,8 +1757,9 @@
> > {
> > 	EditMesh *em = G.editMesh;
> > 	EditEdge *eed, *ed1, *ed2, *ed3, *ed4;
> >+	EditVert *eve;
> > 	EditVlak *evl, *startvl;
> >-	float maxx, nor[3], cent[3];
> >+	float maxx, min[3], max[3], nor[3], cent[3], centm[3], dotcent;
> > 	int totsel, found, foundone, direct, turn;
> > 
> >    /* based at a select-connected to witness loose objects */
> >@@ -1820,17 +1821,43 @@
> > 			evl= evl->next;
> > 		}
> > 		
> >+		/* find our mesh centroid */
> >+		INIT_MINMAX(min, max);
> >+		eve= em->verts.first;
> >+		while(eve) {
> >+			DO_MINMAX(eve->co, min, max);
> >+			eve= eve->next;
> >+		}
> >+		centm[0]= (min[0]+max[0])/2.0;
> >+		centm[1]= (min[1]+max[1])/2.0;
> >+		centm[2]= (min[2]+max[2])/2.0;
> >+		
> > 		/* set first face correct: calc normal */
> > 		CalcNormFloat(startvl->v1->co, startvl->v2->co, startvl->v3->co, nor);
> >+		/* account for object centers not at mesh centroid */
> >+		nor[0] = nor[0]-centm[0];
> >+		nor[1] = nor[1]-centm[1];
> >+		nor[2] = nor[2]-centm[2];
> >+		
> > 		CalcCent3f(cent, startvl->v1->co, startvl->v2->co, startvl->v3->co);
> >+		/* account for object centers not at mesh centroid */
> >+		cent[0] = cent[0]-centm[0];
> >+		cent[1] = cent[1]-centm[1];
> >+		cent[2] = cent[2]-centm[2];
> >+		
> >+		dotcent = cent[0]*cent[0]+cent[1]*cent[1]+cent[2]*cent[2];		
> > 		
> > 		/* first normal is oriented this way or the other */
> > 		if(select) {
> > 			if(select==2) {
> >-				if(cent[0]*nor[0]+cent[1]*nor[1]+cent[2]*nor[2] > 0.0) flipvlak(startvl);
> >+				if( cent[0]*nor[0]+cent[1]*nor[1]+cent[2]*nor[2] > 0.0 ) {
> >+					 flipvlak(startvl);
> >+				}
> > 			}
> > 			else {
> >-				if(cent[0]*nor[0]+cent[1]*nor[1]+cent[2]*nor[2] < 0.0) flipvlak(startvl);
> >+				if(cent[0]*nor[0]+cent[1]*nor[1]+cent[2]*nor[2] < 0.0) {
> >+					 flipvlak(startvl);
> >+				}
> > 			}
> > 		}
> > 		else if(cent[0]*nor[0]+cent[1]*nor[1]+cent[2]*nor[2] < 0.0) flipvlak(startvl);
> >  
> >
> 
> _______________________________________________
> Bf-committers mailing list
> Bf-committers@blender.org
> http://www.blender.org/mailman/listinfo/bf-committers
> 
> 
>