[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43100] branches/bmesh/blender/source/ blender/modifiers/intern/MOD_mirror.c: only run remove doubles if a double is found.

Campbell Barton ideasman42 at gmail.com
Tue Jan 3 15:02:54 CET 2012


Revision: 43100
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43100
Author:   campbellbarton
Date:     2012-01-03 14:02:51 +0000 (Tue, 03 Jan 2012)
Log Message:
-----------
only run remove doubles if a double is found.

Modified Paths:
--------------
    branches/bmesh/blender/source/blender/modifiers/intern/MOD_mirror.c

Modified: branches/bmesh/blender/source/blender/modifiers/intern/MOD_mirror.c
===================================================================
--- branches/bmesh/blender/source/blender/modifiers/intern/MOD_mirror.c	2012-01-03 13:57:31 UTC (rev 43099)
+++ branches/bmesh/blender/source/blender/modifiers/intern/MOD_mirror.c	2012-01-03 14:02:51 UTC (rev 43100)
@@ -99,6 +99,7 @@
 {
 	const float tolerance_sq = mmd->tolerance * mmd->tolerance;
 	const int do_vtargetmap = !(mmd->flag & MOD_MIR_NO_MERGE);
+	int is_vtargetmap = FALSE; /* true when it should be used */
 
 	DerivedMesh *result;
 	const int maxVerts = dm->getNumVerts(dm);
@@ -184,7 +185,14 @@
 		if (do_vtargetmap) {
 			/* compare location of the original and mirrored vertex, to see if they
 			 * should be mapped for merging */
-			*vtmap_a = (len_squared_v3v3(mv_prev->co, mv->co) < tolerance_sq) ? maxVerts + i : -1;
+			if (UNLIKELY(len_squared_v3v3(mv_prev->co, mv->co) < tolerance_sq)) {
+				*vtmap_a = maxVerts + i;
+				is_vtargetmap = TRUE;
+			}
+			else {
+				*vtmap_a = -1;
+			}
+
 			*vtmap_b = -1; /* fill here to avoid 2x loops */
 
 			vtmap_a++;
@@ -269,8 +277,9 @@
 	}
 
 	if (do_vtargetmap) {
-		/* this calls CDDM_recalc_tesselation, so dont do twice */
-		result = CDDM_merge_verts(result, vtargetmap);
+		if (is_vtargetmap) { /* slow - so only call if one or more merge verts are found */
+			result = CDDM_merge_verts(result, vtargetmap);
+		}
 		MEM_freeN(vtargetmap);
 	}
 




More information about the Bf-blender-cvs mailing list