Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/sculpt_undo.c
| Show First 20 Lines • Show All 614 Lines • ▼ Show 20 Lines | static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase *lb) | ||||
| 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); | ||||
| 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, update_mask = false, update_visibility = false; | bool update = false, rebuild = false, update_mask = false, update_visibility = false; | ||||
| bool need_mask = false; | bool need_mask = false; | ||||
| SculptUpdateType update_type = SCULPT_UPDATE_COORDS; | |||||
| for (unode = lb->first; unode; unode = unode->next) { | for (unode = lb->first; unode; unode = unode->next) { | ||||
| /* Restore pivot. */ | /* Restore pivot. */ | ||||
| copy_v3_v3(ss->pivot_pos, unode->pivot_pos); | copy_v3_v3(ss->pivot_pos, unode->pivot_pos); | ||||
| copy_v3_v3(ss->pivot_rot, unode->pivot_rot); | copy_v3_v3(ss->pivot_rot, unode->pivot_rot); | ||||
| if (STREQ(unode->idname, ob->id.name)) { | if (STREQ(unode->idname, ob->id.name)) { | ||||
| if (unode->type == SCULPT_UNDO_MASK) { | if (unode->type == SCULPT_UNDO_MASK) { | ||||
| /* Is possible that we can't do the mask undo (below) | /* Is possible that we can't do the mask undo (below) | ||||
| ▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | else if (unode->maxgrid && subdiv_ccg != NULL) { | ||||
| use_multires_undo = true; | use_multires_undo = true; | ||||
| } | } | ||||
| switch (unode->type) { | switch (unode->type) { | ||||
| case SCULPT_UNDO_COORDS: | case SCULPT_UNDO_COORDS: | ||||
| if (sculpt_undo_restore_coords(C, depsgraph, unode)) { | if (sculpt_undo_restore_coords(C, depsgraph, unode)) { | ||||
| update = true; | update = true; | ||||
| update_type = SCULPT_UPDATE_COORDS; | |||||
| } | } | ||||
| break; | break; | ||||
| case SCULPT_UNDO_HIDDEN: | case SCULPT_UNDO_HIDDEN: | ||||
| if (sculpt_undo_restore_hidden(C, unode)) { | if (sculpt_undo_restore_hidden(C, unode)) { | ||||
| rebuild = true; | rebuild = true; | ||||
| update_visibility = true; | update_visibility = true; | ||||
| update_type = SCULPT_UPDATE_VISIBILITY; | |||||
| } | } | ||||
| break; | break; | ||||
| case SCULPT_UNDO_MASK: | case SCULPT_UNDO_MASK: | ||||
| if (sculpt_undo_restore_mask(C, unode)) { | if (sculpt_undo_restore_mask(C, unode)) { | ||||
| update = true; | update = true; | ||||
| update_mask = true; | update_mask = true; | ||||
| update_type = SCULPT_UPDATE_MASK; | |||||
| } | } | ||||
| break; | break; | ||||
| case SCULPT_UNDO_FACE_SETS: | case SCULPT_UNDO_FACE_SETS: | ||||
| update_type = SCULPT_UPDATE_VISIBILITY; | |||||
| break; | break; | ||||
| case SCULPT_UNDO_COLOR: | case SCULPT_UNDO_COLOR: | ||||
| if (sculpt_undo_restore_color(C, unode)) { | if (sculpt_undo_restore_color(C, unode)) { | ||||
| update_type = SCULPT_UPDATE_COLOR; | |||||
| update = true; | update = true; | ||||
| } | } | ||||
| break; | break; | ||||
| case SCULPT_UNDO_GEOMETRY: | case SCULPT_UNDO_GEOMETRY: | ||||
| sculpt_undo_geometry_restore(unode, ob); | sculpt_undo_geometry_restore(unode, ob); | ||||
| BKE_sculpt_update_object_for_edit(depsgraph, ob, false, need_mask, false); | BKE_sculpt_update_object_for_edit(depsgraph, ob, false, need_mask, false); | ||||
| update_type = SCULPT_UPDATE_COORDS; | |||||
| break; | break; | ||||
| case SCULPT_UNDO_DYNTOPO_BEGIN: | case SCULPT_UNDO_DYNTOPO_BEGIN: | ||||
| case SCULPT_UNDO_DYNTOPO_END: | case SCULPT_UNDO_DYNTOPO_END: | ||||
| case SCULPT_UNDO_DYNTOPO_SYMMETRIZE: | case SCULPT_UNDO_DYNTOPO_SYMMETRIZE: | ||||
| BLI_assert(!"Dynamic topology should've already been handled"); | BLI_assert(!"Dynamic topology should've already been handled"); | ||||
| break; | break; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | if (tag_update) { | ||||
| BKE_sculptsession_free_deformMats(ss); | BKE_sculptsession_free_deformMats(ss); | ||||
| } | } | ||||
| if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES && update_visibility) { | if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES && update_visibility) { | ||||
| Mesh *mesh = ob->data; | Mesh *mesh = ob->data; | ||||
| BKE_mesh_flush_hidden_from_verts(mesh); | BKE_mesh_flush_hidden_from_verts(mesh); | ||||
| } | } | ||||
| SCULPT_flush_update_done(C, ob, update_type); | |||||
| if (tag_update) { | if (tag_update) { | ||||
| DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); | DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); | ||||
| } | } | ||||
| else { | else { | ||||
| SCULPT_update_object_bounding_box(ob); | SCULPT_update_object_bounding_box(ob); | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 842 Lines • Show Last 20 Lines | |||||