[Bf-blender-cvs] [e37bc4e28d7] virtual-array-attributes: progress

Jacques Lucke noreply at git.blender.org
Tue Apr 13 13:25:48 CEST 2021


Commit: e37bc4e28d7a62b6e95568e70ac725e03023adcb
Author: Jacques Lucke
Date:   Tue Apr 13 12:58:53 2021 +0200
Branches: virtual-array-attributes
https://developer.blender.org/rBe37bc4e28d7a62b6e95568e70ac725e03023adcb

progress

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

M	source/blender/nodes/geometry/nodes/node_geo_attribute_sample_texture.cc
M	source/blender/nodes/geometry/nodes/node_geo_attribute_separate_xyz.cc

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

diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_sample_texture.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_sample_texture.cc
index d0b2595b5b9..61603bf3120 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_sample_texture.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_sample_texture.cc
@@ -53,15 +53,16 @@ static AttributeDomain get_result_domain(const GeometryComponent &component,
                                          StringRef map_attribute_name)
 {
   /* Use the domain of the result attribute if it already exists. */
-  ReadAttributePtr result_attribute = component.attribute_try_get_for_read(result_attribute_name);
+  ReadAttributeLookup result_attribute = component.attribute_try_get_for_read(
+      result_attribute_name);
   if (result_attribute) {
-    return result_attribute->domain();
+    return result_attribute.domain;
   }
 
   /* Otherwise use the name of the map attribute. */
-  ReadAttributePtr map_attribute = component.attribute_try_get_for_read(map_attribute_name);
+  ReadAttributeLookup map_attribute = component.attribute_try_get_for_read(map_attribute_name);
   if (map_attribute) {
-    return map_attribute->domain();
+    return map_attribute.domain;
   }
 
   /* The node won't execute in this case, but we still have to return a value. */
@@ -85,16 +86,16 @@ static void execute_on_component(GeometryComponent &component, const GeoNodeExec
   const AttributeDomain result_domain = get_result_domain(
       component, result_attribute_name, mapping_name);
 
-  OutputAttributePtr attribute_out = component.attribute_try_get_for_output(
-      result_attribute_name, result_domain, CD_PROP_COLOR);
+  OutputAttribute_Typed<Color4f> attribute_out = component.attribute_try_get_for_output<Color4f>(
+      result_attribute_name, result_domain);
   if (!attribute_out) {
     return;
   }
 
-  Float3ReadAttribute mapping_attribute = component.attribute_get_for_read<float3>(
+  GVArray_Typed<float3> mapping_attribute = component.attribute_get_for_read<float3>(
       mapping_name, result_domain, {0, 0, 0});
 
-  MutableSpan<Color4f> colors = attribute_out->get_span<Color4f>();
+  MutableSpan<Color4f> colors = attribute_out.as_span();
   for (const int i : IndexRange(mapping_attribute.size())) {
     TexResult texture_result = {0};
     const float3 position = mapping_attribute[i];
@@ -103,7 +104,7 @@ static void execute_on_component(GeometryComponent &component, const GeoNodeExec
     BKE_texture_get_value(nullptr, texture, remapped_position, &texture_result, false);
     colors[i] = {texture_result.tr, texture_result.tg, texture_result.tb, texture_result.ta};
   }
-  attribute_out.apply_span_and_save();
+  attribute_out.save();
 }
 
 static void geo_node_attribute_sample_texture_exec(GeoNodeExecParams params)
diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_separate_xyz.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_separate_xyz.cc
index 656dc51149e..d11e5f5d9f8 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_separate_xyz.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_separate_xyz.cc
@@ -77,17 +77,17 @@ static AttributeDomain get_result_domain(const GeometryComponent &component,
 {
   /* Use the highest priority domain from any existing attribute outputs. */
   Vector<AttributeDomain, 3> output_domains;
-  ReadAttributePtr attribute_x = component.attribute_try_get_for_read(result_name_x);
-  ReadAttributePtr attribute_y = component.attribute_try_get_for_read(result_name_y);
-  ReadAttributePtr attribute_z = component.attribute_try_get_for_read(result_name_z);
+  ReadAttributeLookup attribute_x = component.attribute_try_get_for_read(result_name_x);
+  ReadAttributeLookup attribute_y = component.attribute_try_get_for_read(result_name_y);
+  ReadAttributeLookup attribute_z = component.attribute_try_get_for_read(result_name_z);
   if (attribute_x) {
-    output_domains.append(attribute_x->domain());
+    output_domains.append(attribute_x.domain);
   }
   if (attribute_y) {
-    output_domains.append(attribute_y->domain());
+    output_domains.append(attribute_y.domain);
   }
   if (attribute_z) {
-    output_domains.append(attribute_z->domain());
+    output_domains.append(attribute_z.domain);
   }
   if (output_domains.size() > 0) {
     return bke::attribute_domain_highest_priority(output_domains);
@@ -112,32 +112,29 @@ static void separate_attribute(GeometryComponent &component, const GeoNodeExecPa
   const AttributeDomain result_domain = get_result_domain(
       component, params, result_name_x, result_name_y, result_name_z);
 
-  ReadAttributePtr attribute_input = params.get_input_attribute(
-      "Vector", component, result_domain, input_type, nullptr);
-  if (!attribute_input) {
-    return;
-  }
-  const Span<float3> input_span = attribute_input->get_span<float3>();
+  GVArray_Typed<float3> attribute_input = params.get_input_attribute<float3>(
+      "Vector", component, result_domain, {0, 0, 0});
+  VArray_Span<float3> input_span{*attribute_input};
 
-  OutputAttributePtr attribute_result_x = component.attribute_try_get_for_output(
-      result_name_x, result_domain, result_type);
-  OutputAttributePtr attribute_result_y = component.attribute_try_get_for_output(
-      result_name_y, result_domain, result_type);
-  OutputAttributePtr attribute_result_z = component.attribute_try_get_for_output(
-      result_name_z, result_domain, result_type);
+  OutputAttribute_Typed<float> attribute_result_x = component.attribute_try_get_for_output<float>(
+      result_name_x, result_domain);
+  OutputAttribute_Typed<float> attribute_result_y = component.attribute_try_get_for_output<float>(
+      result_name_y, result_domain);
+  OutputAttribute_Typed<float> attribute_result_z = component.attribute_try_get_for_output<float>(
+      result_name_z, result_domain);
 
   /* Only extract the components for the outputs with a given attribute. */
   if (attribute_result_x) {
-    extract_input(0, input_span, attribute_result_x->get_span_for_write_only<float>());
-    attribute_result_x.apply_span_and_save();
+    extract_input(0, input_span, attribute_result_x.as_span());
+    attribute_result_x.save();
   }
   if (attribute_result_y) {
-    extract_input(1, input_span, attribute_result_y->get_span_for_write_only<float>());
-    attribute_result_y.apply_span_and_save();
+    extract_input(1, input_span, attribute_result_y.as_span());
+    attribute_result_y.save();
   }
   if (attribute_result_z) {
-    extract_input(2, input_span, attribute_result_z->get_span_for_write_only<float>());
-    attribute_result_z.apply_span_and_save();
+    extract_input(2, input_span, attribute_result_z.as_span());
+    attribute_result_z.save();
   }
 }



More information about the Bf-blender-cvs mailing list