Geometry Nodes: Remove repeated instance attribute names in search

This commit makes sure that each attribute name is only added once
when logging geometry values for attribute search.

The `attribute_foreach` function for a single geometry component
deduplicated names, but a much more common situation is to have
more than one component in the instances of a geometry set.

Differential Revision: https://developer.blender.org/D12959
This commit is contained in:
Hans Goudey 2021-10-24 13:24:02 -05:00
parent 6f0dd4f0f0
commit 3e75f70acd
Notes: blender-bot 2023-12-08 12:32:11 +01:00
Referenced by issue #92503, OSL: Blender crashes when activating object with OSL material
Referenced by issue #115899, Regression: Semi-transparent gap between node header and node content
1 changed files with 7 additions and 1 deletions

View File

@ -175,13 +175,19 @@ GeometryValueLog::GeometryValueLog(const GeometrySet &geometry_set, bool log_ful
GEO_COMPONENT_TYPE_MESH,
GEO_COMPONENT_TYPE_POINT_CLOUD,
GEO_COMPONENT_TYPE_VOLUME};
/* Keep track handled attribute names to make sure that we do not return the same name twice.
* Currently #GeometrySet::attribute_foreach does not do that. Note that this will merge
* attributes with the same name but different domains or data types on separate components. */
Set<StringRef> names;
geometry_set.attribute_foreach(
all_component_types,
true,
[&](const bke::AttributeIDRef &attribute_id,
const AttributeMetaData &meta_data,
const GeometryComponent &UNUSED(component)) {
if (attribute_id.is_named()) {
if (attribute_id.is_named() && names.add(attribute_id.name())) {
this->attributes_.append({attribute_id.name(), meta_data.domain, meta_data.data_type});
}
});