diff options
-rw-r--r-- | source/blender/blenkernel/intern/editderivedmesh.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c index 2fffa0dea28..5591ee2a0d4 100644 --- a/source/blender/blenkernel/intern/editderivedmesh.c +++ b/source/blender/blenkernel/intern/editderivedmesh.c @@ -2053,20 +2053,25 @@ static void *emDM_getTessFaceDataArray(DerivedMesh *dm, int type) /* layers are store per face for editmesh, we convert to a temporary * data layer array in the derivedmesh when these are requested */ if (type == CD_MTFACE || type == CD_MCOL) { - const int type_from = (type == CD_MTFACE) ? CD_MTEXPOLY : CD_MLOOPCOL; - int index; const char *bmdata; char *data; - index = CustomData_get_layer_index(&bm->pdata, type_from); + bool has_type_source = false; - if (index != -1) { + if (type == CD_MTFACE) { + has_type_source = CustomData_has_layer(&bm->pdata, CD_MTEXPOLY); + } + else { + has_type_source = CustomData_has_layer(&bm->ldata, CD_MLOOPCOL); + } + + if (has_type_source) { /* offset = bm->pdata.layers[index].offset; */ /* UNUSED */ BMLoop *(*looptris)[3] = bmdm->em->looptris; const int size = CustomData_sizeof(type); int i, j; DM_add_tessface_layer(dm, type, CD_CALLOC, NULL); - index = CustomData_get_layer_index(&dm->faceData, type); + const int index = CustomData_get_layer_index(&dm->faceData, type); dm->faceData.layers[index].flag |= CD_FLAG_TEMPORARY; data = datalayer = DM_get_tessface_data_layer(dm, type); |