diff options
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt_undo.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index 67ef82aeaaf..bb463d29f1c 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -677,11 +677,18 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase } if (use_multires_undo) { - int max_grid; - unode = lb->first; - max_grid = unode->maxgrid; - undo_modified_grids = MEM_callocN(sizeof(char) * max_grid, "undo_grids"); for (unode = lb->first; unode; unode = unode->next) { + if (!STREQ(unode->idname, ob->id.name)) { + continue; + } + if (unode->maxgrid == 0) { + continue; + } + + if (undo_modified_grids == NULL) { + undo_modified_grids = MEM_callocN(sizeof(char) * unode->maxgrid, "undo_grids"); + } + for (int i = 0; i < unode->totgrid; i++) { undo_modified_grids[unode->grids[i]] = 1; } |