From 3d98da9b0fcd9d1b61357656cdc448e495be14f2 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Mon, 28 May 2012 21:02:44 +0000 Subject: [PATCH] Fix for bug [#31613] Cycles 3d viewport material display mode + skin modifier related crash When in material display mode, mesh_calc_modifiers() calculates the orco DerivedMesh, which uses a different CustomDataMask. In particular, it does not necessarily include the current modifier's requiredDataMask, so those layers might get set to NO_COPY. For the skin modifier, this resulted in a crash when the modifier internally copies the DerivedMesh and the output does not contain the expected MVertSkin layer. Fixed by adding the requiredDataMask to the orco DM's CustomDataMask. Also added a debugging function to customdata.c: customData_mask_layers__print(CustomDataMask mask); This will print out the names of all the CD layer types in the mask. --- source/blender/blenkernel/intern/DerivedMesh.c | 4 +++- source/blender/blenkernel/intern/customdata.c | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 7e2d881689c..5774dd7b1ba 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -1651,7 +1651,9 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos orcodm = create_orco_dm(ob, me, NULL, CD_ORCO); nextmask &= ~CD_MASK_ORCO; - DM_set_only_copy(orcodm, nextmask | CD_MASK_ORIGINDEX); + DM_set_only_copy(orcodm, nextmask | CD_MASK_ORIGINDEX | + (mti->requiredDataMask ? + mti->requiredDataMask(ob, md) : 0)); ndm = mti->applyModifier(md, ob, orcodm, app_flags & ~MOD_APPLY_USECACHE); if (ndm) { diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 4e7653e2473..3802d532c5b 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -1193,6 +1193,17 @@ static const char *layerType_getName(int type) return LAYERTYPENAMES[type]; } +void customData_mask_layers__print(CustomDataMask mask) +{ + int i; + + printf("mask=0x%lx:\n", mask); + for (i = 0; i < CD_NUMTYPES; i++) { + if (mask & CD_TYPE_AS_MASK(i)) + printf(" %s\n", layerType_getName(i)); + } +} + /********************* CustomData functions *********************/ static void customData_update_offsets(CustomData *data);