diff options
author | Jacques Lucke <jacques@blender.org> | 2021-11-23 16:39:55 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-11-23 16:39:55 +0300 |
commit | 0bedd5d14f6d61a6a4a96cc7f88484b0dc46f752 (patch) | |
tree | 993d499687008e2b584ddd0f6b2ffc2039440d11 /source/blender/blenkernel/intern | |
parent | d7b7cbb04775005f3fee70c110a07c944829ed49 (diff) | |
parent | 436ce221941403dd8a3f9ec3740d22f70f4c2ad8 (diff) |
Merge branch 'blender-v3.0-release'
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/deform.c | 28 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/geometry_component_mesh.cc | 11 |
2 files changed, 33 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index 13222747a52..a2f285dab51 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -557,11 +557,35 @@ bDeformGroup *BKE_object_defgroup_find_name(const Object *ob, const char *name) int BKE_id_defgroup_name_index(const ID *id, const char *name) { - if (name == NULL || name[0] == '\0') { + int index; + if (!BKE_id_defgroup_name_find(id, name, &index, NULL)) { return -1; } + return index; +} + +bool BKE_id_defgroup_name_find(const struct ID *id, + const char *name, + int *r_index, + struct bDeformGroup **r_group) +{ + if (name == NULL || name[0] == '\0') { + return false; + } const ListBase *defbase = BKE_id_defgroup_list_get(id); - return BLI_findstringindex(defbase, name, offsetof(bDeformGroup, name)); + int index; + LISTBASE_FOREACH_INDEX (bDeformGroup *, group, defbase, index) { + if (STREQ(name, group->name)) { + if (r_index != NULL) { + *r_index = index; + } + if (r_group != NULL) { + *r_group = group; + } + return true; + } + } + return false; } const ListBase *BKE_object_defgroup_list(const Object *ob) diff --git a/source/blender/blenkernel/intern/geometry_component_mesh.cc b/source/blender/blenkernel/intern/geometry_component_mesh.cc index 86a52b420b6..a258a66cdf3 100644 --- a/source/blender/blenkernel/intern/geometry_component_mesh.cc +++ b/source/blender/blenkernel/intern/geometry_component_mesh.cc @@ -1127,16 +1127,19 @@ class VertexGroupsAttributeProvider final : public DynamicAttributesProvider { } const std::string name = attribute_id.name(); - const int vertex_group_index = BLI_findstringindex( - &mesh->vertex_group_names, name.c_str(), offsetof(bDeformGroup, name)); - if (vertex_group_index < 0) { + + int index; + bDeformGroup *group; + if (!BKE_id_defgroup_name_find(&mesh->id, name.c_str(), &index, &group)) { return false; } + BLI_remlink(&mesh->vertex_group_names, group); + MEM_freeN(group); if (mesh->dvert == nullptr) { return true; } for (MDeformVert &dvert : MutableSpan(mesh->dvert, mesh->totvert)) { - MDeformWeight *weight = BKE_defvert_find_index(&dvert, vertex_group_index); + MDeformWeight *weight = BKE_defvert_find_index(&dvert, index); BKE_defvert_remove_group(&dvert, weight); } return true; |