diff options
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt_undo.c | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index 846801ae85d..e011e0f3c77 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -266,7 +266,8 @@ static int sculpt_undo_restore_mask(bContext *C, DerivedMesh *dm, SculptUndoNode return 1; } -static void sculpt_undo_bmesh_restore_generic(SculptUndoNode *unode, +static void sculpt_undo_bmesh_restore_generic(bContext *C, + SculptUndoNode *unode, Object *ob, SculptSession *ss) { @@ -279,9 +280,27 @@ static void sculpt_undo_bmesh_restore_generic(SculptUndoNode *unode, unode->applied = TRUE; } - /* A bit lame, but for now just recreate the PBVH. The alternative - * is to store changes to the PBVH in the undo stack. */ - sculpt_pbvh_clear(ob); + if (unode->type == SCULPT_UNDO_MASK) { + int i, totnode; + PBVHNode **nodes; + + #ifdef _OPENMP + Sculpt *sd = CTX_data_tool_settings(C)->sculpt; + #else + (void)C; + #endif + + BKE_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode); + + #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) + for (i = 0; i < totnode; i++) + BKE_pbvh_node_mark_redraw(nodes[i]); + } + else { + /* A bit lame, but for now just recreate the PBVH. The alternative + * is to store changes to the PBVH in the undo stack. */ + sculpt_pbvh_clear(ob); + } } /* Create empty sculpt BMesh and enable logging */ @@ -362,7 +381,7 @@ static int sculpt_undo_bmesh_restore(bContext *C, default: if (ss->bm_log) { - sculpt_undo_bmesh_restore_generic(unode, ob, ss); + sculpt_undo_bmesh_restore_generic(C, unode, ob, ss); return TRUE; } break; |