Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/sculpt.c
| Show First 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | |||||
| #include "BKE_modifier.h" | #include "BKE_modifier.h" | ||||
| #include "BKE_multires.h" | #include "BKE_multires.h" | ||||
| #include "BKE_paint.h" | #include "BKE_paint.h" | ||||
| #include "BKE_report.h" | #include "BKE_report.h" | ||||
| #include "BKE_node.h" | #include "BKE_node.h" | ||||
| #include "BKE_object.h" | #include "BKE_object.h" | ||||
| #include "BKE_subsurf.h" | #include "BKE_subsurf.h" | ||||
| #include "BKE_colortools.h" | #include "BKE_colortools.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_sculpt.h" | #include "ED_sculpt.h" | ||||
| #include "ED_object.h" | #include "ED_object.h" | ||||
| ▲ Show 20 Lines • Show All 5,343 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| static int sculpt_mode_toggle_exec(bContext *C, wmOperator *op) | static int sculpt_mode_toggle_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| ToolSettings *ts = CTX_data_tool_settings(C); | ToolSettings *ts = CTX_data_tool_settings(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_SCULPT; | const int mode_flag = OB_MODE_SCULPT; | ||||
| const bool is_mode_set = (ob->mode & mode_flag) != 0; | const bool is_mode_set = (ob->mode & mode_flag) != 0; | ||||
| Mesh *me; | Mesh *me; | ||||
| MultiresModifierData *mmd = BKE_sculpt_multires_active(scene, ob); | MultiresModifierData *mmd = BKE_sculpt_multires_active(scene, ob); | ||||
| int flush_recalc = 0; | int flush_recalc = 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)) { | ||||
| Show All 25 Lines | if (me->flag & ME_SCULPT_DYNAMIC_TOPOLOGY) { | ||||
| * state */ | * state */ | ||||
| sculpt_dynamic_topology_toggle_exec(C, NULL); | sculpt_dynamic_topology_toggle_exec(C, NULL); | ||||
| /* store so we know to re-enable when entering sculpt mode */ | /* store so we know to re-enable when entering sculpt mode */ | ||||
| me->flag |= ME_SCULPT_DYNAMIC_TOPOLOGY; | me->flag |= ME_SCULPT_DYNAMIC_TOPOLOGY; | ||||
| } | } | ||||
| /* Leave sculptmode */ | /* Leave sculptmode */ | ||||
| ob->mode &= ~mode_flag; | BKE_workspace_object_mode_for_object_set(workspace, scene, ob, ob->mode & ~mode_flag); | ||||
| BKE_sculptsession_free(ob); | BKE_sculptsession_free(ob); | ||||
| paint_cursor_delete_textures(); | paint_cursor_delete_textures(); | ||||
| } | } | ||||
| else { | else { | ||||
| /* Enter sculptmode */ | /* Enter sculptmode */ | ||||
| ob->mode |= mode_flag; | BKE_workspace_object_mode_for_object_set(workspace, scene, ob, ob->mode | mode_flag); | ||||
| if (flush_recalc) | if (flush_recalc) | ||||
| DEG_id_tag_update(&ob->id, OB_RECALC_DATA); | DEG_id_tag_update(&ob->id, OB_RECALC_DATA); | ||||
| /* Create persistent sculpt mode data */ | /* Create persistent sculpt mode data */ | ||||
| if (!ts->sculpt) { | if (!ts->sculpt) { | ||||
| ts->sculpt = MEM_callocN(sizeof(Sculpt), "sculpt mode data"); | ts->sculpt = MEM_callocN(sizeof(Sculpt), "sculpt mode data"); | ||||
| ▲ Show 20 Lines • Show All 347 Lines • Show Last 20 Lines | |||||