diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2013-12-20 15:41:38 +0400 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2013-12-20 15:42:03 +0400 |
commit | 26aeb81d003278e30fc36255ba90ca81c3a655e6 (patch) | |
tree | 818e3f286636b4c3416ac714d86c0e65459c65e9 /source/blender/editors/sculpt_paint | |
parent | 59fd22e1d877f5e25f92b4f50e6f273c044df91e (diff) |
Slightly improve undo performance in dyntopo when last operator was mask
modification. In that case no pbvh needs to be freed and recreated and
we can get away just with draw buffer update (all of them for now. When
pbvh nodes get logged for undo we will be able to only update the
affected ones).
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-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; |