diff options
-rw-r--r-- | source/blender/blenkernel/BKE_deform.h | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/deform.c | 28 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/geometry_component_mesh.cc | 11 | ||||
-rw-r--r-- | source/blender/nodes/geometry/nodes/node_geo_raycast.cc | 8 |
4 files changed, 41 insertions, 10 deletions
diff --git a/source/blender/blenkernel/BKE_deform.h b/source/blender/blenkernel/BKE_deform.h index f4221d57428..cca99f9d1cd 100644 --- a/source/blender/blenkernel/BKE_deform.h +++ b/source/blender/blenkernel/BKE_deform.h @@ -50,6 +50,10 @@ void BKE_object_defgroup_active_index_set(struct Object *ob, const int new_index const struct ListBase *BKE_id_defgroup_list_get(const struct ID *id); struct ListBase *BKE_id_defgroup_list_get_mutable(struct ID *id); int BKE_id_defgroup_name_index(const struct ID *id, const char *name); +bool BKE_id_defgroup_name_find(const struct ID *id, + const char *name, + int *r_index, + struct bDeformGroup **r_group); struct bDeformGroup *BKE_object_defgroup_new(struct Object *ob, const char *name); void BKE_defgroup_copy_list(struct ListBase *outbase, const struct ListBase *inbase); 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; diff --git a/source/blender/nodes/geometry/nodes/node_geo_raycast.cc b/source/blender/nodes/geometry/nodes/node_geo_raycast.cc index d422bf5a00a..150be6b4695 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_raycast.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_raycast.cc @@ -205,10 +205,10 @@ class RaycastFunction : public fn::MultiFunction { std::unique_ptr<FieldEvaluator> target_evaluator_; const GVArray *target_data_ = nullptr; - /* Always evaluate the target domain data on the point domain. Eventually this could be - * exposed as an option or determined automatically from the field inputs in order to avoid - * losing information if the target field is on a different domain. */ - const AttributeDomain domain_ = ATTR_DOMAIN_POINT; + /* Always evaluate the target domain data on the face corner domain because it contains the most + * information. Eventually this could be exposed as an option or determined automatically from + * the field inputs for better performance. */ + const AttributeDomain domain_ = ATTR_DOMAIN_CORNER; fn::MFSignature signature_; |