Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/uvedit/uvedit_buttons.c
| Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | |||||
| /* UV Utilities */ | /* UV Utilities */ | ||||
| static int uvedit_center(Scene *scene, Object **objects, uint objects_len, float center[2]) | static int uvedit_center(Scene *scene, Object **objects, uint objects_len, float center[2]) | ||||
| { | { | ||||
| BMFace *f; | BMFace *f; | ||||
| BMLoop *l; | BMLoop *l; | ||||
| BMIter iter, liter; | BMIter iter, liter; | ||||
| MLoopUV *luv; | float *luv; | ||||
| int tot = 0; | int tot = 0; | ||||
| zero_v2(center); | zero_v2(center); | ||||
| for (uint ob_index = 0; ob_index < objects_len; ob_index++) { | for (uint ob_index = 0; ob_index < objects_len; ob_index++) { | ||||
| Object *obedit = objects[ob_index]; | Object *obedit = objects[ob_index]; | ||||
| BMEditMesh *em = BKE_editmesh_from_object(obedit); | BMEditMesh *em = BKE_editmesh_from_object(obedit); | ||||
| const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); | const BMUVOffsets offsets = BM_uv_map_get_offsets(em->bm); | ||||
| BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) { | BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) { | ||||
| if (!uvedit_face_visible_test(scene, f)) { | if (!uvedit_face_visible_test(scene, f)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { | BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { | ||||
| if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) { | if (uvedit_uv_select_test(scene, l, offsets)) { | ||||
| luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); | luv = BM_ELEM_CD_GET_FLOAT_P(l, offsets.uv); | ||||
| add_v2_v2(center, luv->uv); | add_v2_v2(center, luv); | ||||
| tot++; | tot++; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (tot > 0) { | if (tot > 0) { | ||||
| center[0] /= tot; | center[0] /= tot; | ||||
| center[1] /= tot; | center[1] /= tot; | ||||
| } | } | ||||
| return tot; | return tot; | ||||
| } | } | ||||
| static void uvedit_translate(Scene *scene, | static void uvedit_translate(Scene *scene, | ||||
| Object **objects, | Object **objects, | ||||
| uint objects_len, | uint objects_len, | ||||
| const float delta[2]) | const float delta[2]) | ||||
| { | { | ||||
| BMFace *f; | BMFace *f; | ||||
| BMLoop *l; | BMLoop *l; | ||||
| BMIter iter, liter; | BMIter iter, liter; | ||||
| MLoopUV *luv; | float *luv; | ||||
| for (uint ob_index = 0; ob_index < objects_len; ob_index++) { | for (uint ob_index = 0; ob_index < objects_len; ob_index++) { | ||||
| Object *obedit = objects[ob_index]; | Object *obedit = objects[ob_index]; | ||||
| BMEditMesh *em = BKE_editmesh_from_object(obedit); | BMEditMesh *em = BKE_editmesh_from_object(obedit); | ||||
| const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); | const BMUVOffsets offsets = BM_uv_map_get_offsets(em->bm); | ||||
| BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) { | BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) { | ||||
| if (!uvedit_face_visible_test(scene, f)) { | if (!uvedit_face_visible_test(scene, f)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { | BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { | ||||
| if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) { | if (uvedit_uv_select_test(scene, l, offsets)) { | ||||
| luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); | luv = BM_ELEM_CD_GET_FLOAT_P(l, offsets.uv); | ||||
| add_v2_v2(luv->uv, delta); | add_v2_v2(luv, delta); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* Button Functions, using an evil static variable */ | /* Button Functions, using an evil static variable */ | ||||
| ▲ Show 20 Lines • Show All 158 Lines • Show Last 20 Lines | |||||