Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/uvedit/uvedit_unwrap_ops.c
| Show First 20 Lines • Show All 959 Lines • ▼ Show 20 Lines | static void uvedit_pack_islands(const Scene *scene, Object *ob, BMesh *bm) | ||||
| ParamHandle *handle; | ParamHandle *handle; | ||||
| handle = construct_param_handle(scene, ob, bm, &options); | handle = construct_param_handle(scene, ob, bm, &options); | ||||
| param_pack(handle, scene->toolsettings->uvcalc_margin, rotate, ignore_pinned); | param_pack(handle, scene->toolsettings->uvcalc_margin, rotate, ignore_pinned); | ||||
| param_flush(handle); | param_flush(handle); | ||||
| param_delete(handle); | param_delete(handle); | ||||
| } | } | ||||
| /** | |||||
| * \warning Since this uses #ParamHandle it doesn't work with non-manifold meshes (see T82637). | |||||
| * Use #ED_uvedit_pack_islands_multi for a more general solution. | |||||
| * | |||||
| * TODO: remove this function, in favor of #ED_uvedit_pack_islands_multi. | |||||
| */ | |||||
| static void uvedit_pack_islands_multi(const Scene *scene, | static void uvedit_pack_islands_multi(const Scene *scene, | ||||
| Object **objects, | Object **objects, | ||||
| const uint objects_len, | const uint objects_len, | ||||
| const UnwrapOptions *options, | const UnwrapOptions *options, | ||||
| bool rotate, | bool rotate, | ||||
| bool ignore_pinned) | bool ignore_pinned) | ||||
| { | { | ||||
| ParamHandle *handle; | ParamHandle *handle; | ||||
| Show All 18 Lines | const UnwrapOptions options = { | ||||
| .topology_from_uvs = true, | .topology_from_uvs = true, | ||||
| .only_selected_faces = true, | .only_selected_faces = true, | ||||
| .only_selected_uvs = true, | .only_selected_uvs = true, | ||||
| .fill_holes = false, | .fill_holes = false, | ||||
| .correct_aspect = true, | .correct_aspect = true, | ||||
| }; | }; | ||||
| bool rotate = RNA_boolean_get(op->ptr, "rotate"); | bool rotate = RNA_boolean_get(op->ptr, "rotate"); | ||||
| bool ignore_pinned = false; | |||||
| uint objects_len = 0; | uint objects_len = 0; | ||||
| Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs( | Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs( | ||||
| view_layer, CTX_wm_view3d(C), &objects_len); | view_layer, CTX_wm_view3d(C), &objects_len); | ||||
| if (!uvedit_have_selection_multi(scene, objects, objects_len, &options)) { | if (!uvedit_have_selection_multi(scene, objects, objects_len, &options)) { | ||||
| MEM_freeN(objects); | MEM_freeN(objects); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| if (RNA_struct_property_is_set(op->ptr, "margin")) { | if (RNA_struct_property_is_set(op->ptr, "margin")) { | ||||
| scene->toolsettings->uvcalc_margin = RNA_float_get(op->ptr, "margin"); | scene->toolsettings->uvcalc_margin = RNA_float_get(op->ptr, "margin"); | ||||
| } | } | ||||
| else { | else { | ||||
| RNA_float_set(op->ptr, "margin", scene->toolsettings->uvcalc_margin); | RNA_float_set(op->ptr, "margin", scene->toolsettings->uvcalc_margin); | ||||
| } | } | ||||
| uvedit_pack_islands_multi(scene, objects, objects_len, &options, rotate, ignore_pinned); | ED_uvedit_pack_islands_multi(scene, | ||||
| objects, | |||||
| objects_len, | |||||
| &(struct UVPackIsland_Params){ | |||||
| .rotate = rotate, | |||||
| .rotate_align_axis = -1, | |||||
| .only_selected_uvs = true, | |||||
| .only_selected_faces = true, | |||||
| .correct_aspect = true, | |||||
| }); | |||||
| MEM_freeN(objects); | MEM_freeN(objects); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void UV_OT_pack_islands(wmOperatorType *ot) | void UV_OT_pack_islands(wmOperatorType *ot) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 1,115 Lines • ▼ Show 20 Lines | static int smart_project_exec(bContext *C, wmOperator *op) | ||||
| BLI_memarena_free(arena); | BLI_memarena_free(arena); | ||||
| MEM_freeN(objects); | MEM_freeN(objects); | ||||
| /* Pack islands & Stretch to UV bounds */ | /* Pack islands & Stretch to UV bounds */ | ||||
| if (object_changed_len > 0) { | if (object_changed_len > 0) { | ||||
| scene->toolsettings->uvcalc_margin = island_margin; | scene->toolsettings->uvcalc_margin = island_margin; | ||||
| const UnwrapOptions options = { | |||||
| .topology_from_uvs = true, | |||||
| /* Even though the islands are defined by UV's, | |||||
| * split them by seams so users have control over the islands. */ | |||||
| .topology_from_uvs_use_seams = true, | |||||
| /* Depsgraph refresh functions are called here. */ | |||||
| ED_uvedit_pack_islands_multi(scene, | |||||
| objects_changed, | |||||
| object_changed_len, | |||||
| &(struct UVPackIsland_Params){ | |||||
| .rotate = true, | |||||
| /* We could make this optional. */ | |||||
| .rotate_align_axis = 1, | |||||
| .only_selected_faces = true, | .only_selected_faces = true, | ||||
| .only_selected_uvs = false, | .correct_aspect = true, | ||||
| .fill_holes = true, | }); | ||||
| .correct_aspect = false, | |||||
| }; | |||||
| /* Depsgraph refresh functions are called here. */ | |||||
| uvedit_pack_islands_multi(scene, objects_changed, object_changed_len, &options, true, false); | |||||
| uv_map_clip_correct_multi(objects_changed, object_changed_len, op); | uv_map_clip_correct_multi(objects_changed, object_changed_len, op); | ||||
| } | } | ||||
| MEM_freeN(objects_changed); | MEM_freeN(objects_changed); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 694 Lines • Show Last 20 Lines | |||||