From 633f1cdec970d7f4c348ff63f4e8ef1bc8dfc2df Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Wed, 17 Mar 2021 11:50:13 +0100 Subject: Cleanup: improve gathering supported domains by geometry type --- .../blenkernel/intern/attribute_access_intern.hh | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'source/blender/blenkernel/intern/attribute_access_intern.hh') diff --git a/source/blender/blenkernel/intern/attribute_access_intern.hh b/source/blender/blenkernel/intern/attribute_access_intern.hh index 19349c69662..a6fd49bb0c6 100644 --- a/source/blender/blenkernel/intern/attribute_access_intern.hh +++ b/source/blender/blenkernel/intern/attribute_access_intern.hh @@ -18,6 +18,9 @@ #include "BLI_span.hh" #include "BLI_string_ref.hh" #include "BLI_vector.hh" +#include "BLI_vector_set.hh" + +#include "BKE_geometry_set.hh" namespace blender::bke { @@ -286,7 +289,7 @@ class DynamicAttributesProvider { virtual bool foreach_attribute(const GeometryComponent &component, const AttributeForeachCallback callback) const = 0; - virtual void supported_domains(blender::Vector &r_domains) const = 0; + virtual void foreach_domain(const FunctionRef callback) const = 0; }; /** @@ -324,9 +327,9 @@ class CustomDataAttributeProvider final : public DynamicAttributesProvider { bool foreach_attribute(const GeometryComponent &component, const AttributeForeachCallback callback) const final; - void supported_domains(blender::Vector &r_domains) const final + void foreach_domain(const FunctionRef callback) const final { - r_domains.append_non_duplicates(domain_); + callback(domain_); } private: @@ -388,7 +391,7 @@ class NamedLegacyCustomDataProvider final : public DynamicAttributesProvider { bool try_delete(GeometryComponent &component, const StringRef attribute_name) const final; bool foreach_attribute(const GeometryComponent &component, const AttributeForeachCallback callback) const final; - void supported_domains(Vector &r_domains) const final; + void foreach_domain(const FunctionRef callback) const final; }; /** @@ -457,7 +460,7 @@ class ComponentAttributeProviders { /** * All the domains that are supported by at least one of the providers above. */ - blender::Vector supported_domains_; + blender::VectorSet supported_domains_; public: ComponentAttributeProviders( @@ -465,14 +468,13 @@ class ComponentAttributeProviders { blender::Span dynamic_attribute_providers) : dynamic_attribute_providers_(dynamic_attribute_providers) { - blender::Set domains; for (const BuiltinAttributeProvider *provider : builtin_attribute_providers) { /* Use #add_new to make sure that no two builtin attributes have the same name. */ builtin_attribute_providers_.add_new(provider->name(), provider); - supported_domains_.append_non_duplicates(provider->domain()); + supported_domains_.add(provider->domain()); } for (const DynamicAttributesProvider *provider : dynamic_attribute_providers) { - provider->supported_domains(supported_domains_); + provider->foreach_domain([&](AttributeDomain domain) { supported_domains_.add(domain); }); } } @@ -493,4 +495,4 @@ class ComponentAttributeProviders { } }; -} // namespace blender::bke \ No newline at end of file +} // namespace blender::bke -- cgit v1.2.3