Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/sculpt_undo.c
| Show First 20 Lines • Show All 125 Lines • ▼ Show 20 Lines | else { | ||||
| return false; | return false; | ||||
| } | } | ||||
| } | } | ||||
| static bool sculpt_undo_restore_coords(bContext *C, SculptUndoNode *unode) | static bool sculpt_undo_restore_coords(bContext *C, SculptUndoNode *unode) | ||||
| { | { | ||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| Object *ob = OBACT(view_layer); | Object *ob = OBACT(view_layer); | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph(C); | |||||
| SculptSession *ss = ob->sculpt; | SculptSession *ss = ob->sculpt; | ||||
| SubdivCCG *subdiv_ccg = ss->subdiv_ccg; | SubdivCCG *subdiv_ccg = ss->subdiv_ccg; | ||||
| MVert *mvert; | MVert *mvert; | ||||
| int *index; | int *index; | ||||
| if (unode->maxvert) { | if (unode->maxvert) { | ||||
| /* regular mesh restore */ | /* regular mesh restore */ | ||||
| if (ss->kb && !STREQ(ss->kb->name, unode->shapeName)) { | if (ss->kb && !STREQ(ss->kb->name, unode->shapeName)) { | ||||
| /* shape key has been changed before calling undo operator */ | /* shape key has been changed before calling undo operator */ | ||||
| Key *key = BKE_key_from_object(ob); | Key *key = BKE_key_from_object(ob); | ||||
| KeyBlock *kb = key ? BKE_keyblock_find_name(key, unode->shapeName) : NULL; | KeyBlock *kb = key ? BKE_keyblock_find_name(key, unode->shapeName) : NULL; | ||||
| if (kb) { | if (kb) { | ||||
| ob->shapenr = BLI_findindex(&key->block, kb) + 1; | ob->shapenr = BLI_findindex(&key->block, kb) + 1; | ||||
| Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | |||||
brecht: I don't think depsgraph evaluation should ever happen in undo code? | |||||
sergeyAuthorUnsubmitted Done Inline ActionsWith the current code in BKE_sculpt_update_object_for_edit() this is unavoidable. sergey: With the current code in `BKE_sculpt_update_object_for_edit()` this is unavoidable. | |||||
| BKE_sculpt_update_object_for_edit(depsgraph, ob, false, false); | BKE_sculpt_update_object_for_edit(depsgraph, ob, false, false); | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_DATA, ob); | WM_event_add_notifier(C, NC_OBJECT | ND_DATA, ob); | ||||
| } | } | ||||
| else { | else { | ||||
| /* key has been removed -- skip this undo node */ | /* key has been removed -- skip this undo node */ | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 296 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| static void sculpt_undo_restore_list(bContext *C, ListBase *lb) | static void sculpt_undo_restore_list(bContext *C, ListBase *lb) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| View3D *v3d = CTX_wm_view3d(C); | View3D *v3d = CTX_wm_view3d(C); | ||||
| Object *ob = OBACT(view_layer); | Object *ob = OBACT(view_layer); | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph(C); | Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
brechtUnsubmitted Not Done Inline ActionsSame comment. brecht: Same comment. | |||||
sergeyAuthorUnsubmitted Done Inline ActionsSame answer. sergey: Same answer. | |||||
| SculptSession *ss = ob->sculpt; | SculptSession *ss = ob->sculpt; | ||||
| SubdivCCG *subdiv_ccg = ss->subdiv_ccg; | SubdivCCG *subdiv_ccg = ss->subdiv_ccg; | ||||
| SculptUndoNode *unode; | SculptUndoNode *unode; | ||||
| bool update = false, rebuild = false; | bool update = false, rebuild = false; | ||||
| bool need_mask = false; | bool need_mask = false; | ||||
| bool partial_update = true; | bool partial_update = true; | ||||
| for (unode = lb->first; unode; unode = unode->next) { | for (unode = lb->first; unode; unode = unode->next) { | ||||
| ▲ Show 20 Lines • Show All 642 Lines • ▼ Show 20 Lines | static void sculpt_undosys_step_decode( | ||||
| /* Ensure sculpt mode. */ | /* Ensure sculpt mode. */ | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| /* Sculpt needs evaluated state. */ | /* Sculpt needs evaluated state. */ | ||||
| BKE_scene_view_layer_graph_evaluated_ensure(bmain, scene, view_layer); | BKE_scene_view_layer_graph_evaluated_ensure(bmain, scene, view_layer); | ||||
| Object *ob = OBACT(view_layer); | Object *ob = OBACT(view_layer); | ||||
| if (ob && (ob->type == OB_MESH)) { | if (ob && (ob->type == OB_MESH)) { | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph(C); | |||||
| if (ob->mode & OB_MODE_SCULPT) { | if (ob->mode & OB_MODE_SCULPT) { | ||||
| /* pass */ | /* pass */ | ||||
| } | } | ||||
| else { | else { | ||||
| Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | |||||
brechtUnsubmitted Not Done Inline ActionsSame comment. brecht: Same comment. | |||||
sergeyAuthorUnsubmitted Done Inline ActionsSame answer (ED_object_sculptmode_enter_ex -> sculpt_init_session -> BKE_sculpt_update_object_for_edit). sergey: Same answer (`ED_object_sculptmode_enter_ex` -> `sculpt_init_session` ->… | |||||
| ED_object_mode_generic_exit(bmain, depsgraph, scene, ob); | ED_object_mode_generic_exit(bmain, depsgraph, scene, ob); | ||||
| Mesh *me = ob->data; | Mesh *me = ob->data; | ||||
| /* Don't add sculpt topology undo steps when reading back undo state. | /* Don't add sculpt topology undo steps when reading back undo state. | ||||
| * The undo steps must enter/exit for us. */ | * The undo steps must enter/exit for us. */ | ||||
| me->flag &= ~ME_SCULPT_DYNAMIC_TOPOLOGY; | me->flag &= ~ME_SCULPT_DYNAMIC_TOPOLOGY; | ||||
| ED_object_sculptmode_enter_ex(bmain, depsgraph, scene, ob, true, NULL); | ED_object_sculptmode_enter_ex(bmain, depsgraph, scene, ob, true, NULL); | ||||
| } | } | ||||
| BLI_assert(sculpt_undosys_poll(C)); | BLI_assert(sculpt_undosys_poll(C)); | ||||
| ▲ Show 20 Lines • Show All 57 Lines • Show Last 20 Lines | |||||
I don't think depsgraph evaluation should ever happen in undo code?