[Bf-blender-cvs] [4b091f2eb69] temp-geometry-nodes-fields: add comments for anonymous attributes

Jacques Lucke noreply at git.blender.org
Mon Sep 6 17:41:41 CEST 2021


Commit: 4b091f2eb69545b7ebced304b44fc197a7c2aa57
Author: Jacques Lucke
Date:   Mon Sep 6 17:40:53 2021 +0200
Branches: temp-geometry-nodes-fields
https://developer.blender.org/rB4b091f2eb69545b7ebced304b44fc197a7c2aa57

add comments for anonymous attributes

===================================================================

M	source/blender/blenkernel/BKE_geometry_set.hh
M	source/blender/blenkernel/intern/anonymous_attribute.cc
M	source/blender/makesdna/DNA_customdata_types.h

===================================================================

diff --git a/source/blender/blenkernel/BKE_geometry_set.hh b/source/blender/blenkernel/BKE_geometry_set.hh
index d9da4b9fb01..dd921d0d373 100644
--- a/source/blender/blenkernel/BKE_geometry_set.hh
+++ b/source/blender/blenkernel/BKE_geometry_set.hh
@@ -628,6 +628,10 @@ class AttributeFieldInput : public fn::FieldInput {
 
 class AnonymousAttributeFieldInput : public fn::FieldInput {
  private:
+  /**
+   * A strong reference is required to make sure that the referenced attribute is not removed
+   * automatically.
+   */
   StrongAnonymousAttributeID anonymous_id_;
 
  public:
diff --git a/source/blender/blenkernel/intern/anonymous_attribute.cc b/source/blender/blenkernel/intern/anonymous_attribute.cc
index 73e2a656a7f..67611053d83 100644
--- a/source/blender/blenkernel/intern/anonymous_attribute.cc
+++ b/source/blender/blenkernel/intern/anonymous_attribute.cc
@@ -18,10 +18,18 @@
 
 using namespace blender::bke;
 
+/**
+ * A struct that identifies an attribute. It's lifetime is managed by an atomic reference count.
+ *
+ * Additionally, this struct can be strongly or weakly owned. The difference is that strong
+ * ownership means that attributes with this id will be kept around. Weak ownership just makes sure
+ * that the struct itself stays alive, but corresponding attributes might still be removed
+ * automatically.
+ */
 struct AnonymousAttributeID {
   /**
    * Total number of references to this attribute id. Once this reaches zero, the struct can be
-   * freed.
+   * freed. This includes strong and weak references.
    */
   mutable std::atomic<int> refcount_tot = 0;
 
diff --git a/source/blender/makesdna/DNA_customdata_types.h b/source/blender/makesdna/DNA_customdata_types.h
index 214b514b25c..6acea8da15f 100644
--- a/source/blender/makesdna/DNA_customdata_types.h
+++ b/source/blender/makesdna/DNA_customdata_types.h
@@ -57,7 +57,9 @@ typedef struct CustomDataLayer {
   void *data;
   /**
    * Run-time identifier for this layer. If no one has a strong reference to this id anymore,
-   * the layer can be removed.
+   * the layer can be removed. The custom data layer only has a weak reference to the id, because
+   * otherwise there will always be a strong reference and the attribute can't be removed
+   * automatically.
    */
   const struct AnonymousAttributeID *anonymous_id;
 } CustomDataLayer;



More information about the Bf-blender-cvs mailing list