[Bf-blender-cvs] [5db1ae2605b] master: Cleanup: Remove goto in transform_convert_mesh code

Germano Cavalcante noreply at git.blender.org
Mon Jun 22 12:56:19 CEST 2020


Commit: 5db1ae2605be382d2522422172e28a0aea57dada
Author: Germano Cavalcante
Date:   Sat Jun 20 13:58:57 2020 -0300
Branches: master
https://developer.blender.org/rB5db1ae2605be382d2522422172e28a0aea57dada

Cleanup: Remove goto in transform_convert_mesh code

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

M	source/blender/editors/transform/transform_convert_mesh.c

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

diff --git a/source/blender/editors/transform/transform_convert_mesh.c b/source/blender/editors/transform/transform_convert_mesh.c
index 0fb47810f63..61e705558c5 100644
--- a/source/blender/editors/transform/transform_convert_mesh.c
+++ b/source/blender/editors/transform/transform_convert_mesh.c
@@ -705,6 +705,34 @@ void createTransEditVerts(TransInfo *t)
 
     struct TransIslandData island_data = {NULL};
 
+    /**
+     * Quick check if we can transform.
+     *
+     * \note ignore modes here, even in edge/face modes,
+     * transform data is created by selected vertices.
+     */
+
+    /* Support other objects using PET to adjust these, unless connected is enabled. */
+    if ((!prop_mode || (prop_mode & T_PROP_CONNECTED)) && (bm->totvertsel == 0)) {
+      continue;
+    }
+
+    int data_len = 0;
+    if (prop_mode) {
+      BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
+        if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
+          data_len++;
+        }
+      }
+    }
+    else {
+      data_len = bm->totvertsel;
+    }
+
+    if (data_len == 0) {
+      continue;
+    }
+
     /* Snap rotation along normal needs a common axis for whole islands,
      * otherwise one get random crazy results, see T59104.
      * However, we do not want to use the island center for the pivot/translation reference. */
@@ -714,26 +742,16 @@ void createTransEditVerts(TransInfo *t)
                                  (usingSnappingNormal(t) ||
                                   (t->settings->snap_flag & SCE_SNAP_ROTATE) != 0) &&
                                  (t->around != V3D_AROUND_LOCAL_ORIGINS));
+
     /* Even for translation this is needed because of island-orientation, see: T51651. */
     const bool is_island_center = (t->around == V3D_AROUND_LOCAL_ORIGINS) || is_snap_rotate;
+
     /* Original index of our connected vertex when connected distances are calculated.
      * Optional, allocate if needed. */
     int *dists_index = NULL;
 
     BLI_bitmap *mirror_bitmap = NULL;
 
-    /**
-     * Quick check if we can transform.
-     *
-     * \note ignore modes here, even in edge/face modes,
-     * transform data is created by selected vertices.
-     */
-
-    /* Support other objects using PET to adjust these, unless connected is enabled. */
-    if ((!prop_mode || (prop_mode & T_PROP_CONNECTED)) && (bm->totvertsel == 0)) {
-      goto cleanup;
-    }
-
     if (t->mode == TFM_BWEIGHT) {
       BM_mesh_cd_flag_ensure(bm, BKE_mesh_from_object(tc->obedit), ME_CDFLAG_VERT_BWEIGHT);
       cd_vert_bweight_offset = CustomData_get_offset(&bm->vdata, CD_BWEIGHT);
@@ -747,29 +765,13 @@ void createTransEditVerts(TransInfo *t)
           em, use_select, use_topology, mirror_axis, &tc->data_mirror_len, &mirror_bitmap);
     }
 
-    int data_len = 0;
-    if (prop_mode) {
-      BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
-        if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
-          data_len++;
-        }
-      }
-
-      if (data_len == 0) {
-        goto cleanup;
-      }
-
-      /* allocating scratch arrays */
-      if (prop_mode & T_PROP_CONNECTED) {
-        dists = MEM_mallocN(em->bm->totvert * sizeof(float), __func__);
-        if (is_island_center) {
-          dists_index = MEM_mallocN(em->bm->totvert * sizeof(int), __func__);
-        }
+    /* allocating scratch arrays */
+    if (prop_mode & T_PROP_CONNECTED) {
+      dists = MEM_mallocN(bm->totvert * sizeof(float), __func__);
+      if (is_island_center) {
+        dists_index = MEM_mallocN(bm->totvert * sizeof(int), __func__);
       }
     }
-    else {
-      data_len = bm->totvertsel;
-    }
 
     if (mirror_bitmap) {
       BM_ITER_MESH_INDEX (eve, &iter, bm, BM_VERTS_OF_MESH, a) {
@@ -953,17 +955,12 @@ void createTransEditVerts(TransInfo *t)
     if (island_data.center) {
       MEM_freeN(island_data.center);
     }
-
     if (island_data.axismtx) {
       MEM_freeN(island_data.axismtx);
     }
-
     if (island_data.island_vert_map) {
       MEM_freeN(island_data.island_vert_map);
     }
-
-  cleanup:
-    /* crazy space free */
     if (quats) {
       MEM_freeN(quats);
     }



More information about the Bf-blender-cvs mailing list