[Bf-blender-cvs] [990b912fd76] master: Cleanup: Add check whether to remove an anonymous atttribute
Hans Goudey
noreply at git.blender.org
Wed Oct 20 16:58:03 CEST 2021
Commit: 990b912fd76cd9a2bf0278e7a5bc4a2029e024d2
Author: Hans Goudey
Date: Wed Oct 20 09:57:54 2021 -0500
Branches: master
https://developer.blender.org/rB990b912fd76cd9a2bf0278e7a5bc4a2029e024d2
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.
===================================================================
M source/blender/blenkernel/BKE_attribute_access.hh
M source/blender/blenkernel/intern/geometry_set.cc
M source/blender/geometry/intern/mesh_to_curve_convert.cc
===================================================================
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(
More information about the Bf-blender-cvs
mailing list