Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2021-09-16 19:56:31 +0300
committerHans Goudey <h.goudey@me.com>2021-09-16 19:56:31 +0300
commit31a0708cb1097be96bf7a8ad2b344b20ac7d2fcd (patch)
tree0a232c8e70de95fbfc938385b41407d754fd0b9e
parent58043c0637f88f56a26c9cd645d9019780bc4761 (diff)
Cleanup: Add built-in check for an attribute ID
-rw-r--r--source/blender/blenkernel/BKE_geometry_set.hh1
-rw-r--r--source/blender/blenkernel/intern/attribute_access.cc8
2 files changed, 8 insertions, 1 deletions
diff --git a/source/blender/blenkernel/BKE_geometry_set.hh b/source/blender/blenkernel/BKE_geometry_set.hh
index 3da35cb4fe1..bf38294257a 100644
--- a/source/blender/blenkernel/BKE_geometry_set.hh
+++ b/source/blender/blenkernel/BKE_geometry_set.hh
@@ -103,6 +103,7 @@ class GeometryComponent {
virtual int attribute_domain_size(const AttributeDomain domain) const;
bool attribute_is_builtin(const blender::StringRef attribute_name) const;
+ bool attribute_is_builtin(const blender::bke::AttributeIDRef &attribute_id) const;
/* Get read-only access to the highest priority attribute with the given name.
* Returns null if the attribute does not exist. */
diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc
index bdf1891a55a..cfd3136c765 100644
--- a/source/blender/blenkernel/intern/attribute_access.cc
+++ b/source/blender/blenkernel/intern/attribute_access.cc
@@ -817,6 +817,12 @@ bool GeometryComponent::attribute_is_builtin(const blender::StringRef attribute_
return providers->builtin_attribute_providers().contains_as(attribute_name);
}
+bool GeometryComponent::attribute_is_builtin(const AttributeIDRef &attribute_id) const
+{
+ /* Anonymous attributes cannot be built-in. */
+ return attribute_id.is_named() && this->attribute_is_builtin(attribute_id.name());
+}
+
blender::bke::ReadAttributeLookup GeometryComponent::attribute_try_get_for_read(
const AttributeIDRef &attribute_id) const
{
@@ -1210,7 +1216,7 @@ static OutputAttribute create_output_attribute(GeometryComponent &component,
BLI_assert(cpp_type != nullptr);
const nodes::DataTypeConversions &conversions = nodes::get_implicit_type_conversions();
- if (attribute_id.is_named() && component.attribute_is_builtin(attribute_id.name())) {
+ if (component.attribute_is_builtin(attribute_id)) {
const StringRef attribute_name = attribute_id.name();
WriteAttributeLookup attribute = component.attribute_try_get_for_write(attribute_name);
if (!attribute) {