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_weightvgedit.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_weightvgedit.c')
-rw-r--r-- | source/blender/modifiers/intern/MOD_weightvgedit.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c index bdd7ab7486b..e090ad78e59 100644 --- a/source/blender/modifiers/intern/MOD_weightvgedit.c +++ b/source/blender/modifiers/intern/MOD_weightvgedit.c @@ -204,6 +204,17 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der return dm; 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 this modifier is not allowed to add vertices, just return. */ + if(!do_add) + return dm; + /* Else, add a valid data layer! */ + dvert = CustomData_add_layer_named(&dm->vertData, CD_MDEFORMVERT, CD_CALLOC, + NULL, numVerts, wmd->defgrp_name); + /* Ultimate security check. */ + if(!dvert) + return dm; /* Get org weights, assuming 0.0 for vertices not in given vgroup. */ org_w = MEM_mallocN(sizeof(float) * numVerts, "WeightVGEdit Modifier, org_w"); |