Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform_convert_mesh.c
| Show First 20 Lines • Show All 531 Lines • ▼ Show 20 Lines | if (mirror_elem_len != 0) { | ||||
| BM_ITER_MESH_INDEX (eve, &iter, bm, BM_VERTS_OF_MESH, i) { | BM_ITER_MESH_INDEX (eve, &iter, bm, BM_VERTS_OF_MESH, i) { | ||||
| int elem_index = BM_elem_index_get(eve); | int elem_index = BM_elem_index_get(eve); | ||||
| if (elem_index != -1) { | if (elem_index != -1) { | ||||
| BMVert *v_src = BM_vert_at_index(bm, elem_index); | BMVert *v_src = BM_vert_at_index(bm, elem_index); | ||||
| mirror_data_iter->loc_src = v_src->co; | mirror_data_iter->loc_src = v_src->co; | ||||
| mirror_data_iter->loc_dst = eve->co; | mirror_data_iter->loc_dst = eve->co; | ||||
| /* The center is calculated later. | |||||
| * zero_v3(mirror_data_iter->center); */ | |||||
| mirror_data_iter->sign_x = index[0] && index[0][i] == -2 ? -1 : 1; | mirror_data_iter->sign_x = index[0] && index[0][i] == -2 ? -1 : 1; | ||||
| mirror_data_iter->sign_y = index[1] && index[1][i] == -2 ? -1 : 1; | mirror_data_iter->sign_y = index[1] && index[1][i] == -2 ? -1 : 1; | ||||
| mirror_data_iter->sign_z = index[2] && index[2][i] == -2 ? -1 : 1; | mirror_data_iter->sign_z = index[2] && index[2][i] == -2 ? -1 : 1; | ||||
| mirror_data_iter->extra = eve; | mirror_data_iter->extra = eve; | ||||
| mirror_data_iter->flag = BM_elem_flag_test(eve, BM_ELEM_SELECT) ? TD_SELECTED : 0; | |||||
| mirror_data_iter++; | mirror_data_iter++; | ||||
| BLI_BITMAP_ENABLE(*r_mirror_bitmap, i); | BLI_BITMAP_ENABLE(*r_mirror_bitmap, i); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| MEM_SAFE_FREE(index[0]); | MEM_SAFE_FREE(index[0]); | ||||
| MEM_SAFE_FREE(index[1]); | MEM_SAFE_FREE(index[1]); | ||||
| MEM_SAFE_FREE(index[2]); | MEM_SAFE_FREE(index[2]); | ||||
| bm->elem_index_dirty |= BM_VERT; | bm->elem_index_dirty |= BM_VERT; | ||||
| *r_mirror_data_len = mirror_elem_len; | *r_mirror_data_len = mirror_elem_len; | ||||
| return mirror_data; | return mirror_data; | ||||
| } | } | ||||
| static void trans_data_center_calc(struct TransIslandData *v_island, | |||||
| const bool no_island_center, | |||||
| float orig_loc[3], | |||||
| float *r_center) | |||||
| { | |||||
| if (v_island && !no_island_center) { | |||||
| copy_v3_v3(r_center, v_island->co); | |||||
| } | |||||
| else { | |||||
| copy_v3_v3(r_center, orig_loc); | |||||
| } | |||||
| } | |||||
| /* way to overwrite what data is edited with transform */ | /* way to overwrite what data is edited with transform */ | ||||
| static void VertsToTransData(TransInfo *t, | static void VertsToTransData(TransInfo *t, | ||||
| TransData *td, | TransData *td, | ||||
| TransDataExtension *tx, | TransDataExtension *tx, | ||||
| BMEditMesh *em, | BMEditMesh *em, | ||||
| BMVert *eve, | BMVert *eve, | ||||
| float *bweight, | float *bweight, | ||||
| struct TransIslandData *v_island, | struct TransIslandData *v_island, | ||||
| Show All 13 Lines | if ((t->mode == TFM_SHRINKFATTEN) && (em->selectmode & SCE_SELECT_FACE) && | ||||
| BM_elem_flag_test(eve, BM_ELEM_SELECT) && | BM_elem_flag_test(eve, BM_ELEM_SELECT) && | ||||
| (BM_vert_calc_normal_ex(eve, BM_ELEM_SELECT, _no))) { | (BM_vert_calc_normal_ex(eve, BM_ELEM_SELECT, _no))) { | ||||
| no = _no; | no = _no; | ||||
| } | } | ||||
| else { | else { | ||||
| no = eve->no; | no = eve->no; | ||||
| } | } | ||||
| trans_data_center_calc(v_island, no_island_center, td->loc, td->center); | |||||
| if (v_island) { | if (v_island) { | ||||
| if (no_island_center) { | |||||
| copy_v3_v3(td->center, td->loc); | |||||
| } | |||||
| else { | |||||
| copy_v3_v3(td->center, v_island->co); | |||||
| } | |||||
| copy_m3_m3(td->axismtx, v_island->axismtx); | copy_m3_m3(td->axismtx, v_island->axismtx); | ||||
| } | } | ||||
| else if (t->around == V3D_AROUND_LOCAL_ORIGINS) { | else if (t->around == V3D_AROUND_LOCAL_ORIGINS) { | ||||
| copy_v3_v3(td->center, td->loc); | |||||
| createSpaceNormal(td->axismtx, no); | createSpaceNormal(td->axismtx, no); | ||||
| } | } | ||||
| else { | else { | ||||
| copy_v3_v3(td->center, td->loc); | |||||
| /* Setting normals */ | /* Setting normals */ | ||||
| copy_v3_v3(td->axismtx[2], no); | copy_v3_v3(td->axismtx[2], no); | ||||
| td->axismtx[0][0] = td->axismtx[0][1] = td->axismtx[0][2] = td->axismtx[1][0] = | td->axismtx[0][0] = td->axismtx[0][1] = td->axismtx[0][2] = td->axismtx[1][0] = | ||||
| td->axismtx[1][1] = td->axismtx[1][2] = 0.0f; | td->axismtx[1][1] = td->axismtx[1][2] = 0.0f; | ||||
| } | } | ||||
| td->ext = NULL; | td->ext = NULL; | ||||
| td->val = NULL; | td->val = NULL; | ||||
| ▲ Show 20 Lines • Show All 180 Lines • ▼ Show 20 Lines | #endif | ||||
| } | } | ||||
| } | } | ||||
| if (defcos) { | if (defcos) { | ||||
| MEM_freeN(defcos); | MEM_freeN(defcos); | ||||
| } | } | ||||
| } | } | ||||
| TransDataMirror *mirror_data_iter = tc->mirror.data; | |||||
| BM_ITER_MESH_INDEX (eve, &iter, bm, BM_VERTS_OF_MESH, a) { | BM_ITER_MESH_INDEX (eve, &iter, bm, BM_VERTS_OF_MESH, a) { | ||||
| if (BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) { | if (BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (mirror_bitmap && BLI_BITMAP_TEST(mirror_bitmap, a)) { | |||||
| continue; | |||||
| } | |||||
| if (prop_mode || BM_elem_flag_test(eve, BM_ELEM_SELECT)) { | if (prop_mode || BM_elem_flag_test(eve, BM_ELEM_SELECT)) { | ||||
| struct TransIslandData *v_island = NULL; | struct TransIslandData *v_island = NULL; | ||||
| float *bweight = (cd_vert_bweight_offset != -1) ? | |||||
| BM_ELEM_CD_GET_VOID_P(eve, cd_vert_bweight_offset) : | |||||
| NULL; | |||||
| if (island_info) { | if (island_info) { | ||||
| const int connected_index = (dists_index && dists_index[a] != -1) ? dists_index[a] : a; | const int connected_index = (dists_index && dists_index[a] != -1) ? dists_index[a] : a; | ||||
| v_island = (island_vert_map[connected_index] != -1) ? | v_island = (island_vert_map[connected_index] != -1) ? | ||||
| &island_info[island_vert_map[connected_index]] : | &island_info[island_vert_map[connected_index]] : | ||||
| NULL; | NULL; | ||||
| } | } | ||||
| if (mirror_bitmap && BLI_BITMAP_TEST(mirror_bitmap, a)) { | |||||
| trans_data_center_calc( | |||||
| v_island, is_snap_rotate, mirror_data_iter->loc_dst, mirror_data_iter->center); | |||||
| mirror_data_iter++; | |||||
| continue; | |||||
| } | |||||
| float *bweight = (cd_vert_bweight_offset != -1) ? | |||||
| BM_ELEM_CD_GET_VOID_P(eve, cd_vert_bweight_offset) : | |||||
| NULL; | |||||
| /* Do not use the island center in case we are using islands | /* Do not use the island center in case we are using islands | ||||
| * only to get axis for snap/rotate to normal... */ | * only to get axis for snap/rotate to normal... */ | ||||
| VertsToTransData(t, tob, tx, em, eve, bweight, v_island, is_snap_rotate); | VertsToTransData(t, tob, tx, em, eve, bweight, v_island, is_snap_rotate); | ||||
| if (tx) { | if (tx) { | ||||
| tx++; | tx++; | ||||
| } | } | ||||
| /* selected */ | /* selected */ | ||||
| ▲ Show 20 Lines • Show All 816 Lines • Show Last 20 Lines | |||||