static float rna_PoseBone_do_envelope(bPoseChannel *chan, float *vec) { Bone *bone = chan->bone; float scale = (bone->flag & BONE_MULT_VG_ENV) == BONE_MULT_VG_ENV ? bone->weight : 1.0f; return distfactor_to_bone(vec, chan->pose_head, chan->pose_tail, bone->rad_head * scale, bone->rad_tail * scale, bone->dist * scale); }
static void envelope_bone_weighting(Object *ob, Mesh *mesh, float (*verts)[3], int numbones, Bone **bonelist, bDeformGroup **dgrouplist, bDeformGroup **dgroupflip, float (*root)[3], float (*tip)[3], const int *selected, float scale) { /* Create vertex group weights from envelopes */ Bone *bone; bDeformGroup *dgroup; 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++) { if (use_mask && !(mesh->mvert[i].flag & SELECT)) { continue; } iflip = (dgroupflip) ? mesh_get_x_mirror_vert(ob, NULL, i, use_topology) : -1; /* for each skinnable bone */ for (j = 0; j < numbones; ++j) { if (!selected[j]) continue; bone = bonelist[j]; dgroup = dgrouplist[j]; /* store the distance-factor from the vertex to the bone */ distance = distfactor_to_bone(verts[i], root[j], tip[j], bone->rad_head * scale, bone->rad_tail * scale, bone->dist * scale); /* add the vert to the deform group if (weight != 0.0) */ if (distance != 0.0f) ED_vgroup_vert_add(ob, dgroup, i, distance, WEIGHT_REPLACE); else ED_vgroup_vert_remove(ob, dgroup, i); /* do same for mirror */ if (dgroupflip && dgroupflip[j] && iflip != -1) { if (distance != 0.0f) ED_vgroup_vert_add(ob, dgroupflip[j], iflip, distance, WEIGHT_REPLACE); else ED_vgroup_vert_remove(ob, dgroupflip[j], iflip); } } } }
static float rna_Bone_do_envelope(Bone *bone, float *vec) { float scale = (bone->flag & BONE_MULT_VG_ENV) == BONE_MULT_VG_ENV ? bone->weight : 1.0f; return distfactor_to_bone(vec, bone->arm_head, bone->arm_tail, bone->rad_head * scale, bone->rad_tail * scale, bone->dist * scale); }