Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/sculpt_dyntopo.c
| Show First 20 Lines • Show All 275 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| 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); | ||||
| SCULPT_dynamic_topology_disable_ex(bmain, depsgraph, scene, ob, unode); | SCULPT_dynamic_topology_disable_ex(bmain, depsgraph, scene, ob, unode); | ||||
| } | } | ||||
| void sculpt_dynamic_topology_disable_with_undo(Main *bmain, | void sculpt_dynamic_topology_disable_with_undo( | ||||
| Depsgraph *depsgraph, | bContext *C, Main *bmain, Depsgraph *depsgraph, Scene *scene, Object *ob) | ||||
| Scene *scene, | |||||
| Object *ob) | |||||
| { | { | ||||
| SculptSession *ss = ob->sculpt; | SculptSession *ss = ob->sculpt; | ||||
| if (ss->bm != NULL) { | if (ss->bm != NULL) { | ||||
| /* May be false in background mode. */ | /* May be false in background mode. */ | ||||
| const bool use_undo = G.background ? (ED_undo_stack_get() != NULL) : true; | const bool use_undo = G.background ? (ED_undo_stack_get() != NULL) : true; | ||||
| if (use_undo) { | if (use_undo) { | ||||
| SCULPT_undo_push_begin("Dynamic topology disable"); | SCULPT_undo_push_begin(NULL, "Dynamic topology disable"); | ||||
| SCULPT_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_END); | SCULPT_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_END); | ||||
| } | } | ||||
| SCULPT_dynamic_topology_disable_ex(bmain, depsgraph, scene, ob, NULL); | SCULPT_dynamic_topology_disable_ex(bmain, depsgraph, scene, ob, NULL); | ||||
| if (use_undo) { | if (use_undo) { | ||||
| SCULPT_undo_push_end(); | SCULPT_undo_push_end(NULL); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void sculpt_dynamic_topology_enable_with_undo(Main *bmain, | static void sculpt_dynamic_topology_enable_with_undo( | ||||
| Depsgraph *depsgraph, | bContext *C, Main *bmain, Depsgraph *depsgraph, Scene *scene, Object *ob) | ||||
| Scene *scene, | |||||
| Object *ob) | |||||
| { | { | ||||
| SculptSession *ss = ob->sculpt; | SculptSession *ss = ob->sculpt; | ||||
| if (ss->bm == NULL) { | if (ss->bm == NULL) { | ||||
| /* May be false in background mode. */ | /* May be false in background mode. */ | ||||
| const bool use_undo = G.background ? (ED_undo_stack_get() != NULL) : true; | const bool use_undo = G.background ? (ED_undo_stack_get() != NULL) : true; | ||||
| if (use_undo) { | if (use_undo) { | ||||
| SCULPT_undo_push_begin("Dynamic topology enable"); | SCULPT_undo_push_begin(C, "Dynamic topology enable"); | ||||
| } | } | ||||
| SCULPT_dynamic_topology_enable_ex(bmain, depsgraph, scene, ob); | SCULPT_dynamic_topology_enable_ex(bmain, depsgraph, scene, ob); | ||||
| if (use_undo) { | if (use_undo) { | ||||
| SCULPT_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_BEGIN); | SCULPT_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_BEGIN); | ||||
| SCULPT_undo_push_end(); | SCULPT_undo_push_end(C); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static int sculpt_dynamic_topology_toggle_exec(bContext *C, wmOperator *UNUSED(op)) | static int sculpt_dynamic_topology_toggle_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| 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); | ||||
| SculptSession *ss = ob->sculpt; | SculptSession *ss = ob->sculpt; | ||||
| WM_cursor_wait(true); | WM_cursor_wait(true); | ||||
| if (ss->bm) { | if (ss->bm) { | ||||
| sculpt_dynamic_topology_disable_with_undo(bmain, depsgraph, scene, ob); | sculpt_dynamic_topology_disable_with_undo(C, bmain, depsgraph, scene, ob); | ||||
| } | } | ||||
| else { | else { | ||||
| sculpt_dynamic_topology_enable_with_undo(bmain, depsgraph, scene, ob); | sculpt_dynamic_topology_enable_with_undo(C, bmain, depsgraph, scene, ob); | ||||
| } | } | ||||
| WM_cursor_wait(false); | WM_cursor_wait(false); | ||||
| WM_main_add_notifier(NC_SCENE | ND_TOOLSETTINGS, NULL); | WM_main_add_notifier(NC_SCENE | ND_TOOLSETTINGS, NULL); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 109 Lines • Show Last 20 Lines | |||||