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
This commit is contained in:
@@ -200,10 +200,22 @@ static void envelope_bone_weighting(Object *ob, Mesh *mesh, float (*verts)[3], i
|
|||||||
float distance;
|
float distance;
|
||||||
int i, iflip, j;
|
int i, iflip, j;
|
||||||
bool use_topology = (mesh->editflag & ME_EDIT_MIRROR_TOPO) != 0;
|
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 each vertex in the mesh */
|
||||||
for (i = 0; i < mesh->totvert; i++) {
|
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 each skinnable bone */
|
||||||
for (j = 0; j < numbones; ++j) {
|
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);
|
ED_vgroup_vert_remove(ob, dgroup, i);
|
||||||
|
|
||||||
/* do same for mirror */
|
/* do same for mirror */
|
||||||
if (dgroupflip && dgroupflip[j] && iflip >= 0) {
|
if (dgroupflip && dgroupflip[j] && iflip != -1) {
|
||||||
if (distance != 0.0f)
|
if (distance != 0.0f)
|
||||||
ED_vgroup_vert_add(ob, dgroupflip[j], iflip, distance,
|
ED_vgroup_vert_add(ob, dgroupflip[j], iflip, distance,
|
||||||
WEIGHT_REPLACE);
|
WEIGHT_REPLACE);
|
||||||
|
@@ -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;
|
bool use_topology = (me->editflag & ME_EDIT_MIRROR_TOPO) != 0;
|
||||||
|
|
||||||
MVert *mvert = me->mvert;
|
MVert *mvert = me->mvert;
|
||||||
bool use_vert_sel = false;
|
bool use_vert_sel = (me->editflag & ME_EDIT_PAINT_VERT_SEL) != 0;
|
||||||
bool use_face_sel = false;
|
bool use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
|
||||||
|
|
||||||
*err_str = NULL;
|
*err_str = NULL;
|
||||||
|
|
||||||
@@ -652,9 +652,8 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* count triangles and create mask */
|
/* count triangles and create mask */
|
||||||
if (ob->mode == OB_MODE_WEIGHT_PAINT &&
|
if (ob->mode & OB_MODE_WEIGHT_PAINT &&
|
||||||
((use_face_sel = ((me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0)) ||
|
(use_face_sel || use_vert_sel))
|
||||||
(use_vert_sel = ((me->editflag & ME_EDIT_PAINT_VERT_SEL) != 0))))
|
|
||||||
{
|
{
|
||||||
mask = MEM_callocN(sizeof(int) * me->totvert, "heat_bone_weighting mask");
|
mask = MEM_callocN(sizeof(int) * me->totvert, "heat_bone_weighting mask");
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user