DataTransfer: Fix vertices being wrongly added to vgroup.
Previously, a vertex from destination mesh would always be added to all transferred vgroup (with a 0.0 weight), even if none of its matching sources in source mesh belonged to the matching source vgroups. Now a destination vertex is only added to a given destination vgroup if at least one of its source vertices belong to the matching source vgroup. Issue found and initial investigation by @pls in D11524, thanks!
This commit is contained in:
parent
b669fd376a
commit
5304c6ed7d
|
@ -1130,11 +1130,13 @@ static void vgroups_datatransfer_interp(const CustomDataTransferLayerMap *laymap
|
|||
MDeformWeight *dw_dst = BKE_defvert_find_index(data_dst, idx_dst);
|
||||
float weight_src = 0.0f, weight_dst = 0.0f;
|
||||
|
||||
bool has_dw_sources = false;
|
||||
if (sources) {
|
||||
for (i = count; i--;) {
|
||||
for (j = data_src[i]->totweight; j--;) {
|
||||
if ((dw_src = &data_src[i]->dw[j])->def_nr == idx_src) {
|
||||
weight_src += dw_src->weight * weights[i];
|
||||
has_dw_sources = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1152,7 +1154,14 @@ static void vgroups_datatransfer_interp(const CustomDataTransferLayerMap *laymap
|
|||
|
||||
CLAMP(weight_src, 0.0f, 1.0f);
|
||||
|
||||
if (!dw_dst) {
|
||||
/* Do not create a destination MDeformWeight data if we had no sources at all. */
|
||||
if (!has_dw_sources) {
|
||||
BLI_assert(weight_src == 0.0f);
|
||||
if (dw_dst) {
|
||||
dw_dst->weight = weight_src;
|
||||
}
|
||||
}
|
||||
else if (!dw_dst) {
|
||||
BKE_defvert_add_index_notest(data_dst, idx_dst, weight_src);
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Reference in New Issue