Fix T84757: feedback loop with when modifying vertex group with nodes

The issue was that the mesh shared its vertex weights with the
original mesh (to reduce memory consumption). The solution is
to make a local copy of the vertex weights in this case.
This commit is contained in:
Jacques Lucke 2021-01-16 15:24:22 +01:00
parent f7829961c6
commit 1e193a0b56
Notes: blender-bot 2023-02-14 02:08:37 +01:00
Referenced by issue #84757,  feedback loops occuring with Geonode Modifier when working with vertex-group attr
1 changed files with 5 additions and 0 deletions

View File

@ -1191,6 +1191,11 @@ WriteAttributePtr MeshComponent::attribute_try_get_for_write(const StringRef att
if (mesh_->dvert == nullptr) {
BKE_object_defgroup_data_create(&mesh_->id);
}
else {
/* Copy the data layer if it is shared with some other mesh. */
mesh_->dvert = (MDeformVert *)CustomData_duplicate_referenced_layer(
&mesh_->vdata, CD_MDEFORMVERT, mesh_->totvert);
}
return std::make_unique<blender::bke::VertexWeightWriteAttribute>(
mesh_->dvert, mesh_->totvert, vertex_group_index);
}