Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/sculpt_undo.c
| Show First 20 Lines • Show All 480 Lines • ▼ Show 20 Lines | |||||
| static bool sculpt_undo_restore_face_sets(bContext *C, SculptUndoNode *unode) | static bool sculpt_undo_restore_face_sets(bContext *C, SculptUndoNode *unode) | ||||
| { | { | ||||
| const Scene *scene = CTX_data_scene(C); | const Scene *scene = CTX_data_scene(C); | ||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| BKE_view_layer_synced_ensure(scene, view_layer); | BKE_view_layer_synced_ensure(scene, view_layer); | ||||
| Object *ob = BKE_view_layer_active_object_get(view_layer); | Object *ob = BKE_view_layer_active_object_get(view_layer); | ||||
| Mesh *me = BKE_object_get_original_mesh(ob); | Mesh *me = BKE_object_get_original_mesh(ob); | ||||
| int *face_sets = CustomData_add_layer_named( | |||||
| int *face_sets = CustomData_get_layer_named(&me->pdata, CD_PROP_INT32, ".sculpt_face_set"); | |||||
| if (!face_sets) { | |||||
| face_sets = CustomData_add_layer_named( | |||||
| &me->pdata, CD_PROP_INT32, CD_CONSTRUCT, NULL, me->totpoly, ".sculpt_face_set"); | &me->pdata, CD_PROP_INT32, CD_CONSTRUCT, NULL, me->totpoly, ".sculpt_face_set"); | ||||
| } | |||||
| for (int i = 0; i < me->totpoly; i++) { | for (int i = 0; i < me->totpoly; i++) { | ||||
| SWAP(int, face_sets[i], unode->face_sets[i]); | SWAP(int, face_sets[i], unode->face_sets[i]); | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| static void sculpt_undo_bmesh_restore_generic_task_cb( | static void sculpt_undo_bmesh_restore_generic_task_cb( | ||||
| void *__restrict userdata, const int n, const TaskParallelTLS *__restrict UNUSED(tls)) | void *__restrict userdata, const int n, const TaskParallelTLS *__restrict UNUSED(tls)) | ||||
| ▲ Show 20 Lines • Show All 236 Lines • ▼ Show 20 Lines | static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase *lb) | ||||
| BKE_view_layer_synced_ensure(scene, view_layer); | BKE_view_layer_synced_ensure(scene, view_layer); | ||||
| Object *ob = BKE_view_layer_active_object_get(view_layer); | Object *ob = BKE_view_layer_active_object_get(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; | ||||
| bool need_refine_subdiv = false; | bool need_refine_subdiv = false; | ||||
| bool clear_automask_cache = false; | |||||
| for (unode = lb->first; unode; unode = unode->next) { | for (unode = lb->first; unode; unode = unode->next) { | ||||
| if (!ELEM(unode->type, SCULPT_UNDO_COLOR, SCULPT_UNDO_MASK)) { | |||||
| clear_automask_cache = true; | |||||
| } | |||||
| /* 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) | ||||
| * because of the vertex count. */ | * because of the vertex count. */ | ||||
| need_mask = true; | need_mask = true; | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (clear_automask_cache) { | |||||
| ss->last_automasking_settings_hash = 0; | |||||
| } | |||||
| DEG_id_tag_update(&ob->id, ID_RECALC_SHADING); | DEG_id_tag_update(&ob->id, ID_RECALC_SHADING); | ||||
| if (lb->first) { | if (lb->first) { | ||||
| unode = lb->first; | unode = lb->first; | ||||
| if (unode->type == SCULPT_UNDO_FACE_SETS) { | if (unode->type == SCULPT_UNDO_FACE_SETS) { | ||||
| sculpt_undo_restore_face_sets(C, unode); | sculpt_undo_restore_face_sets(C, unode); | ||||
| rebuild = true; | rebuild = true; | ||||
| ▲ Show 20 Lines • Show All 1,262 Lines • Show Last 20 Lines | |||||