[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [40152] branches/bmesh/blender/source/ blender: use BM_Make_Vert example argument rather then calling inline, was also copying vertex normals twice in quite a few places.

Campbell Barton ideasman42 at gmail.com
Mon Sep 12 07:24:45 CEST 2011


Revision: 40152
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=40152
Author:   campbellbarton
Date:     2011-09-12 05:24:45 +0000 (Mon, 12 Sep 2011)
Log Message:
-----------
use BM_Make_Vert example argument rather then calling inline, was also copying vertex normals twice in quite a few places.

Modified Paths:
--------------
    branches/bmesh/blender/source/blender/bmesh/intern/bmesh_construct.c
    branches/bmesh/blender/source/blender/bmesh/intern/bmesh_newcore.c
    branches/bmesh/blender/source/blender/bmesh/operators/edgesplitop.c
    branches/bmesh/blender/source/blender/bmesh/operators/extrudeops.c
    branches/bmesh/blender/source/blender/editors/mesh/bmesh_tools.c
    branches/bmesh/blender/source/blender/editors/mesh/knifetool.c

Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_construct.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_construct.c	2011-09-12 05:21:47 UTC (rev 40151)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_construct.c	2011-09-12 05:24:45 UTC (rev 40152)
@@ -497,10 +497,9 @@
 
 	v = BMIter_New(&iter, bmold, BM_VERTS_OF_MESH, NULL);
 	for (i=0; v; v=BMIter_Step(&iter), i++) {
-		v2 = BM_Make_Vert(bm, v->co, NULL);
+		v2 = BM_Make_Vert(bm, v->co, NULL); /* copy between meshes so cant use 'example' argument */
 		BM_Copy_Attributes(bmold, bm, v, v2);
 		BLI_array_growone(vtable);
-		copy_v3_v3(v2->no, v->no);
 
 		vtable[BLI_array_count(vtable)-1] = v2;
 

Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_newcore.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_newcore.c	2011-09-12 05:21:47 UTC (rev 40151)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_newcore.c	2011-09-12 05:24:45 UTC (rev 40152)
@@ -26,6 +26,7 @@
 
 	v->head.type = BM_VERT;
 
+	/* 'v->no' is handled by BM_Copy_Attributes */
 	if (co) copy_v3_v3(v->co, co);
 	
 	/*allocate flags*/

Modified: branches/bmesh/blender/source/blender/bmesh/operators/edgesplitop.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/operators/edgesplitop.c	2011-09-12 05:21:47 UTC (rev 40151)
+++ branches/bmesh/blender/source/blender/bmesh/operators/edgesplitop.c	2011-09-12 05:24:45 UTC (rev 40152)
@@ -207,8 +207,8 @@
 
 	BMO_Flag_Buffer(bm, op, "edges", EDGE_SEAM, BM_EDGE);
 	
-	/*single marked edges unconnected to any other marked edges
-	  are illegal, go through and unmark them*/
+	/* single marked edges unconnected to any other marked edges
+	 * are illegal, go through and unmark them */
 	BMO_ITER(e, &siter, bm, op, "edges", BM_EDGE) {
 		for (i=0; i<2; i++) {
 			BM_ITER(e2, &iter, bm, BM_EDGES_OF_VERT, i ? e->v2 : e->v1) {
@@ -231,10 +231,10 @@
 	}
 
 #ifdef ETV
-#undef ETV
+#  undef ETV
 #endif
 #ifdef SETETV
-#undef SETETV
+#  undef SETETV
 #endif
 
 #define ETV(et, v, l) (l->e->v1 == v ? et->newv1 : et->newv2)
@@ -271,9 +271,7 @@
 				if (BMO_TestFlag(bm, l2->e, EDGE_SEAM)) {
 					if (!verts[j ? (i+1) % f->len : i]) {
 						/*make unique vert here for this face only*/
-						v2 = BM_Make_Vert(bm, v->co, NULL);
-						copy_v3_v3(v2->no, v->no);
-						BM_Copy_Attributes(bm, bm, v, v2);
+						v2 = BM_Make_Vert(bm, v->co, v);
 
 						verts[j ? (i+1) % f->len : i] = v2;
 					} else v2 = verts[j ? (i+1) % f->len : i];
@@ -301,9 +299,7 @@
 					if (l3 == NULL || (BMO_TestFlag(bm, l3->e, EDGE_SEAM) && l3->e != l->e)) {
 						et = etags + BM_GetIndex(l2->e);
 						if (ETV(et, v, l2) == NULL) {
-							v2 = BM_Make_Vert(bm, v->co, NULL);
-							copy_v3_v3(v2->no, v->no);
-							BM_Copy_Attributes(bm, bm, v, v2);
+							v2 = BM_Make_Vert(bm, v->co, v);
 							
 							l3 = l2;
 							do {

Modified: branches/bmesh/blender/source/blender/bmesh/operators/extrudeops.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/operators/extrudeops.c	2011-09-12 05:21:47 UTC (rev 40151)
+++ branches/bmesh/blender/source/blender/bmesh/operators/extrudeops.c	2011-09-12 05:24:45 UTC (rev 40152)
@@ -39,8 +39,7 @@
 		BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) {
 			BLI_array_growone(edges);
 
-			v = BM_Make_Vert(bm, l->v->co, NULL);
-			BM_Copy_Attributes(bm, bm, l->v, v);
+			v = BM_Make_Vert(bm, l->v->co, l->v);
 
 			if (lastv) {
 				e = BM_Make_Edge(bm, lastv, v, l->e, 0);
@@ -151,9 +150,7 @@
 
 	v = BMO_IterNew(&siter, bm, op, "verts", BM_VERT);
 	for (; v; v=BMO_IterStep(&siter)) {
-		dupev = BM_Make_Vert(bm, v->co, NULL);
-		copy_v3_v3(dupev->no, v->no);
-		BM_Copy_Attributes(bm, bm, v, dupev);
+		dupev = BM_Make_Vert(bm, v->co, v);
 
 		e = BM_Make_Edge(bm, v, dupev, NULL, 0);
 

Modified: branches/bmesh/blender/source/blender/editors/mesh/bmesh_tools.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/mesh/bmesh_tools.c	2011-09-12 05:21:47 UTC (rev 40151)
+++ branches/bmesh/blender/source/blender/editors/mesh/bmesh_tools.c	2011-09-12 05:24:45 UTC (rev 40152)
@@ -2709,7 +2709,7 @@
 	BMEdge *e, *e2, *closest = NULL;
 	BMVert *v;
 	int side = 0, i, singlesel = 0;
-	float projectMat[4][4], fmval[3] = {event->mval[0], event->mval[1], 0.0f};
+	float projectMat[4][4], fmval[3] = {event->mval[0], event->mval[1]};
 	float dist = FLT_MAX, d;
 
 	ED_view3d_ob_project_mat_get(rv3d, obedit, projectMat);
@@ -2803,34 +2803,31 @@
 
 	for (i=0; i<2; i++) {
 		BMO_ITER(e, &siter, em->bm, &bmop, i ? "edgeout2":"edgeout1", BM_EDGE) {
-			float cent[3] = {0, 0, 0}, mid[4], vec[3];
+			float cent[3] = {0, 0, 0}, mid[3], vec[3];
 
 			if (!BMBVH_EdgeVisible(bvhtree, e, ar, v3d, obedit) || !e->l)
 				continue;
 
-			/*method for calculating distance:
-			
-			  for each edge: calculate face center, then made a vector
-			  from edge midpoint to face center.  offset edge midpoint
-			  by a small amount along this vector.*/
+			/* method for calculating distance:
+			 *
+			 * for each edge: calculate face center, then made a vector
+			 * from edge midpoint to face center.  offset edge midpoint
+			 * by a small amount along this vector. */
 			BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, e->l->f) {
-				add_v3_v3v3(cent, cent, l->v->co);
+				add_v3_v3(cent, l->v->co);
 			}
 			mul_v3_fl(cent, 1.0f/(float)e->l->f->len);
 
-			add_v3_v3v3(mid, e->v1->co, e->v2->co);
-			mul_v3_fl(mid, 0.5f);
+			mid_v3_v3v3(mid, e->v1->co, e->v2->co);
 			sub_v3_v3v3(vec, cent, mid);
 			normalize_v3(vec);
 			mul_v3_fl(vec, 0.01f);
 			add_v3_v3v3(mid, mid, vec);
 
-			/*yay we have our comparison point, now project it*/
+			/* yay we have our comparison point, now project it */
 			ED_view3d_project_float(ar, mid, mid, projectMat);
 
-			vec[0] = fmval[0] - mid[0];
-			vec[1] = fmval[1] - mid[1];
-			d = vec[0]*vec[0] + vec[1]*vec[1];
+			d = len_squared_v2v2(fmval, mid);
 
 			if (d < dist) {
 				side = i;

Modified: branches/bmesh/blender/source/blender/editors/mesh/knifetool.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/mesh/knifetool.c	2011-09-12 05:21:47 UTC (rev 40151)
+++ branches/bmesh/blender/source/blender/editors/mesh/knifetool.c	2011-09-12 05:24:45 UTC (rev 40152)
@@ -1373,6 +1373,7 @@
 	BLI_mempool_iternew(kcd->kverts, &iter);
 	for (kfv=BLI_mempool_iterstep(&iter); kfv; kfv=BLI_mempool_iterstep(&iter)) {
 		if (!kfv->v) {
+			/* shouldn't we be at least copying the normal? - if not some comment here should explain why - campbell */
 			kfv->v = BM_Make_Vert(bm, kfv->co, NULL);
 			kfv->flag = 1;
 			BMO_SetFlag(bm, kfv->v, DEL);




More information about the Bf-blender-cvs mailing list