Geometry Nodes: Add helper function to check if attribute exists

This commit is contained in:
Hans Goudey 2020-12-10 10:50:37 -06:00
parent 3d25312617
commit 8bdd996cd0
2 changed files with 12 additions and 0 deletions

View File

@ -88,6 +88,9 @@ class GeometryComponent {
GeometryComponentType type() const;
/* Return true when any attribute with this name exists, including built in attributes. */
bool attribute_exists(const blender::StringRef attribute_name) const;
/* Returns true when the geometry component supports this attribute domain. */
virtual bool attribute_domain_supported(const AttributeDomain domain) const;
/* Returns true when the given data type is supported in the given domain. */

View File

@ -590,6 +590,15 @@ Set<std::string> GeometryComponent::attribute_names() const
return {};
}
bool GeometryComponent::attribute_exists(const blender::StringRef attribute_name) const
{
ReadAttributePtr attribute = this->attribute_try_get_for_read(attribute_name);
if (attribute) {
return true;
}
return false;
}
static ReadAttributePtr try_adapt_data_type(ReadAttributePtr attribute,
const blender::fn::CPPType &to_type)
{