Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/paint_image_proj.c
| Show First 20 Lines • Show All 5,895 Lines • ▼ Show 20 Lines | void PAINT_OT_delete_texture_paint_slot(wmOperatorType *ot) | ||||
| /* flags */ | /* flags */ | ||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ||||
| } | } | ||||
| static int add_simple_uvs_exec(bContext *C, wmOperator *UNUSED(op)) | static int add_simple_uvs_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| { | { | ||||
| /* no checks here, poll function does them for us */ | /* no checks here, poll function does them for us */ | ||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | |||||
| Object *ob = CTX_data_active_object(C); | Object *ob = CTX_data_active_object(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| Mesh *me = ob->data; | Mesh *me = ob->data; | ||||
| bool synch_selection = (scene->toolsettings->uv_flag & UV_SYNC_SELECTION) != 0; | bool synch_selection = (scene->toolsettings->uv_flag & UV_SYNC_SELECTION) != 0; | ||||
| BMesh *bm = BM_mesh_create( | BMesh *bm = BM_mesh_create( | ||||
| &bm_mesh_allocsize_default, | &bm_mesh_allocsize_default, | ||||
| &((struct BMeshCreateParams){.use_toolflags = false,})); | &((struct BMeshCreateParams){.use_toolflags = false,})); | ||||
| /* turn synch selection off, since we are not in edit mode we need to ensure only the uv flags are tested */ | /* turn synch selection off, since we are not in edit mode we need to ensure only the uv flags are tested */ | ||||
| scene->toolsettings->uv_flag &= ~UV_SYNC_SELECTION; | scene->toolsettings->uv_flag &= ~UV_SYNC_SELECTION; | ||||
| ED_mesh_uv_texture_ensure(me, NULL); | ED_mesh_uv_texture_ensure(me, NULL); | ||||
| BM_mesh_bm_from_me( | BM_mesh_bm_from_me( | ||||
| bm, me, (&(struct BMeshFromMeshParams){ | bm, me, (&(struct BMeshFromMeshParams){ | ||||
| .calc_face_normal = true, | .calc_face_normal = true, | ||||
| })); | })); | ||||
| /* select all uv loops first - pack parameters needs this to make sure charts are registered */ | /* select all uv loops first - pack parameters needs this to make sure charts are registered */ | ||||
| ED_uvedit_select_all(bm); | ED_uvedit_select_all(bm); | ||||
| ED_uvedit_unwrap_cube_project(bm, 1.0, false, NULL); | ED_uvedit_unwrap_cube_project(bm, 1.0, false, NULL); | ||||
| /* set the margin really quickly before the packing operation*/ | /* set the margin really quickly before the packing operation*/ | ||||
| scene->toolsettings->uvcalc_margin = 0.001f; | scene->toolsettings->uvcalc_margin = 0.001f; | ||||
| ED_uvedit_pack_islands(scene, ob, bm, false, false, true); | ED_uvedit_pack_islands_multi(scene, view_layer, false, false, true); /* XXX, other code here isn't operating on all objects */ | ||||
| BM_mesh_bm_to_me(bm, me, (&(struct BMeshToMeshParams){0})); | BM_mesh_bm_to_me(bm, me, (&(struct BMeshToMeshParams){0})); | ||||
| BM_mesh_free(bm); | BM_mesh_free(bm); | ||||
| if (synch_selection) | if (synch_selection) | ||||
| scene->toolsettings->uv_flag |= UV_SYNC_SELECTION; | scene->toolsettings->uv_flag |= UV_SYNC_SELECTION; | ||||
| BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); | BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); | ||||
| Show All 31 Lines | |||||