Fix incorrectly deleted elements in array modifier caps.
authorNicholas Bishop <nicholasbishop@gmail.com>
Mon, 11 Jun 2012 09:41:08 +0000 (09:41 +0000)
committerNicholas Bishop <nicholasbishop@gmail.com>
Mon, 11 Jun 2012 09:41:08 +0000 (09:41 +0000)
Add check for merging vertices into vertices that are themselves
marked for merge, was already done for array eleements but not end
caps.

Fixes bug [#31695] Array Modifier: End Cap fails if all vertices are merged

Also corrected some reversed assert arguments.

source/blender/bmesh/intern/bmesh_marking.c
source/blender/bmesh/intern/bmesh_operators.c
source/blender/modifiers/intern/MOD_array.c

index 1720ee4f55a9cab86a6c5ba7341035297c5c21ff..59817043eed90dad21e690790a563a930e9d2901 100644 (file)
@@ -458,7 +458,7 @@ static int bm_mesh_flag_count(BMesh *bm, const char htype, const char hflag,
        BMIter iter;
        int tot = 0;
 
-       BLI_assert(ELEM(TRUE, FALSE, test_for_enabled));
+       BLI_assert(ELEM(test_for_enabled, TRUE, FALSE));
 
        if (htype & BM_VERT) {
                for (ele = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL); ele; ele = BM_iter_step(&iter)) {
index 82ad5c1805baaf4a1119f09fce2f4df9e1be0ebf..65288522b3b24724d6100c4ce9cc9b0a951828ca 100644 (file)
@@ -698,7 +698,7 @@ static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *sl
        BMOpSlot *output = BMO_slot_get(op, slotname);
        int totelement = 0, i = 0;
 
-       BLI_assert(ELEM(TRUE, FALSE, test_for_enabled));
+       BLI_assert(ELEM(test_for_enabled, TRUE, FALSE));
 
        if (test_for_enabled)
                totelement = BM_mesh_elem_hflag_count_enabled(bm, htype, hflag, TRUE);
index 39e08c1cb5df55d921ba52d5728a3078df06c067..41057234d9bfbdb36310d9c914c92d29135c0689 100644 (file)
@@ -220,9 +220,12 @@ static void bm_merge_dm_transform(BMesh *bm, DerivedMesh *dm, float mat[4][4],
                                   const char *dupe_slot_name,
                                   BMOperator *weld_op)
 {
-       BMVert *v, *v2;
+       BMVert *v, *v2, *v3;
        BMIter iter;
 
+       /* Add the DerivedMesh's elements to the BMesh. The pre-existing
+          elements were already tagged, so the new elements can be
+          identified by not having the BM_ELEM_TAG flag set. */
        DM_to_bmesh_ex(dm, bm);
 
        if (amd->flags & MOD_ARR_MERGE) {
@@ -252,6 +255,11 @@ static void bm_merge_dm_transform(BMesh *bm, DerivedMesh *dm, float mat[4][4],
                /* add new merge targets to weld operator */
                BMO_ITER (v, &oiter, bm, &find_op, "targetmapout", 0) {
                        v2 = BMO_iter_map_value_p(&oiter);
+                       /* check in case the target vertex (v2) is already marked
+                        * for merging */
+                       while ((v3 = BMO_slot_map_ptr_get(bm, weld_op, "targetmap", v2))) {
+                               v2 = v3;
+                       }
                        BMO_slot_map_ptr_insert(bm, weld_op, "targetmap", v, v2);
                }