diff options
-rw-r--r-- | source/blender/blenkernel/intern/lattice.c | 22 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_vertex.c | 14 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_hook.c | 29 |
3 files changed, 28 insertions, 37 deletions
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 53fa7c14730..1954bac7e93 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -845,26 +845,20 @@ void lattice_deform_verts(Object *laOb, Object *target, DerivedMesh *dm, use_vgroups = 0; if(vgroup && vgroup[0] && use_vgroups) { - bDeformGroup *curdef; Mesh *me = target->data; - int index = 0; - - /* find the group (weak loop-in-loop) */ - for(curdef = target->defbase.first; curdef; - curdef = curdef->next, index++) - if(!strcmp(curdef->name, vgroup)) break; + int index = defgroup_name_index(target, vgroup); + float weight; - if(curdef && (me->dvert || dm)) { + if(index >= 0 && (me->dvert || dm)) { MDeformVert *dvert = me->dvert; - int j; for(a = 0; a < numVerts; a++, dvert++) { if(dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT); - for(j = 0; j < dvert->totweight; j++) { - if (dvert->dw[j].def_nr == index) { - calc_latt_deform(laOb, vertexCos[a], dvert->dw[j].weight); - } - } + + weight= defvert_find_weight(dvert, index); + + if(weight > 0.0f) + calc_latt_deform(laOb, vertexCos[a], weight); } } } else { diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 2650c2e278c..c1ef23e44a2 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -864,6 +864,7 @@ void sample_wpaint(Scene *scene, ARegion *ar, View3D *v3d, int mode) Mesh *me= get_mesh(ob); int index; short mval[2] = {0, 0}, sco[2]; + int vgroup= ob->actdef-1; if (!me) return; @@ -938,7 +939,6 @@ void sample_wpaint(Scene *scene, ARegion *ar, View3D *v3d, int mode) } else { DerivedMesh *dm; - MDeformWeight *dw; float w1, w2, w3, w4, co[3], fac; dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH); @@ -968,21 +968,17 @@ void sample_wpaint(Scene *scene, ARegion *ar, View3D *v3d, int mode) fac= MIN4(w1, w2, w3, w4); if(w1==fac) { - dw= defvert_find_index(me->dvert+mface->v1, ob->actdef-1); - if(dw) ts->vgroup_weight= dw->weight; else ts->vgroup_weight= 0.0f; + ts->vgroup_weight= defvert_find_weight(me->dvert+mface->v1, vgroup); } else if(w2==fac) { - dw= defvert_find_index(me->dvert+mface->v2, ob->actdef-1); - if(dw) ts->vgroup_weight= dw->weight; else ts->vgroup_weight= 0.0f; + ts->vgroup_weight= defvert_find_weight(me->dvert+mface->v2, vgroup); } else if(w3==fac) { - dw= defvert_find_index(me->dvert+mface->v3, ob->actdef-1); - if(dw) ts->vgroup_weight= dw->weight; else ts->vgroup_weight= 0.0f; + ts->vgroup_weight= defvert_find_weight(me->dvert+mface->v3, vgroup); } else if(w4==fac) { if(mface->v4) { - dw= defvert_find_index(me->dvert+mface->v4, ob->actdef-1); - if(dw) ts->vgroup_weight= dw->weight; else ts->vgroup_weight= 0.0f; + ts->vgroup_weight= defvert_find_weight(me->dvert+mface->v4, vgroup); } } } diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c index 6ca5e3ee83c..6715e2b78c0 100644 --- a/source/blender/modifiers/intern/MOD_hook.c +++ b/source/blender/modifiers/intern/MOD_hook.c @@ -214,25 +214,26 @@ static void deformVerts( if(defgrp_index >= 0 && use_dverts) { MDeformVert *dvert = me->dvert; - int i, j; + int i; + float fac; for(i = 0; i < maxVerts; i++, dvert++) { if(dm) dvert = dm->getVertData(dm, i, CD_MDEFORMVERT); - for(j = 0; j < dvert->totweight; j++) { - if(dvert->dw[j].def_nr == defgrp_index) { - float fac = hmd->force*dvert->dw[j].weight; - float *co = vertexCos[i]; - - if(hmd->falloff != 0.0) { - float len = len_v3v3(co, hmd->cent); - if(len > hmd->falloff) fac = 0.0; - else if(len > 0.0) - fac *= sqrt(1.0 - len / hmd->falloff); - } - mul_v3_m4v3(vec, mat, co); - interp_v3_v3v3(co, co, vec, fac); + fac= defvert_find_weight(dvert, defgrp_index); + + if(fac > 0.0f) { + float *co = vertexCos[i]; + + if(hmd->falloff != 0.0) { + float len = len_v3v3(co, hmd->cent); + if(len > hmd->falloff) fac = 0.0; + else if(len > 0.0) + fac *= sqrt(1.0 - len / hmd->falloff); } + + mul_v3_m4v3(vec, mat, co); + interp_v3_v3v3(co, co, vec, fac); } } } |