forked from bartvdbraak/blender
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!
This commit is contained in:
parent
d8d2dc552a
commit
c8cff5e1c4
@ -204,6 +204,17 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
|
|||||||
return dm;
|
return dm;
|
||||||
|
|
||||||
dvert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MDEFORMVERT, numVerts);
|
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. */
|
/* Get org weights, assuming 0.0 for vertices not in given vgroup. */
|
||||||
org_w = MEM_mallocN(sizeof(float) * numVerts, "WeightVGEdit Modifier, org_w");
|
org_w = MEM_mallocN(sizeof(float) * numVerts, "WeightVGEdit Modifier, org_w");
|
||||||
|
@ -251,6 +251,17 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
|
|||||||
}
|
}
|
||||||
|
|
||||||
dvert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MDEFORMVERT, numVerts);
|
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. */
|
/* Find out which vertices to work on. */
|
||||||
tidx = MEM_mallocN(sizeof(int) * numVerts, "WeightVGMix Modifier, tidx");
|
tidx = MEM_mallocN(sizeof(int) * numVerts, "WeightVGMix Modifier, tidx");
|
||||||
|
@ -378,6 +378,10 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
|
|||||||
return dm;
|
return dm;
|
||||||
|
|
||||||
dvert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MDEFORMVERT, numVerts);
|
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.
|
||||||
|
* As this modifier never add vertices to vgroup, just return. */
|
||||||
|
if(!dvert)
|
||||||
|
return dm;
|
||||||
|
|
||||||
/* Find out which vertices to work on (all vertices in vgroup), and get their relevant weight.
|
/* Find out which vertices to work on (all vertices in vgroup), and get their relevant weight.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user