Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/uvedit/uvedit_unwrap_ops.c
| Show First 20 Lines • Show All 2,740 Lines • ▼ Show 20 Lines | BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { | ||||
| if (use_select && !BM_elem_flag_test(efa, BM_ELEM_SELECT)) { | if (use_select && !BM_elem_flag_test(efa, BM_ELEM_SELECT)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| axis_dominant_v3(&cox, &coy, efa->no); | axis_dominant_v3(&cox, &coy, efa->no); | ||||
| BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { | BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { | ||||
| luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); | luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); | ||||
| luv->uv[0] = 0.5f + 0.5f * cube_size * (l->v->co[cox] - loc[cox]); | luv->uv[0] = 0.5f + cube_size * (l->v->co[cox] - loc[cox]); | ||||
| luv->uv[1] = 0.5f + 0.5f * cube_size * (l->v->co[coy] - loc[coy]); | luv->uv[1] = 0.5f + cube_size * (l->v->co[coy] - loc[coy]); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static int cube_project_exec(bContext *C, wmOperator *op) | static int cube_project_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| const Scene *scene = CTX_data_scene(C); | const Scene *scene = CTX_data_scene(C); | ||||
| View3D *v3d = CTX_wm_view3d(C); | View3D *v3d = CTX_wm_view3d(C); | ||||
| Show All 29 Lines | for (uint ob_index = 0; ob_index < objects_len; ob_index++) { | ||||
| uv_map_transform_center(scene, v3d, obedit, em, center, bounds_buf); | uv_map_transform_center(scene, v3d, obedit, em, center, bounds_buf); | ||||
| /* calculate based on bounds */ | /* calculate based on bounds */ | ||||
| float cube_size = cube_size_init; | float cube_size = cube_size_init; | ||||
| if (bounds_buf) { | if (bounds_buf) { | ||||
| float dims[3]; | float dims[3]; | ||||
| sub_v3_v3v3(dims, bounds[1], bounds[0]); | sub_v3_v3v3(dims, bounds[1], bounds[0]); | ||||
| cube_size = max_fff(UNPACK3(dims)); | cube_size = max_fff(UNPACK3(dims)); | ||||
| cube_size = cube_size ? 2.0f / cube_size : 1.0f; | cube_size = cube_size ? 1.0f / cube_size : 1.0f; | ||||
| if (ob_index == 0) { | if (ob_index == 0) { | ||||
| /* This doesn't fit well with, multiple objects. */ | /* This doesn't fit well with, multiple objects. */ | ||||
| RNA_property_float_set(op->ptr, prop_cube_size, cube_size); | RNA_property_float_set(op->ptr, prop_cube_size, cube_size); | ||||
| } | } | ||||
| } | } | ||||
| uvedit_unwrap_cube_project(em->bm, cube_size, true, center); | uvedit_unwrap_cube_project(em->bm, cube_size, true, center); | ||||
| ▲ Show 20 Lines • Show All 78 Lines • Show Last 20 Lines | |||||