Don't initialize CDDM with MFace from Meshes

Caused crash because MFace is no longer a layer which is added unless requested,
causing CDDM to have numTessFaceData nonzero, but mface set to NULL.
This commit is contained in:
Campbell Barton 2015-07-31 11:52:21 +10:00
parent 4d4c3b36a7
commit 6b7313be94
Notes: blender-bot 2023-02-14 08:49:50 +01:00
Referenced by issue #45633, New Depsgraph break Modifiers animatability
Referenced by issue #45624, Crash when switching from sculpt to object mode.
Referenced by issue #45612, Blender crashes when I change it to object-mode after having edited the object which multires modifier was set in sculpt-mode.
1 changed files with 6 additions and 2 deletions

View File

@ -2034,7 +2034,7 @@ DerivedMesh *CDDM_from_mesh(Mesh *mesh)
/* this does a referenced copy, with an exception for fluidsim */
DM_init(dm, DM_TYPE_CDDM, mesh->totvert, mesh->totedge, mesh->totface,
DM_init(dm, DM_TYPE_CDDM, mesh->totvert, mesh->totedge, 0 /* mesh->totface */,
mesh->totloop, mesh->totpoly);
dm->deformedOnly = 1;
@ -2047,7 +2047,7 @@ DerivedMesh *CDDM_from_mesh(Mesh *mesh)
CustomData_merge(&mesh->edata, &dm->edgeData, mask, alloctype,
mesh->totedge);
CustomData_merge(&mesh->fdata, &dm->faceData, mask | CD_MASK_ORIGINDEX, alloctype,
mesh->totface);
0 /* mesh->totface */);
CustomData_merge(&mesh->ldata, &dm->loopData, mask, alloctype,
mesh->totloop);
CustomData_merge(&mesh->pdata, &dm->polyData, mask, alloctype,
@ -2057,7 +2057,11 @@ DerivedMesh *CDDM_from_mesh(Mesh *mesh)
cddm->medge = CustomData_get_layer(&dm->edgeData, CD_MEDGE);
cddm->mloop = CustomData_get_layer(&dm->loopData, CD_MLOOP);
cddm->mpoly = CustomData_get_layer(&dm->polyData, CD_MPOLY);
#if 0
cddm->mface = CustomData_get_layer(&dm->faceData, CD_MFACE);
#else
cddm->mface = NULL;
#endif
/* commented since even when CD_ORIGINDEX was first added this line fails
* on the default cube, (after editmode toggle too) - campbell */