[Bf-blender-cvs] [5304c6ed7d6] master: DataTransfer: Fix vertices being wrongly added to vgroup.
Bastien Montagne
noreply at git.blender.org
Thu Jun 10 11:37:14 CEST 2021
Commit: 5304c6ed7d6288ac40bbc79391668c397e30afb8
Author: Bastien Montagne
Date: Thu Jun 10 11:33:53 2021 +0200
Branches: master
https://developer.blender.org/rB5304c6ed7d6288ac40bbc79391668c397e30afb8
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!
===================================================================
M source/blender/blenkernel/intern/deform.c
===================================================================
diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c
index 7832f3cd882..e6ef569d4b9 100644
--- a/source/blender/blenkernel/intern/deform.c
+++ b/source/blender/blenkernel/intern/deform.c
@@ -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 {
More information about the Bf-blender-cvs
mailing list