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:
authorJacques Lucke <jacques@blender.org>2021-03-17 13:50:13 +0300
committerJacques Lucke <jacques@blender.org>2021-03-17 13:52:02 +0300
commit633f1cdec970d7f4c348ff63f4e8ef1bc8dfc2df (patch)
tree6e696541a7dc2f9dd4c2e1ebd599f2fcc36a1694 /source/blender/blenkernel/intern/attribute_access_intern.hh
parente6bdd57191e833f336fdb582418935b997395f98 (diff)
Cleanup: improve gathering supported domains by geometry type
Diffstat (limited to 'source/blender/blenkernel/intern/attribute_access_intern.hh')
-rw-r--r--source/blender/blenkernel/intern/attribute_access_intern.hh20
1 files changed, 11 insertions, 9 deletions
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<AttributeDomain> &r_domains) const = 0;
+ virtual void foreach_domain(const FunctionRef<void(AttributeDomain)> 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<AttributeDomain> &r_domains) const final
+ void foreach_domain(const FunctionRef<void(AttributeDomain)> 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<AttributeDomain> &r_domains) const final;
+ void foreach_domain(const FunctionRef<void(AttributeDomain)> 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<AttributeDomain> supported_domains_;
+ blender::VectorSet<AttributeDomain> supported_domains_;
public:
ComponentAttributeProviders(
@@ -465,14 +468,13 @@ class ComponentAttributeProviders {
blender::Span<const DynamicAttributesProvider *> dynamic_attribute_providers)
: dynamic_attribute_providers_(dynamic_attribute_providers)
{
- blender::Set<AttributeDomain> 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