Sculpt Undo: Fix multires undo for interleaved nodes

Made it so grids array is properly allocated when first node in the
undo list does not contain grid data.

Differential Revision: https://developer.blender.org/D7299
This commit is contained in:
Sergey Sharybin 2020-03-27 16:54:28 +01:00
parent a9963669f9
commit 3ebebe62d7
1 changed files with 11 additions and 4 deletions

View File

@ -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;
}