From 5db1ae2605be382d2522422172e28a0aea57dada Mon Sep 17 00:00:00 2001 From: Germano Cavalcante Date: Sat, 20 Jun 2020 13:58:57 -0300 Subject: Cleanup: Remove goto in transform_convert_mesh code --- .../editors/transform/transform_convert_mesh.c | 73 +++++++++++----------- 1 file changed, 35 insertions(+), 38 deletions(-) (limited to 'source/blender/editors/transform') 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); } -- cgit v1.2.3