Fix T102700: Viewer node missing check for empty geometry component

`GeometrySet::has()` can return an empty component. It's more convenient
if it doesn't, since other code rarely wants to access an empty component.

The alternative would be adding an `is_empty()` check in the lazy function
for the viewer node, that would work fine too, for this case.

Differential Revision: https://developer.blender.org/D16584
This commit is contained in:
Hans Goudey 2022-11-22 15:40:42 -06:00
parent 0e6d893d07
commit 41ae2c6438
Notes: blender-bot 2023-11-20 12:14:32 +01:00
Referenced by issue #102700, Regression: Viewer node crash on empty by non-null mesh after join geometry with attribute output on viewer
4 changed files with 2 additions and 10 deletions

View File

@ -161,7 +161,8 @@ const GeometryComponent *GeometrySet::get_component_for_read(
bool GeometrySet::has(const GeometryComponentType component_type) const
{
return components_[component_type].has_value();
const GeometryComponentPtr &component = components_[component_type];
return component.has_value() && !component->is_empty();
}
void GeometrySet::remove(const GeometryComponentType component_type)

View File

@ -1016,9 +1016,6 @@ static Vector<OutputAttributeToStore> compute_attributes_to_store(
continue;
}
const GeometryComponent &component = *geometry.get_component_for_read(component_type);
if (component.is_empty()) {
continue;
}
const blender::bke::AttributeAccessor attributes = *component.attributes();
for (const auto item : outputs_by_domain.items()) {
const eAttrDomain domain = item.key;

View File

@ -111,9 +111,6 @@ static bool component_is_available(const GeometrySet &geometry,
return false;
}
const GeometryComponent &component = *geometry.get_component_for_read(type);
if (component.is_empty()) {
return false;
}
return component.attribute_domain_size(domain) != 0;
}

View File

@ -211,9 +211,6 @@ static bool component_is_available(const GeometrySet &geometry,
return false;
}
const GeometryComponent &component = *geometry.get_component_for_read(type);
if (component.is_empty()) {
return false;
}
return component.attribute_domain_size(domain) != 0;
}