[Bf-blender-cvs] [600c069e0ef] master: Attributes: Correct implementation of typed "write_only" method

Hans Goudey noreply at git.blender.org
Wed Sep 21 20:10:58 CEST 2022


Commit: 600c069e0ef5334575164e5c4d758efe7324b0c7
Author: Hans Goudey
Date:   Wed Sep 21 12:19:04 2022 -0500
Branches: master
https://developer.blender.org/rB600c069e0ef5334575164e5c4d758efe7324b0c7

Attributes: Correct implementation of typed "write_only" method

The typed "lookup_or_add_for_write_only" function is meant to do the
same thing as the non-typed version of the function. Instead, it still
initialized values of new attribute arrays, which isn't meant to happen.

Missed in 4c91c24bc7cbe2c4f97be373.

I also had to correct one place that used the "write_only"
function but didn't intialize all values.

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

M	source/blender/blenkernel/BKE_attribute.hh
M	source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc

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

diff --git a/source/blender/blenkernel/BKE_attribute.hh b/source/blender/blenkernel/BKE_attribute.hh
index b1f4039f788..97a8a91d0e4 100644
--- a/source/blender/blenkernel/BKE_attribute.hh
+++ b/source/blender/blenkernel/BKE_attribute.hh
@@ -706,7 +706,9 @@ class MutableAttributeAccessor : public AttributeAccessor {
   SpanAttributeWriter<T> lookup_or_add_for_write_only_span(const AttributeIDRef &attribute_id,
                                                            const eAttrDomain domain)
   {
-    AttributeWriter<T> attribute = this->lookup_or_add_for_write<T>(attribute_id, domain);
+    AttributeWriter<T> attribute = this->lookup_or_add_for_write<T>(
+        attribute_id, domain, AttributeInitConstruct());
+
     if (attribute) {
       return SpanAttributeWriter<T>{std::move(attribute), false};
     }
diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc
index edf14f664c5..1f9ad9f6ea2 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc
@@ -485,7 +485,7 @@ static void calculate_selection_outputs(Mesh *mesh,
   /* Populate "Top" selection output. */
   if (attribute_outputs.top_id) {
     const bool face = !config.top_is_point && config.fill_type != GEO_NODE_MESH_CIRCLE_FILL_NONE;
-    SpanAttributeWriter<bool> selection = attributes.lookup_or_add_for_write_only_span<bool>(
+    SpanAttributeWriter<bool> selection = attributes.lookup_or_add_for_write_span<bool>(
         attribute_outputs.top_id.get(), face ? ATTR_DOMAIN_FACE : ATTR_DOMAIN_POINT);
 
     if (config.top_is_point) {
@@ -501,7 +501,7 @@ static void calculate_selection_outputs(Mesh *mesh,
   if (attribute_outputs.bottom_id) {
     const bool face = !config.bottom_is_point &&
                       config.fill_type != GEO_NODE_MESH_CIRCLE_FILL_NONE;
-    SpanAttributeWriter<bool> selection = attributes.lookup_or_add_for_write_only_span<bool>(
+    SpanAttributeWriter<bool> selection = attributes.lookup_or_add_for_write_span<bool>(
         attribute_outputs.bottom_id.get(), face ? ATTR_DOMAIN_FACE : ATTR_DOMAIN_POINT);
 
     if (config.bottom_is_point) {
@@ -518,7 +518,7 @@ static void calculate_selection_outputs(Mesh *mesh,
 
   /* Populate "Side" selection output. */
   if (attribute_outputs.side_id) {
-    SpanAttributeWriter<bool> selection = attributes.lookup_or_add_for_write_only_span<bool>(
+    SpanAttributeWriter<bool> selection = attributes.lookup_or_add_for_write_span<bool>(
         attribute_outputs.side_id.get(), ATTR_DOMAIN_FACE);
 
     selection.span.slice(config.side_faces_start, config.side_faces_len).fill(true);



More information about the Bf-blender-cvs mailing list