diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2012-01-22 14:14:01 +0400 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2012-01-22 14:14:01 +0400 |
commit | c8cff5e1c4a8a5b61f11ee708460c994903f14e7 (patch) | |
tree | 58e6a713995939fcf4542e6e67ae05e1264f1123 /source/blender/modifiers/intern/MOD_weightvgmix.c | |
parent | d8d2dc552a47d521b1d8c93ce13d5216b31c72f0 (diff) |
Fix a crasher in WeightVG modifiers.
Problem was, if no vertices were ever added to one of the obect's vgroups, there is no CD_DEFORMVERT layer, even though there might be several valid vgroup indices... Odd no one noticed that earlier.
Many thanks to miikah for finding that bug!
Diffstat (limited to 'source/blender/modifiers/intern/MOD_weightvgmix.c')
-rw-r--r-- | source/blender/modifiers/intern/MOD_weightvgmix.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c index 17316d891da..28f9f503966 100644 --- a/source/blender/modifiers/intern/MOD_weightvgmix.c +++ b/source/blender/modifiers/intern/MOD_weightvgmix.c @@ -251,6 +251,17 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der } dvert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MDEFORMVERT, numVerts); + /* If no vertices were ever added to an object's vgroup, dvert might be NULL. */ + if(!dvert) + /* If not affecting all vertices, just return. */ + if(wmd->mix_set != MOD_WVG_SET_ALL) + return dm; + /* Else, add a valid data layer! */ + dvert = CustomData_add_layer_named(&dm->vertData, CD_MDEFORMVERT, CD_CALLOC, + NULL, numVerts, wmd->defgrp_name_a); + /* Ultimate security check. */ + if(!dvert) + return dm; /* Find out which vertices to work on. */ tidx = MEM_mallocN(sizeof(int) * numVerts, "WeightVGMix Modifier, tidx"); |