Fix T58310: Crash when removing multires modifier from sculpt object
authorSergey Sharybin <sergey.vfx@gmail.com>
Thu, 6 Dec 2018 14:20:16 +0000 (15:20 +0100)
committerSergey Sharybin <sergey.vfx@gmail.com>
Thu, 6 Dec 2018 14:22:21 +0000 (15:22 +0100)
source/blender/blenkernel/intern/multires_reshape.c
source/blender/blenkernel/intern/object.c

index 72be26177983d120436fd6e0d20aa3f8faf3df22..af3219ca06c45606d21a3988332f9f581e685112 100644 (file)
@@ -1163,6 +1163,11 @@ bool multiresModifier_reshapeFromCCG(
                return false;
        }
        MDisps *mdisps = CustomData_get_layer(&coarse_mesh->ldata, CD_MDISPS);
+       if (mdisps == NULL) {
+               /* Multires displacement has been removed before current changes were
+                * applies to all the levels. */
+               return false;
+       }
        GridPaintMask *grid_paint_mask =
                CustomData_get_layer(&coarse_mesh->ldata, CD_GRID_PAINT_MASK);
        Subdiv *subdiv = subdiv_ccg->subdiv;
index 3e2e890f54273694ecfa48c13316d4687fa2e0a4..694dae77bcdfdb9c674012df82936da93e6c9321 100644 (file)
@@ -425,6 +425,9 @@ static void object_update_from_subsurf_ccg(Object *object)
        Mesh *mesh_cow = object->runtime.mesh_orig;
        copy_ccg_data(mesh_cow, mesh_orig, CD_MDISPS);
        copy_ccg_data(mesh_cow, mesh_orig, CD_GRID_PAINT_MASK);
+       /* Everything is now up-to-date. */
+       subdiv_ccg->dirty.coords = false;
+       subdiv_ccg->dirty.hidden = false;
 }
 
 /* free data derived from mesh, called when mesh changes or is freed */