Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/paint_image.c
| Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | |||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_DerivedMesh.h" | #include "BKE_DerivedMesh.h" | ||||
| #include "BKE_brush.h" | #include "BKE_brush.h" | ||||
| #include "BKE_image.h" | #include "BKE_image.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_material.h" | #include "BKE_material.h" | ||||
| #include "BKE_node.h" | #include "BKE_node.h" | ||||
| #include "BKE_paint.h" | #include "BKE_paint.h" | ||||
| #include "BKE_workspace.h" | |||||
| #include "DEG_depsgraph.h" | #include "DEG_depsgraph.h" | ||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
| #include "UI_view2d.h" | #include "UI_view2d.h" | ||||
| #include "ED_image.h" | #include "ED_image.h" | ||||
| #include "ED_object.h" | #include "ED_object.h" | ||||
| ▲ Show 20 Lines • Show All 1,301 Lines • ▼ Show 20 Lines | static int texture_paint_toggle_poll(bContext *C) | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| static int texture_paint_toggle_exec(bContext *C, wmOperator *op) | static int texture_paint_toggle_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| Object *ob = CTX_data_active_object(C); | Object *ob = CTX_data_active_object(C); | ||||
| WorkSpace *workspace = CTX_wm_workspace(C); | |||||
| const int mode_flag = OB_MODE_TEXTURE_PAINT; | const int mode_flag = OB_MODE_TEXTURE_PAINT; | ||||
| const bool is_mode_set = (ob->mode & mode_flag) != 0; | const bool is_mode_set = (ob->mode & mode_flag) != 0; | ||||
| if (!is_mode_set) { | if (!is_mode_set) { | ||||
| if (!ED_object_mode_compat_set(C, ob, mode_flag, op->reports)) { | if (!ED_object_mode_compat_set(C, ob, mode_flag, op->reports)) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| } | } | ||||
| if (ob->mode & mode_flag) { | if (ob->mode & mode_flag) { | ||||
| ob->mode &= ~mode_flag; | BKE_workspace_object_mode_for_object_set(workspace, scene, ob, ob->mode & ~mode_flag); | ||||
| if (U.glreslimit != 0) | if (U.glreslimit != 0) | ||||
| GPU_free_images(); | GPU_free_images(); | ||||
| GPU_paint_set_mipmap(1); | GPU_paint_set_mipmap(1); | ||||
| toggle_paint_cursor(C, 0); | toggle_paint_cursor(C, 0); | ||||
| } | } | ||||
| else { | else { | ||||
| Show All 30 Lines | if (ima) { | ||||
| if (!sima->pin) | if (!sima->pin) | ||||
| ED_space_image_set(sima, scene, scene->obedit, ima); | ED_space_image_set(sima, scene, scene->obedit, ima); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ob->mode |= mode_flag; | BKE_workspace_object_mode_for_object_set(workspace, scene, ob, ob->mode | mode_flag); | ||||
| BKE_paint_init(scene, ePaintTextureProjective, PAINT_CURSOR_TEXTURE_PAINT); | BKE_paint_init(scene, ePaintTextureProjective, PAINT_CURSOR_TEXTURE_PAINT); | ||||
| if (U.glreslimit != 0) | if (U.glreslimit != 0) | ||||
| GPU_free_images(); | GPU_free_images(); | ||||
| GPU_paint_set_mipmap(0); | GPU_paint_set_mipmap(0); | ||||
| toggle_paint_cursor(C, 1); | toggle_paint_cursor(C, 1); | ||||
| ▲ Show 20 Lines • Show All 129 Lines • Show Last 20 Lines | |||||