Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform_conversions.c
| Show First 20 Lines • Show All 2,455 Lines • ▼ Show 20 Lines | else if (t->mode == TFM_SHRINKFATTEN) { | ||||
| tx->isize[0] = BM_vert_calc_shell_factor_ex(eve, no, BM_ELEM_SELECT); | tx->isize[0] = BM_vert_calc_shell_factor_ex(eve, no, BM_ELEM_SELECT); | ||||
| } | } | ||||
| } | } | ||||
| static void createTransEditVerts(TransInfo *t) | static void createTransEditVerts(TransInfo *t) | ||||
| { | { | ||||
| TransData *tob = NULL; | TransData *tob = NULL; | ||||
| TransDataExtension *tx = NULL; | TransDataExtension *tx = NULL; | ||||
| BMEditMesh *em = BKE_editmesh_from_object(t->obedit); | const Mesh *me = t->obedit->data; | ||||
| Mesh *me = t->obedit->data; | |||||
| BMesh *bm = em->bm; | |||||
| BMVert *eve; | BMVert *eve; | ||||
| BMIter iter; | BMIter iter; | ||||
| #if 0 | |||||
| float (*mappedcos)[3] = NULL, (*quats)[4] = NULL; | float (*mappedcos)[3] = NULL, (*quats)[4] = NULL; | ||||
| float mtx[3][3], smtx[3][3], (*defmats)[3][3] = NULL, (*defcos)[3] = NULL; | #endif | ||||
| float mtx[3][3], smtx[3][3]; | |||||
| #if 0 | |||||
| float (*defmats)[3][3] = NULL, (*defcos)[3] = NULL; | |||||
| #endif | |||||
| float *dists = NULL; | float *dists = NULL; | ||||
| int a; | int a; | ||||
| const int prop_mode = (t->flag & T_PROP_EDIT) ? (t->flag & T_PROP_EDIT_ALL) : 0; | const int prop_mode = (t->flag & T_PROP_EDIT) ? (t->flag & T_PROP_EDIT_ALL) : 0; | ||||
| int mirror = 0; | int mirror = 0; | ||||
| int cd_vert_bweight_offset = -1; | int cd_vert_bweight_offset = -1; | ||||
| bool use_topology = (me->editflag & ME_EDIT_MIRROR_TOPO) != 0; | bool use_topology = (me->editflag & ME_EDIT_MIRROR_TOPO) != 0; | ||||
| #if 0 | |||||
| struct TransIslandData *island_info = NULL; | struct TransIslandData *island_info = NULL; | ||||
| int island_info_tot; | int island_info_tot; | ||||
| int *island_vert_map = NULL; | int *island_vert_map = NULL; | ||||
| #endif | |||||
| /* Even for translation this is needed because of island-orientation, see: T51651. */ | /* Even for translation this is needed because of island-orientation, see: T51651. */ | ||||
| const bool is_island_center = (t->around == V3D_AROUND_LOCAL_ORIGINS); | const bool is_island_center = (t->around == V3D_AROUND_LOCAL_ORIGINS); | ||||
| /* Original index of our connected vertex when connected distances are calculated. | /* Original index of our connected vertex when connected distances are calculated. | ||||
| * Optional, allocate if needed. */ | * Optional, allocate if needed. */ | ||||
| int *dists_index = NULL; | int *dists_index = NULL; | ||||
| if (t->flag & T_MIRROR) { | if (t->flag & T_MIRROR) { | ||||
| FOREACH_OBJECT_IN_EDIT_MODE_BEGIN (t->eval_ctx.view_layer, ob_iter) { | |||||
| BMEditMesh *em = BKE_editmesh_from_object(ob_iter); | |||||
| EDBM_verts_mirror_cache_begin(em, 0, false, (t->flag & T_PROP_EDIT) == 0, use_topology); | EDBM_verts_mirror_cache_begin(em, 0, false, (t->flag & T_PROP_EDIT) == 0, use_topology); | ||||
| } FOREACH_OBJECT_IN_EDIT_MODE_END; | |||||
| mirror = 1; | mirror = 1; | ||||
| } | } | ||||
| #if 0 | |||||
| FOREACH_OBJECT_IN_EDIT_MODE_BEGIN (t->eval_ctx.view_layer, ob_iter) { | |||||
| BMEditMesh *em = BKE_editmesh_from_object(ob_iter); | |||||
| BMesh *bm = em->bm; | |||||
| } FOREACH_OBJECT_IN_EDIT_MODE_END; | |||||
| #endif | |||||
| /** | /** | ||||
| * Quick check if we can transform. | * Quick check if we can transform. | ||||
| * | * | ||||
| * \note ignore modes here, even in edge/face modes, transform data is created by selected vertices. | * \note ignore modes here, even in edge/face modes, transform data is created by selected vertices. | ||||
| * \note in prop mode we need at least 1 selected. | * \note in prop mode we need at least 1 selected. | ||||
| */ | */ | ||||
| if (bm->totvertsel == 0) { | |||||
| int totvertsel_multi = 0; | |||||
| int select_mode = -1; | |||||
| { | |||||
| FOREACH_OBJECT_IN_EDIT_MODE_BEGIN (t->eval_ctx.view_layer, ob_iter) { | |||||
| BMEditMesh *em = BKE_editmesh_from_object(ob_iter); | |||||
| if (select_mode == -1) { | |||||
| select_mode = em->selectmode; | |||||
| } | |||||
| totvertsel_multi += em->bm->totvertsel; | |||||
| } FOREACH_OBJECT_IN_EDIT_MODE_END; | |||||
| if (totvertsel_multi == 0) { | |||||
| goto cleanup; | goto cleanup; | ||||
| } | } | ||||
| } | |||||
| if (t->mode == TFM_BWEIGHT) { | if (t->mode == TFM_BWEIGHT) { | ||||
| BM_mesh_cd_flag_ensure(bm, BKE_mesh_from_object(t->obedit), ME_CDFLAG_VERT_BWEIGHT); | FOREACH_OBJECT_IN_EDIT_MODE_BEGIN (t->eval_ctx.view_layer, ob_iter) { | ||||
| cd_vert_bweight_offset = CustomData_get_offset(&bm->vdata, CD_BWEIGHT); | BMEditMesh *em = BKE_editmesh_from_object(ob_iter); | ||||
| BMesh *bm = em->bm; | |||||
| BM_mesh_cd_flag_ensure(bm, BKE_mesh_from_object(ob_iter), ME_CDFLAG_VERT_BWEIGHT); | |||||
| } FOREACH_OBJECT_IN_EDIT_MODE_END; | |||||
| } | } | ||||
| if (prop_mode) { | if (prop_mode) { | ||||
| unsigned int count = 0; | unsigned int count = 0; | ||||
| unsigned int count_total = 0; | |||||
| FOREACH_OBJECT_IN_EDIT_MODE_BEGIN (t->eval_ctx.view_layer, ob_iter) { | |||||
| BMEditMesh *em = BKE_editmesh_from_object(ob_iter); | |||||
| BMesh *bm = em->bm; | |||||
| BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) { | BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) { | ||||
| if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) { | if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) { | ||||
| count++; | count++; | ||||
| } | } | ||||
| } | } | ||||
| count_total += bm->totvert; | |||||
| } FOREACH_OBJECT_IN_EDIT_MODE_END; | |||||
| t->total = count; | t->total = count; | ||||
| /* allocating scratch arrays */ | /* allocating scratch arrays */ | ||||
| if (prop_mode & T_PROP_CONNECTED) { | if (prop_mode & T_PROP_CONNECTED) { | ||||
| dists = MEM_mallocN(em->bm->totvert * sizeof(float), __func__); | dists = MEM_mallocN(count_total * sizeof(float), __func__); | ||||
| if (is_island_center) { | if (is_island_center) { | ||||
| dists_index = MEM_mallocN(em->bm->totvert * sizeof(int), __func__); | dists_index = MEM_mallocN(count_total * sizeof(int), __func__); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| t->total = bm->totvertsel; | t->total = totvertsel_multi; | ||||
| } | } | ||||
| tob = t->data = MEM_callocN(t->total * sizeof(TransData), "TransObData(Mesh EditMode)"); | tob = t->data = MEM_callocN(t->total * sizeof(TransData), "TransObData(Mesh EditMode)"); | ||||
| if (ELEM(t->mode, TFM_SKIN_RESIZE, TFM_SHRINKFATTEN)) { | if (ELEM(t->mode, TFM_SKIN_RESIZE, TFM_SHRINKFATTEN)) { | ||||
| /* warning, this is overkill, we only need 2 extra floats, | /* warning, this is overkill, we only need 2 extra floats, | ||||
| * but this stores loads of extra stuff, for TFM_SHRINKFATTEN its even more overkill | * but this stores loads of extra stuff, for TFM_SHRINKFATTEN its even more overkill | ||||
| * since we may not use the 'alt' transform mode to maintain shell thickness, | * since we may not use the 'alt' transform mode to maintain shell thickness, | ||||
| * but with generic transform code its hard to lazy init vars */ | * but with generic transform code its hard to lazy init vars */ | ||||
| tx = t->ext = MEM_callocN(t->total * sizeof(TransDataExtension), | tx = t->ext = MEM_callocN(t->total * sizeof(TransDataExtension), | ||||
| "TransObData ext"); | "TransObData ext"); | ||||
| } | } | ||||
| copy_m3_m4(mtx, t->obedit->obmat); | copy_m3_m4(mtx, t->obedit->obmat); | ||||
| /* we use a pseudoinverse so that when one of the axes is scaled to 0, | /* we use a pseudoinverse so that when one of the axes is scaled to 0, | ||||
| * matrix inversion still works and we can still moving along the other */ | * matrix inversion still works and we can still moving along the other */ | ||||
| pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON); | pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON); | ||||
| if (prop_mode & T_PROP_CONNECTED) { | if (prop_mode & T_PROP_CONNECTED) { | ||||
| FOREACH_OBJECT_IN_EDIT_MODE_BEGIN (t->eval_ctx.view_layer, ob_iter) { | |||||
| BMEditMesh *em = BKE_editmesh_from_object(ob_iter); | |||||
| editmesh_set_connectivity_distance(em->bm, mtx, dists, dists_index); | editmesh_set_connectivity_distance(em->bm, mtx, dists, dists_index); | ||||
| } FOREACH_OBJECT_IN_EDIT_MODE_END; | |||||
| } | } | ||||
| /* TODO */ | |||||
| (void)editmesh_islands_info_calc; | |||||
| # if 0 | |||||
| if (is_island_center) { | if (is_island_center) { | ||||
| /* In this specific case, near-by vertices will need to know the island of the nearest connected vertex. */ | /* In this specific case, near-by vertices will need to know the island of the nearest connected vertex. */ | ||||
| const bool calc_single_islands = ( | const bool calc_single_islands = ( | ||||
| (prop_mode & T_PROP_CONNECTED) && | (prop_mode & T_PROP_CONNECTED) && | ||||
| (t->around == V3D_AROUND_LOCAL_ORIGINS) && | (t->around == V3D_AROUND_LOCAL_ORIGINS) && | ||||
| (em->selectmode & SCE_SELECT_VERTEX)); | (select_mode & SCE_SELECT_VERTEX)); | ||||
| island_info = editmesh_islands_info_calc(em, &island_info_tot, &island_vert_map, calc_single_islands); | island_info = editmesh_islands_info_calc(em, &island_info_tot, &island_vert_map, calc_single_islands); | ||||
| } | } | ||||
| /* detect CrazySpace [tm] */ | /* detect CrazySpace [tm] */ | ||||
| if (modifiers_getCageIndex(t->scene, t->obedit, NULL, 1) != -1) { | if (modifiers_getCageIndex(t->scene, t->obedit, NULL, 1) != -1) { | ||||
| int totleft = -1; | int totleft = -1; | ||||
| if (modifiers_isCorrectableDeformed(&t->eval_ctx, t->scene, t->obedit)) { | if (modifiers_isCorrectableDeformed(&t->eval_ctx, t->scene, t->obedit)) { | ||||
| Show All 18 Lines | #endif | ||||
| if (mappedcos) | if (mappedcos) | ||||
| MEM_freeN(mappedcos); | MEM_freeN(mappedcos); | ||||
| } | } | ||||
| if (defcos) { | if (defcos) { | ||||
| MEM_freeN(defcos); | MEM_freeN(defcos); | ||||
| } | } | ||||
| } | } | ||||
| #endif /* XXX, TODO */ | |||||
| /* find out which half we do */ | /* find out which half we do */ | ||||
| if (mirror) { | if (mirror) { | ||||
| FOREACH_OBJECT_IN_EDIT_MODE_BEGIN (t->eval_ctx.view_layer, ob_iter) { | |||||
| BMEditMesh *em = BKE_editmesh_from_object(ob_iter); | |||||
| BMesh *bm = em->bm; | |||||
| BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) { | BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) { | ||||
| if (BM_elem_flag_test(eve, BM_ELEM_SELECT) && eve->co[0] != 0.0f) { | if (BM_elem_flag_test(eve, BM_ELEM_SELECT) && eve->co[0] != 0.0f) { | ||||
| if (eve->co[0] < 0.0f) { | if (eve->co[0] < 0.0f) { | ||||
| t->mirror = -1; | t->mirror = -1; | ||||
| mirror = -1; | mirror = -1; | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } FOREACH_OBJECT_IN_EDIT_MODE_END; | |||||
| } | } | ||||
| FOREACH_OBJECT_IN_EDIT_MODE_BEGIN (t->eval_ctx.view_layer, ob_iter) { | |||||
| BMEditMesh *em = BKE_editmesh_from_object(ob_iter); | |||||
| BMesh *bm = em->bm; | |||||
| cd_vert_bweight_offset = CustomData_get_offset(&bm->vdata, CD_BWEIGHT); | |||||
| 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)) { | ||||
| 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; | float *bweight = (cd_vert_bweight_offset != -1) ? BM_ELEM_CD_GET_VOID_P(eve, cd_vert_bweight_offset) : NULL; | ||||
| #if 0 | |||||
| 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]] : NULL; | &island_info[island_vert_map[connected_index]] : NULL; | ||||
| } | } | ||||
| #endif | |||||
| VertsToTransData(t, tob, tx, em, eve, bweight, v_island); | VertsToTransData(t, tob, tx, em, eve, bweight, v_island); | ||||
| if (tx) | if (tx) | ||||
| tx++; | tx++; | ||||
| /* selected */ | /* selected */ | ||||
| if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) | if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) | ||||
| tob->flag |= TD_SELECTED; | tob->flag |= TD_SELECTED; | ||||
| if (prop_mode) { | if (prop_mode) { | ||||
| if (prop_mode & T_PROP_CONNECTED) { | if (prop_mode & T_PROP_CONNECTED) { | ||||
| tob->dist = dists[a]; | tob->dist = dists[a]; | ||||
| } | } | ||||
| else { | else { | ||||
| tob->flag |= TD_NOTCONNECTED; | tob->flag |= TD_NOTCONNECTED; | ||||
| tob->dist = FLT_MAX; | tob->dist = FLT_MAX; | ||||
| } | } | ||||
| } | } | ||||
| #if 0 | |||||
| /* CrazySpace */ | /* CrazySpace */ | ||||
| if (defmats || (quats && BM_elem_flag_test(eve, BM_ELEM_TAG))) { | if (defmats || (quats && BM_elem_flag_test(eve, BM_ELEM_TAG))) { | ||||
| float mat[3][3], qmat[3][3], imat[3][3]; | float mat[3][3], qmat[3][3], imat[3][3]; | ||||
| /* use both or either quat and defmat correction */ | /* use both or either quat and defmat correction */ | ||||
| if (quats && BM_elem_flag_test(eve, BM_ELEM_TAG)) { | if (quats && BM_elem_flag_test(eve, BM_ELEM_TAG)) { | ||||
| quat_to_mat3(qmat, quats[BM_elem_index_get(eve)]); | quat_to_mat3(qmat, quats[BM_elem_index_get(eve)]); | ||||
| if (defmats) | if (defmats) | ||||
| mul_m3_series(mat, defmats[a], qmat, mtx); | mul_m3_series(mat, defmats[a], qmat, mtx); | ||||
| else | else | ||||
| mul_m3_m3m3(mat, mtx, qmat); | mul_m3_m3m3(mat, mtx, qmat); | ||||
| } | } | ||||
| else | else | ||||
| mul_m3_m3m3(mat, mtx, defmats[a]); | mul_m3_m3m3(mat, mtx, defmats[a]); | ||||
| invert_m3_m3(imat, mat); | invert_m3_m3(imat, mat); | ||||
| copy_m3_m3(tob->smtx, imat); | copy_m3_m3(tob->smtx, imat); | ||||
| copy_m3_m3(tob->mtx, mat); | copy_m3_m3(tob->mtx, mat); | ||||
| } | } | ||||
| else { | else | ||||
| #endif | |||||
| { | |||||
| copy_m3_m3(tob->smtx, smtx); | copy_m3_m3(tob->smtx, smtx); | ||||
| copy_m3_m3(tob->mtx, mtx); | copy_m3_m3(tob->mtx, mtx); | ||||
| } | } | ||||
| /* Mirror? */ | /* Mirror? */ | ||||
| if ((mirror > 0 && tob->iloc[0] > 0.0f) || (mirror < 0 && tob->iloc[0] < 0.0f)) { | if ((mirror > 0 && tob->iloc[0] > 0.0f) || (mirror < 0 && tob->iloc[0] < 0.0f)) { | ||||
| BMVert *vmir = EDBM_verts_mirror_get(em, eve); //t->obedit, em, eve, tob->iloc, a); | BMVert *vmir = EDBM_verts_mirror_get(em, eve); //t->obedit, em, eve, tob->iloc, a); | ||||
| if (vmir && vmir != eve) { | if (vmir && vmir != eve) { | ||||
| tob->extra = vmir; | tob->extra = vmir; | ||||
| } | } | ||||
| } | } | ||||
| tob++; | tob++; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* XXX, no indent, avoid diff noise */ | |||||
| } FOREACH_OBJECT_IN_EDIT_MODE_END; | |||||
| #if 0 | |||||
| if (island_info) { | if (island_info) { | ||||
| MEM_freeN(island_info); | MEM_freeN(island_info); | ||||
| MEM_freeN(island_vert_map); | MEM_freeN(island_vert_map); | ||||
| } | } | ||||
| #endif | |||||
| if (mirror != 0) { | if (mirror != 0) { | ||||
| tob = t->data; | tob = t->data; | ||||
| for (a = 0; a < t->total; a++, tob++) { | for (a = 0; a < t->total; a++, tob++) { | ||||
| if (ABS(tob->loc[0]) <= 0.00001f) { | if (ABS(tob->loc[0]) <= 0.00001f) { | ||||
| tob->flag |= TD_MIRROR_EDGE; | tob->flag |= TD_MIRROR_EDGE; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| cleanup: | cleanup: | ||||
| /* crazy space free */ | /* crazy space free */ | ||||
| #if 0 | |||||
| if (quats) | if (quats) | ||||
| MEM_freeN(quats); | MEM_freeN(quats); | ||||
| if (defmats) | if (defmats) | ||||
| MEM_freeN(defmats); | MEM_freeN(defmats); | ||||
| #endif | |||||
| if (dists) | if (dists) | ||||
| MEM_freeN(dists); | MEM_freeN(dists); | ||||
| if (dists_index) | if (dists_index) | ||||
| MEM_freeN(dists_index); | MEM_freeN(dists_index); | ||||
| if (t->flag & T_MIRROR) { | if (t->flag & T_MIRROR) { | ||||
| FOREACH_OBJECT_IN_EDIT_MODE_BEGIN (t->eval_ctx.view_layer, ob_iter) { | |||||
| BMEditMesh *em = BKE_editmesh_from_object(ob_iter); | |||||
| EDBM_verts_mirror_cache_end(em); | EDBM_verts_mirror_cache_end(em); | ||||
| } FOREACH_OBJECT_IN_EDIT_MODE_END; | |||||
| } | } | ||||
| } | } | ||||
| /* *** NODE EDITOR *** */ | /* *** NODE EDITOR *** */ | ||||
| void flushTransNodes(TransInfo *t) | void flushTransNodes(TransInfo *t) | ||||
| { | { | ||||
| const float dpi_fac = UI_DPI_FAC; | const float dpi_fac = UI_DPI_FAC; | ||||
| int a; | int a; | ||||
| ▲ Show 20 Lines • Show All 221 Lines • ▼ Show 20 Lines | |||||
| static void createTransUVs(bContext *C, TransInfo *t) | static void createTransUVs(bContext *C, TransInfo *t) | ||||
| { | { | ||||
| SpaceImage *sima = CTX_wm_space_image(C); | SpaceImage *sima = CTX_wm_space_image(C); | ||||
| Image *ima = CTX_data_edit_image(C); | Image *ima = CTX_data_edit_image(C); | ||||
| Scene *scene = t->scene; | Scene *scene = t->scene; | ||||
| ToolSettings *ts = CTX_data_tool_settings(C); | ToolSettings *ts = CTX_data_tool_settings(C); | ||||
| TransData *td = NULL; | TransData *td = NULL; | ||||
| TransData2D *td2d = NULL; | TransData2D *td2d = NULL; | ||||
| BMEditMesh *em = BKE_editmesh_from_object(t->obedit); | |||||
| BMFace *efa; | BMFace *efa; | ||||
| BMIter iter, liter; | BMIter iter, liter; | ||||
| UvElementMap *elementmap = NULL; | UvElementMap *elementmap = NULL; | ||||
| BLI_bitmap *island_enabled = NULL; | BLI_bitmap *island_enabled = NULL; | ||||
| struct { float co[2]; int co_num; } *island_center = NULL; | struct { float co[2]; int co_num; } *island_center = NULL; | ||||
| int count = 0, countsel = 0, count_rejected = 0; | int count = 0, countsel = 0, count_rejected = 0; | ||||
| const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0; | const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0; | ||||
| const bool is_prop_connected = (t->flag & T_PROP_CONNECTED) != 0; | const bool is_prop_connected = (t->flag & T_PROP_CONNECTED) != 0; | ||||
| const bool is_island_center = (t->around == V3D_AROUND_LOCAL_ORIGINS); | const bool is_island_center = (t->around == V3D_AROUND_LOCAL_ORIGINS); | ||||
| const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); | |||||
| if (!ED_space_image_show_uvedit(sima, t->obedit)) | if (!ED_space_image_show_uvedit(sima, t->obedit)) | ||||
| return; | return; | ||||
| /* count */ | /* count */ | ||||
| if (0) { | |||||
| BMEditMesh *em = BKE_editmesh_from_object(t->obedit); | |||||
| if (is_prop_connected || is_island_center) { | if (is_prop_connected || is_island_center) { | ||||
| /* create element map with island information */ | /* create element map with island information */ | ||||
| const bool use_facesel = (ts->uv_flag & UV_SYNC_SELECTION) == 0; | const bool use_facesel = (ts->uv_flag & UV_SYNC_SELECTION) == 0; | ||||
| elementmap = BM_uv_element_map_create(em->bm, use_facesel, false, true); | elementmap = BM_uv_element_map_create(em->bm, use_facesel, false, true); | ||||
| if (elementmap == NULL) { | if (elementmap == NULL) { | ||||
| return; | return; | ||||
| } | } | ||||
| if (is_prop_connected) { | if (is_prop_connected) { | ||||
| island_enabled = BLI_BITMAP_NEW(elementmap->totalIslands, "TransIslandData(UV Editing)"); | island_enabled = BLI_BITMAP_NEW(elementmap->totalIslands, "TransIslandData(UV Editing)"); | ||||
| } | } | ||||
| if (is_island_center) { | if (is_island_center) { | ||||
| island_center = MEM_callocN(sizeof(*island_center) * elementmap->totalIslands, __func__); | island_center = MEM_callocN(sizeof(*island_center) * elementmap->totalIslands, __func__); | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| FOREACH_OBJECT_IN_EDIT_MODE_BEGIN (t->eval_ctx.view_layer, ob_iter) { | |||||
| BMEditMesh *em = BKE_editmesh_from_object(ob_iter); | |||||
| const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); | |||||
| BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { | BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { | ||||
| BMLoop *l; | BMLoop *l; | ||||
| if (!uvedit_face_visible_test(scene, t->obedit, ima, efa)) { | if (!uvedit_face_visible_test(scene, t->obedit, ima, efa)) { | ||||
| BM_elem_flag_disable(efa, BM_ELEM_TAG); | BM_elem_flag_disable(efa, BM_ELEM_TAG); | ||||
| continue; | continue; | ||||
| } | } | ||||
| Show All 21 Lines | BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { | ||||
| } | } | ||||
| } | } | ||||
| if (is_prop_edit) { | if (is_prop_edit) { | ||||
| count++; | count++; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } FOREACH_OBJECT_IN_EDIT_MODE_END; | |||||
| /* note: in prop mode we need at least 1 selected */ | /* note: in prop mode we need at least 1 selected */ | ||||
| if (countsel == 0) { | if (countsel == 0) { | ||||
| goto finally; | goto finally; | ||||
| } | } | ||||
| if (is_island_center) { | if (is_island_center) { | ||||
| int i; | int i; | ||||
| Show All 11 Lines | static void createTransUVs(bContext *C, TransInfo *t) | ||||
| t->data2d = MEM_callocN(t->total * sizeof(TransData2D), "TransObData2D(UV Editing)"); | t->data2d = MEM_callocN(t->total * sizeof(TransData2D), "TransObData2D(UV Editing)"); | ||||
| if (sima->flag & SI_CLIP_UV) | if (sima->flag & SI_CLIP_UV) | ||||
| t->flag |= T_CLIP_UV; | t->flag |= T_CLIP_UV; | ||||
| td = t->data; | td = t->data; | ||||
| td2d = t->data2d; | td2d = t->data2d; | ||||
| FOREACH_OBJECT_IN_EDIT_MODE_BEGIN (t->eval_ctx.view_layer, ob_iter) { | |||||
| BMEditMesh *em = BKE_editmesh_from_object(ob_iter); | |||||
| const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); | |||||
| BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { | BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { | ||||
| BMLoop *l; | BMLoop *l; | ||||
| if (!BM_elem_flag_test(efa, BM_ELEM_TAG)) | if (!BM_elem_flag_test(efa, BM_ELEM_TAG)) | ||||
| continue; | continue; | ||||
| BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { | BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { | ||||
| const bool selected = uvedit_uv_select_test(scene, l, cd_loop_uv_offset); | const bool selected = uvedit_uv_select_test(scene, l, cd_loop_uv_offset); | ||||
| Show All 19 Lines | BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { | ||||
| } | } | ||||
| BM_elem_flag_enable(l, BM_ELEM_TAG); | BM_elem_flag_enable(l, BM_ELEM_TAG); | ||||
| luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); | luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); | ||||
| UVsToTransData(t->aspect, td++, td2d++, luv->uv, center, selected); | UVsToTransData(t->aspect, td++, td2d++, luv->uv, center, selected); | ||||
| } | } | ||||
| } | } | ||||
| } FOREACH_OBJECT_IN_EDIT_MODE_END; | |||||
| if (is_prop_connected) { | if (is_prop_connected) { | ||||
| t->total -= count_rejected; | t->total -= count_rejected; | ||||
| } | } | ||||
| if (sima->flag & SI_LIVE_UNWRAP) | if (sima->flag & SI_LIVE_UNWRAP) | ||||
| ED_uvedit_live_unwrap_begin(t->scene, t->obedit); | ED_uvedit_live_unwrap_begin(t->scene, t->obedit); | ||||
| ▲ Show 20 Lines • Show All 5,275 Lines • Show Last 20 Lines | |||||