diff options
Diffstat (limited to 'source/blender/modifiers')
-rw-r--r-- | source/blender/modifiers/intern/MOD_hook.c | 24 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_mask.c | 15 |
2 files changed, 17 insertions, 22 deletions
diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c index e04d5113364..a6eb9ab1e48 100644 --- a/source/blender/modifiers/intern/MOD_hook.c +++ b/source/blender/modifiers/intern/MOD_hook.c @@ -185,22 +185,20 @@ static void deformVerts_do(HookModifierData *hmd, Object *ob, DerivedMesh *dm, const float fac_orig= hmd->force; float fac; const int *origindex_ar; - - /* if DerivedMesh is present and has original index data, - * use it - */ + + /* if DerivedMesh is present and has original index data, use it */ if(dm && (origindex_ar= dm->getVertDataArray(dm, CD_ORIGINDEX))) { for(i= 0, index_pt= hmd->indexar; i < hmd->totindex; i++, index_pt++) { if(*index_pt < numVerts) { int j; - + for(j = 0; j < numVerts; j++) { if(origindex_ar[j] == *index_pt) { float *co = vertexCos[j]; if((fac= hook_falloff(hmd->cent, co, falloff_squared, fac_orig))) { if(dvert) fac *= defvert_find_weight(dvert+j, defgrp_index); - + if(fac) { mul_v3_m4v3(vec, mat, co); interp_v3_v3v3(co, co, vec, fac); @@ -218,7 +216,7 @@ static void deformVerts_do(HookModifierData *hmd, Object *ob, DerivedMesh *dm, if((fac= hook_falloff(hmd->cent, co, falloff_squared, fac_orig))) { if(dvert) fac *= defvert_find_weight(dvert+(*index_pt), defgrp_index); - + if(fac) { mul_v3_m4v3(vec, mat, co); interp_v3_v3v3(co, co, vec, fac); @@ -230,11 +228,11 @@ static void deformVerts_do(HookModifierData *hmd, Object *ob, DerivedMesh *dm, } else if(dvert) { /* vertex group hook */ const float fac_orig= hmd->force; - + for(i = 0; i < max_dvert; i++, dvert++) { float fac; float *co = vertexCos[i]; - + if((fac= hook_falloff(hmd->cent, co, falloff_squared, fac_orig))) { fac *= defvert_find_weight(dvert, defgrp_index); if(fac) { @@ -251,12 +249,8 @@ static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData, int UNUSED(useRenderParams), int UNUSED(isFinalCalc)) { HookModifierData *hmd = (HookModifierData*) md; - DerivedMesh *dm = get_dm(ob, NULL, derivedData, NULL, 0); - - deformVerts_do(hmd, ob, dm, vertexCos, numVerts); - - if(derivedData != dm) - dm->release(dm); + + deformVerts_do(hmd, ob, derivedData, vertexCos, numVerts); } static void deformVertsEM(ModifierData *md, Object *ob, struct BMEditMesh *editData, diff --git a/source/blender/modifiers/intern/MOD_mask.c b/source/blender/modifiers/intern/MOD_mask.c index 046eb0e5d03..cdb92ab432c 100644 --- a/source/blender/modifiers/intern/MOD_mask.c +++ b/source/blender/modifiers/intern/MOD_mask.c @@ -137,12 +137,13 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, bDeformGroup *def; char *bone_select_array; int bone_select_tot= 0; + const int defbase_tot= BLI_countlist(&ob->defbase); /* check that there is armature object with bones to use, otherwise return original mesh */ if (ELEM3(NULL, mmd->ob_arm, mmd->ob_arm->pose, ob->defbase.first)) return derivedData; - bone_select_array= MEM_mallocN(BLI_countlist(&ob->defbase) * sizeof(char), "mask array"); + bone_select_array= MEM_mallocN(defbase_tot * sizeof(char), "mask array"); for (i = 0, def = ob->defbase.first; def; def = def->next, i++) { @@ -194,12 +195,12 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, MDeformWeight *dw= dv->dw; int j; - for (j= dv->totweight; j > 0; j--, dw++) - { - if (bone_select_array[dw->def_nr]) - { - if(dw->weight != 0.0f) { - break; + for (j= dv->totweight; j > 0; j--, dw++) { + if (dw->def_nr < defbase_tot) { + if (bone_select_array[dw->def_nr]) { + if(dw->weight != 0.0f) { + break; + } } } } |