forked from bartvdbraak/blender
fix [#29450] Mirror Vertex Groups issue
This commit is contained in:
parent
4afc0e80a7
commit
b202bf0564
@ -57,6 +57,7 @@ float defvert_find_weight(const struct MDeformVert *dvert, const int group_num)
|
||||
float defvert_array_find_weight_safe(const struct MDeformVert *dvert, int index, int group_num);
|
||||
|
||||
void defvert_copy(struct MDeformVert *dvert_r, const struct MDeformVert *dvert);
|
||||
void defvert_copy_index(struct MDeformVert *dv_dst, const struct MDeformVert *dv_src, const int defgroup);
|
||||
void defvert_sync(struct MDeformVert *dvert_r, const struct MDeformVert *dvert, int use_verify);
|
||||
void defvert_sync_mapped(struct MDeformVert *dvert_r, const struct MDeformVert *dvert, const int *flip_map, const int flip_map_len, const int use_verify);
|
||||
void defvert_remap (struct MDeformVert *dvert, int *map);
|
||||
|
@ -94,6 +94,31 @@ void defvert_copy (MDeformVert *dvert_r, const MDeformVert *dvert)
|
||||
}
|
||||
}
|
||||
|
||||
/* copy an index from one dvert to another
|
||||
* - do nothing if neither are set.
|
||||
* - add destination weight if needed.
|
||||
*/
|
||||
void defvert_copy_index (MDeformVert *dv_dst, const MDeformVert *dv_src, const int defgroup)
|
||||
{
|
||||
MDeformWeight *dw_src, *dw_dst;
|
||||
|
||||
dw_src= defvert_find_index(dv_src, defgroup);
|
||||
|
||||
if (dw_src) {
|
||||
/* source is valid, verify destination */
|
||||
dw_dst= defvert_verify_index(dv_dst, defgroup);
|
||||
dw_dst->weight= dw_src->weight;
|
||||
}
|
||||
else {
|
||||
/* source was NULL, assign zero, could also remove */
|
||||
dw_dst= defvert_find_index(dv_dst, defgroup);
|
||||
|
||||
if (dw_dst) {
|
||||
dw_dst->weight= 0.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* only sync over matching weights, don't add or remove groups
|
||||
* warning, loop within loop.
|
||||
*/
|
||||
|
@ -1576,13 +1576,21 @@ static void dvert_mirror_op(MDeformVert *dvert, MDeformVert *dvert_mirr,
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* dvert should always be the target */
|
||||
/* dvert should always be the target, only swaps pointer */
|
||||
if(sel_mirr) {
|
||||
SWAP(MDeformVert *, dvert, dvert_mirr);
|
||||
}
|
||||
|
||||
if(mirror_weights)
|
||||
defvert_copy(dvert, dvert_mirr);
|
||||
if(mirror_weights) {
|
||||
if (all_vgroups) {
|
||||
defvert_copy(dvert, dvert_mirr);
|
||||
}
|
||||
else {
|
||||
defvert_copy_index(dvert, dvert_mirr, act_vgroup);
|
||||
}
|
||||
}
|
||||
|
||||
/* flip map already modified for 'all_vgroups' */
|
||||
if(flip_vgroups) {
|
||||
defvert_flip(dvert, flip_map, flip_map_len);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user