diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2014-05-13 21:59:54 +0400 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2014-05-13 23:05:23 +0400 |
commit | 33df6aa12ea6f627b5b238e6eec64cffb2acdbd4 (patch) | |
tree | a2cd38a29091f349b9850e42ee59a4b3ce5600fb /source/blender/editors/sculpt_paint/sculpt_undo.c | |
parent | 9531091eb8ec4c8c7e62d727f962e19c334e7ef2 (diff) |
Fix T39196, Dynamic Topology Undo Applied to Wrong Mesh
Undoing nodes that do not belong to the current object will cause the
saved bmesh log entry to be reverted instead. This entry can belong to
another object though.
This is easy to fix by enforcing name matching (this was borrowed by
edit mode but can definitely be improved) between current object name
and undo node name and deleting older entries.
However there are complications. Deleting dyntopo entries in this way
can leave a brush stroke as first dyntopo log entry. This can present
issues if we attempt to delete that entry since it's deleted mesh
elements may now have had their ids (which would still be valid at the
time) cleaned up. This can result in crashing if we attempt to resculpt
on the mesh. To fix this I have disabled releasing the deleted entries.
This entanglement between bm_log and undo is quite volatile but I hope
the system works better now.
Also minor cleanup, fix unneeded check warning
Diffstat (limited to 'source/blender/editors/sculpt_paint/sculpt_undo.c')
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt_undo.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index 57e852db796..9beb11ec2f4 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -526,9 +526,11 @@ static void sculpt_undo_free(ListBase *lb) } if (unode->mask) MEM_freeN(unode->mask); + if (unode->bm_entry) { BM_log_entry_drop(unode->bm_entry); } + if (unode->bm_enter_totvert) CustomData_free(&unode->bm_enter_vdata, unode->bm_enter_totvert); if (unode->bm_enter_totedge) @@ -540,6 +542,24 @@ static void sculpt_undo_free(ListBase *lb) } } +bool sculpt_undo_cleanup(bContext *C, ListBase *lb) { + Object *ob = CTX_data_active_object(C); + SculptUndoNode *unode; + + unode = lb->first; + + if (strcmp(unode->idname, ob->id.name) != 0) { + for (unode = lb->first; unode; unode = unode->next) { + if (unode->bm_entry) + BM_log_cleanup_entry(unode->bm_entry); + } + + return true; + } + + return false; +} + SculptUndoNode *sculpt_undo_get_node(PBVHNode *node) { ListBase *lb = undo_paint_push_get_list(UNDO_PAINT_MESH); @@ -859,7 +879,7 @@ SculptUndoNode *sculpt_undo_push_node(Object *ob, PBVHNode *node, void sculpt_undo_push_begin(const char *name) { ED_undo_paint_push_begin(UNDO_PAINT_MESH, name, - sculpt_undo_restore, sculpt_undo_free); + sculpt_undo_restore, sculpt_undo_free); } void sculpt_undo_push_end(void) |