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-10-20 17:57:54 +0300
committerHans Goudey <h.goudey@me.com>2021-10-20 17:57:54 +0300
commit990b912fd76cd9a2bf0278e7a5bc4a2029e024d2 (patch)
tree2d99061834d5ffdda05c3ad3f5235d11833eaf4b
parent494c3fb1bdb425059b26abd21d7c9230eda68438 (diff)
Cleanup: Add check whether to remove an anonymous atttribute
Add a higher level check that can be used instead of checking whether the attribute ID is anonymous and checking whether it has any strong references.
-rw-r--r--source/blender/blenkernel/BKE_attribute_access.hh11
-rw-r--r--source/blender/blenkernel/intern/geometry_set.cc9
-rw-r--r--source/blender/geometry/intern/mesh_to_curve_convert.cc8
3 files changed, 17 insertions, 11 deletions
diff --git a/source/blender/blenkernel/BKE_attribute_access.hh b/source/blender/blenkernel/BKE_attribute_access.hh
index ff2aebc7d10..4a1c29badb4 100644
--- a/source/blender/blenkernel/BKE_attribute_access.hh
+++ b/source/blender/blenkernel/BKE_attribute_access.hh
@@ -55,6 +55,7 @@ class AttributeIDRef {
bool is_anonymous() const;
StringRef name() const;
const AnonymousAttributeID &anonymous_id() const;
+ bool should_be_kept() const;
friend bool operator==(const AttributeIDRef &a, const AttributeIDRef &b);
friend std::ostream &operator<<(std::ostream &stream, const AttributeIDRef &attribute_id);
@@ -438,6 +439,16 @@ inline const AnonymousAttributeID &AttributeIDRef::anonymous_id() const
return *anonymous_id_;
}
+/**
+ * \return True if the attribute should not be removed automatically as an optimization during
+ * processing or copying. Anonymous attributes can be removed when they no longer have any
+ * references.
+ */
+inline bool AttributeIDRef::should_be_kept() const
+{
+ return this->is_named() || BKE_anonymous_attribute_id_has_strong_references(anonymous_id_);
+}
+
/** \} */
/* -------------------------------------------------------------------- */
diff --git a/source/blender/blenkernel/intern/geometry_set.cc b/source/blender/blenkernel/intern/geometry_set.cc
index e439cc838e3..4753a9e0768 100644
--- a/source/blender/blenkernel/intern/geometry_set.cc
+++ b/source/blender/blenkernel/intern/geometry_set.cc
@@ -507,12 +507,11 @@ void GeometrySet::gather_attributes_for_propagation(
return;
}
}
- if (attribute_id.is_anonymous()) {
- if (!BKE_anonymous_attribute_id_has_strong_references(&attribute_id.anonymous_id())) {
- /* Don't propagate anonymous attributes that are not used anymore. */
- return;
- }
+
+ if (!attribute_id.should_be_kept()) {
+ return;
}
+
auto add_info = [&](AttributeKind *attribute_kind) {
attribute_kind->domain = meta_data.domain;
attribute_kind->data_type = meta_data.data_type;
diff --git a/source/blender/geometry/intern/mesh_to_curve_convert.cc b/source/blender/geometry/intern/mesh_to_curve_convert.cc
index 64b9fa5c01d..24f0b6308ba 100644
--- a/source/blender/geometry/intern/mesh_to_curve_convert.cc
+++ b/source/blender/geometry/intern/mesh_to_curve_convert.cc
@@ -78,12 +78,8 @@ static void copy_attributes_to_points(CurveEval &curve,
continue;
}
- /* Don't copy anonymous attributes with no references anymore. */
- if (attribute_id.is_anonymous()) {
- const AnonymousAttributeID &anonymous_id = attribute_id.anonymous_id();
- if (!BKE_anonymous_attribute_id_has_strong_references(&anonymous_id)) {
- continue;
- }
+ if (!attribute_id.should_be_kept()) {
+ continue;
}
const fn::GVArrayPtr mesh_attribute = mesh_component.attribute_try_get_for_read(