Commit: a6eeeee4abeabeffcacbb4c69d43f349723bc387
Author: gaiaclary
Date:   Sat Jul 26 17:54:18 2014 +0200
Branches: master
https://developer.blender.org/rBa6eeeee4abeabeffcacbb4c69d43f349723bc387

Adding Mask select mode to Assign weights from Bone Heat (when called in Weight 
Paint mode)

Reviewers: campbellbarton

Differential Revision: https://developer.blender.org/D681

===================================================================

M       source/blender/editors/armature/armature_skinning.c
M       source/blender/editors/armature/meshlaplacian.c

===================================================================

diff --git a/source/blender/editors/armature/armature_skinning.c 
b/source/blender/editors/armature/armature_skinning.c
index e898e60..57ae03c 100644
--- a/source/blender/editors/armature/armature_skinning.c
+++ b/source/blender/editors/armature/armature_skinning.c
@@ -200,10 +200,22 @@ static void envelope_bone_weighting(Object *ob, Mesh 
*mesh, float (*verts)[3], i
        float distance;
        int i, iflip, j;
        bool use_topology = (mesh->editflag & ME_EDIT_MIRROR_TOPO) != 0;
+       bool use_mask = false;
+
+       if ((ob->mode & OB_MODE_WEIGHT_PAINT) &&
+           (mesh->editflag & (ME_EDIT_PAINT_FACE_SEL | 
ME_EDIT_PAINT_VERT_SEL)))
+       {
+               use_mask = true;
+       }
 
        /* for each vertex in the mesh */
        for (i = 0; i < mesh->totvert; i++) {
-               iflip = (dgroupflip) ? mesh_get_x_mirror_vert(ob, i, 
use_topology) : 0;
+
+               if (use_mask && !(mesh->mvert[i].flag & SELECT)) {
+                       continue;
+               }
+
+               iflip = (dgroupflip) ? mesh_get_x_mirror_vert(ob, i, 
use_topology) : -1;
                
                /* for each skinnable bone */
                for (j = 0; j < numbones; ++j) {
@@ -224,7 +236,7 @@ static void envelope_bone_weighting(Object *ob, Mesh *mesh, 
float (*verts)[3], i
                                ED_vgroup_vert_remove(ob, dgroup, i);
                        
                        /* do same for mirror */
-                       if (dgroupflip && dgroupflip[j] && iflip >= 0) {
+                       if (dgroupflip && dgroupflip[j] && iflip != -1) {
                                if (distance != 0.0f)
                                        ED_vgroup_vert_add(ob, dgroupflip[j], 
iflip, distance,
                                                           WEIGHT_REPLACE);
diff --git a/source/blender/editors/armature/meshlaplacian.c 
b/source/blender/editors/armature/meshlaplacian.c
index 56e7bde..49650fc 100644
--- a/source/blender/editors/armature/meshlaplacian.c
+++ b/source/blender/editors/armature/meshlaplacian.c
@@ -635,8 +635,8 @@ void heat_bone_weighting(Object *ob, Mesh *me, float 
(*verts)[3], int numsource,
        bool use_topology = (me->editflag & ME_EDIT_MIRROR_TOPO) != 0;
 
        MVert *mvert = me->mvert;
-       bool use_vert_sel = false;
-       bool use_face_sel = false;
+       bool use_vert_sel = (me->editflag & ME_EDIT_PAINT_VERT_SEL) != 0;
+       bool use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
 
        *err_str = NULL;
 
@@ -652,9 +652,8 @@ void heat_bone_weighting(Object *ob, Mesh *me, float 
(*verts)[3], int numsource,
                return;
 
        /* count triangles and create mask */
-       if (ob->mode == OB_MODE_WEIGHT_PAINT &&
-           ((use_face_sel = ((me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0)) ||
-            (use_vert_sel = ((me->editflag & ME_EDIT_PAINT_VERT_SEL) != 0))))
+       if (ob->mode & OB_MODE_WEIGHT_PAINT &&
+           (use_face_sel || use_vert_sel))
        {
                mask = MEM_callocN(sizeof(int) * me->totvert, 
"heat_bone_weighting mask");

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to