diff options
author | Antonioya <blendergit@gmail.com> | 2018-09-27 15:10:27 +0300 |
---|---|---|
committer | Antonioya <blendergit@gmail.com> | 2018-09-27 15:12:37 +0300 |
commit | f35cc54c11b6373b833215f906c92f011012dba8 (patch) | |
tree | f902550f3f005a1aff185f02a1d0ab6f18574777 /source | |
parent | 250a377592ca79d473700170f3be716e40cbedfd (diff) |
GP: Avoid duplicated weight deformation for strokes
If the point had several weights, the result could be wrongly accumulated.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/armature.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index a5eb49756bb..a2551eebd1d 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1153,7 +1153,7 @@ void armature_deform_verts(Object *armOb, Object *target, const Mesh * mesh, flo MDeformWeight *dw = dvert->dw; int deformed = 0; unsigned int j; - + float acum_weight = 0; for (j = dvert->totweight; j != 0; j--, dw++) { const int index = dw->def_nr; if (index >= 0 && index < defbase_tot && (pchan = defnrToPC[index])) { @@ -1167,7 +1167,21 @@ void armature_deform_verts(Object *armOb, Object *target, const Mesh * mesh, flo weight *= distfactor_to_bone(co, bone->arm_head, bone->arm_tail, bone->rad_head, bone->rad_tail, bone->dist); } + + /* check limit of weight */ + if (target->type == OB_GPENCIL) { + if (acum_weight + weight >= 1.0f) { + weight = 1.0f - acum_weight; + } + acum_weight += weight; + } + pchan_bone_deform(pchan, pdef_info, weight, vec, dq, smat, co, &contrib); + + /* if aumulated weight limit exceed, exit loop */ + if ((target->type == OB_GPENCIL) && (acum_weight >= 1.0f)) { + break; + } } } /* if there are vertexgroups but not groups with bones |