[Bf-blender-cvs] [ab4b7b5368c] master: Fix T51648: Inconsistent edge collapse point depending on orientation

Luca Rood noreply at git.blender.org
Fri Jun 9 10:05:16 CEST 2017


Commit: ab4b7b5368c0dc3b3d6dbc9a63a45f8efc841d80
Author: Luca Rood
Date:   Fri Jun 9 09:56:19 2017 +0200
Branches: master
https://developer.blender.org/rBab4b7b5368c0dc3b3d6dbc9a63a45f8efc841d80

Fix T51648: Inconsistent edge collapse point depending on orientation

Edge collapse was using bounding box center as the point to collapse to.
When collapsing multiple adjacent edges together, this caused
inconsistencies in placement of the collapsed point, depending on the
orientation of the edges in relation to the space axis.

This makes edge collapse use the mean point instead.

===================================================================

M	source/blender/bmesh/operators/bmo_removedoubles.c

===================================================================

diff --git a/source/blender/bmesh/operators/bmo_removedoubles.c b/source/blender/bmesh/operators/bmo_removedoubles.c
index 18704a6679f..7d19d90807a 100644
--- a/source/blender/bmesh/operators/bmo_removedoubles.c
+++ b/source/blender/bmesh/operators/bmo_removedoubles.c
@@ -440,20 +440,24 @@ void bmo_collapse_exec(BMesh *bm, BMOperator *op)
 	edge_stack = BLI_stack_new(sizeof(BMEdge *), __func__);
 
 	BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
-		float min[3], max[3], center[3];
+		float center[3];
+		int count = 0;
 		BMVert *v_tar;
 
+		zero_v3(center);
+
 		if (!BMO_edge_flag_test(bm, e, EDGE_MARK))
 			continue;
 
 		BLI_assert(BLI_stack_is_empty(edge_stack));
 
-		INIT_MINMAX(min, max);
 		for (e = BMW_begin(&walker, e->v1); e; e = BMW_step(&walker)) {
 			BLI_stack_push(edge_stack, &e);
 
-			minmax_v3v3_v3(min, max, e->v1->co);
-			minmax_v3v3_v3(min, max, e->v2->co);
+			add_v3_v3(center, e->v1->co);
+			add_v3_v3(center, e->v2->co);
+
+			count += 2;
 
 			/* prevent adding to slot_targetmap multiple times */
 			BM_elem_flag_disable(e->v1, BM_ELEM_TAG);
@@ -461,8 +465,7 @@ void bmo_collapse_exec(BMesh *bm, BMOperator *op)
 		}
 
 		if (!BLI_stack_is_empty(edge_stack)) {
-
-			mid_v3_v3v3(center, min, max);
+			mul_v3_fl(center, 1.0f / count);
 
 			/* snap edges to a point.  for initial testing purposes anyway */
 			e = *(BMEdge **)BLI_stack_peek(edge_stack);




More information about the Bf-blender-cvs mailing list