Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/paint_vertex.c
| Show First 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | |||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_deform.h" | #include "BKE_deform.h" | ||||
| #include "BKE_mesh.h" | #include "BKE_mesh.h" | ||||
| #include "BKE_mesh_mapping.h" | #include "BKE_mesh_mapping.h" | ||||
| #include "BKE_object_deform.h" | #include "BKE_object_deform.h" | ||||
| #include "BKE_paint.h" | #include "BKE_paint.h" | ||||
| #include "BKE_report.h" | #include "BKE_report.h" | ||||
| #include "BKE_subsurf.h" | #include "BKE_subsurf.h" | ||||
| #include "BKE_workspace.h" | |||||
| #include "DEG_depsgraph.h" | #include "DEG_depsgraph.h" | ||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| #include "WM_types.h" | #include "WM_types.h" | ||||
| #include "ED_object.h" | #include "ED_object.h" | ||||
| #include "ED_mesh.h" | #include "ED_mesh.h" | ||||
| ▲ Show 20 Lines • Show All 958 Lines • ▼ Show 20 Lines | |||||
| /* *************** set wpaint operator ****************** */ | /* *************** set wpaint operator ****************** */ | ||||
| /** | /** | ||||
| * \note Keep in sync with #vpaint_mode_toggle_exec | * \note Keep in sync with #vpaint_mode_toggle_exec | ||||
| */ | */ | ||||
| static int wpaint_mode_toggle_exec(bContext *C, wmOperator *op) | static int wpaint_mode_toggle_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| 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_WEIGHT_PAINT; | const int mode_flag = OB_MODE_WEIGHT_PAINT; | ||||
| const bool is_mode_set = (ob->mode & mode_flag) != 0; | const bool is_mode_set = (ob->mode & mode_flag) != 0; | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| VPaint *wp = scene->toolsettings->wpaint; | VPaint *wp = scene->toolsettings->wpaint; | ||||
| Mesh *me; | Mesh *me; | ||||
| 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; | ||||
| } | } | ||||
| } | } | ||||
| me = BKE_mesh_from_object(ob); | me = BKE_mesh_from_object(ob); | ||||
| 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 (me->editflag & ME_EDIT_PAINT_VERT_SEL) { | if (me->editflag & ME_EDIT_PAINT_VERT_SEL) { | ||||
| BKE_mesh_flush_select_from_verts(me); | BKE_mesh_flush_select_from_verts(me); | ||||
| } | } | ||||
| else if (me->editflag & ME_EDIT_PAINT_FACE_SEL) { | else if (me->editflag & ME_EDIT_PAINT_FACE_SEL) { | ||||
| BKE_mesh_flush_select_from_polys(me); | BKE_mesh_flush_select_from_polys(me); | ||||
| } | } | ||||
| Show All 11 Lines | if (ob->mode & mode_flag) { | ||||
| paint_cursor_delete_textures(); | paint_cursor_delete_textures(); | ||||
| } | } | ||||
| else { | else { | ||||
| EvaluationContext eval_ctx; | EvaluationContext eval_ctx; | ||||
| CTX_data_eval_ctx(C, &eval_ctx); | CTX_data_eval_ctx(C, &eval_ctx); | ||||
| ob->mode |= mode_flag; | BKE_workspace_object_mode_for_object_set(workspace, scene, ob, ob->mode | mode_flag); | ||||
| if (wp == NULL) | if (wp == NULL) | ||||
| wp = scene->toolsettings->wpaint = new_vpaint(); | wp = scene->toolsettings->wpaint = new_vpaint(); | ||||
| paint_cursor_start(C, weight_paint_poll); | paint_cursor_start(C, weight_paint_poll); | ||||
| BKE_paint_init(scene, ePaintWeight, PAINT_CURSOR_WEIGHT_PAINT); | BKE_paint_init(scene, ePaintWeight, PAINT_CURSOR_WEIGHT_PAINT); | ||||
| ▲ Show 20 Lines • Show All 1,117 Lines • ▼ Show 20 Lines | |||||
| /* ************ set / clear vertex paint mode ********** */ | /* ************ set / clear vertex paint mode ********** */ | ||||
| /** | /** | ||||
| * \note Keep in sync with #wpaint_mode_toggle_exec | * \note Keep in sync with #wpaint_mode_toggle_exec | ||||
| */ | */ | ||||
| static int vpaint_mode_toggle_exec(bContext *C, wmOperator *op) | static int vpaint_mode_toggle_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| 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_VERTEX_PAINT; | const int mode_flag = OB_MODE_VERTEX_PAINT; | ||||
| const bool is_mode_set = (ob->mode & mode_flag) != 0; | const bool is_mode_set = (ob->mode & mode_flag) != 0; | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| VPaint *vp = scene->toolsettings->vpaint; | VPaint *vp = scene->toolsettings->vpaint; | ||||
| Mesh *me; | Mesh *me; | ||||
| 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; | ||||
| } | } | ||||
| } | } | ||||
| me = BKE_mesh_from_object(ob); | me = BKE_mesh_from_object(ob); | ||||
| /* toggle: end vpaint */ | /* toggle: end vpaint */ | ||||
| if (is_mode_set) { | if (is_mode_set) { | ||||
| ob->mode &= ~mode_flag; | BKE_workspace_object_mode_for_object_set(workspace, scene, ob, ob->mode & ~mode_flag); | ||||
| if (me->editflag & ME_EDIT_PAINT_FACE_SEL) { | if (me->editflag & ME_EDIT_PAINT_FACE_SEL) { | ||||
| BKE_mesh_flush_select_from_polys(me); | BKE_mesh_flush_select_from_polys(me); | ||||
| } | } | ||||
| else if (me->editflag & ME_EDIT_PAINT_VERT_SEL) { | else if (me->editflag & ME_EDIT_PAINT_VERT_SEL) { | ||||
| BKE_mesh_flush_select_from_verts(me); | BKE_mesh_flush_select_from_verts(me); | ||||
| } | } | ||||
| /* If the cache is not released by a cancel or a done, free it now. */ | /* If the cache is not released by a cancel or a done, free it now. */ | ||||
| if (ob->sculpt->cache) { | if (ob->sculpt->cache) { | ||||
| sculpt_cache_free(ob->sculpt->cache); | sculpt_cache_free(ob->sculpt->cache); | ||||
| ob->sculpt->cache = NULL; | ob->sculpt->cache = NULL; | ||||
| } | } | ||||
| BKE_sculptsession_free(ob); | BKE_sculptsession_free(ob); | ||||
| paint_cursor_delete_textures(); | paint_cursor_delete_textures(); | ||||
| } | } | ||||
| else { | else { | ||||
| EvaluationContext eval_ctx; | EvaluationContext eval_ctx; | ||||
| CTX_data_eval_ctx(C, &eval_ctx); | CTX_data_eval_ctx(C, &eval_ctx); | ||||
| ob->mode |= mode_flag; | BKE_workspace_object_mode_for_object_set(workspace, scene, ob, ob->mode | mode_flag); | ||||
| ED_mesh_color_ensure(me, NULL); | ED_mesh_color_ensure(me, NULL); | ||||
| if (vp == NULL) | if (vp == NULL) | ||||
| vp = scene->toolsettings->vpaint = new_vpaint(); | vp = scene->toolsettings->vpaint = new_vpaint(); | ||||
| paint_cursor_start(C, vertex_paint_poll); | paint_cursor_start(C, vertex_paint_poll); | ||||
| ▲ Show 20 Lines • Show All 866 Lines • Show Last 20 Lines | |||||