[Bf-blender-cvs] [9eaec846552] virtual-array-attributes: cleanup

Jacques Lucke noreply at git.blender.org
Wed Apr 14 12:51:14 CEST 2021


Commit: 9eaec846552f84f593a8e9753220c7f6a88f1a26
Author: Jacques Lucke
Date:   Wed Apr 14 12:49:10 2021 +0200
Branches: virtual-array-attributes
https://developer.blender.org/rB9eaec846552f84f593a8e9753220c7f6a88f1a26

cleanup

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

M	source/blender/functions/FN_generic_virtual_array.hh
M	source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc
M	source/blender/nodes/geometry/nodes/node_geo_point_separate.cc

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

diff --git a/source/blender/functions/FN_generic_virtual_array.hh b/source/blender/functions/FN_generic_virtual_array.hh
index 362b1815a61..fa4f9298441 100644
--- a/source/blender/functions/FN_generic_virtual_array.hh
+++ b/source/blender/functions/FN_generic_virtual_array.hh
@@ -528,7 +528,7 @@ template<typename T> class GVMutableArray_For_VMutableArray : public GVMutableAr
   }
 };
 
-class GVArray_GSpan final : public GSpan {
+class GVArray_GSpan : public GSpan {
  private:
   const GVArray &varray_;
   void *owned_data_ = nullptr;
@@ -538,7 +538,7 @@ class GVArray_GSpan final : public GSpan {
   ~GVArray_GSpan();
 };
 
-class GVMutableArray_GSpan final : public GMutableSpan {
+class GVMutableArray_GSpan : public GMutableSpan {
  private:
   GVMutableArray &varray_;
   void *owned_data_ = nullptr;
@@ -553,6 +553,19 @@ class GVMutableArray_GSpan final : public GMutableSpan {
   void disable_not_applied_warning();
 };
 
+template<typename T> class GVArray_Span : public Span<T> {
+ private:
+  GVArray_GSpan varray_gspan_;
+
+ public:
+  GVArray_Span(const GVArray &varray) : varray_gspan_(varray)
+  {
+    BLI_assert(varray.type().is<T>());
+    this->data_ = (const T *)varray_gspan_.data();
+    this->size_ = varray_gspan_.size();
+  }
+};
+
 template<typename T> class GVArray_For_OwnedVArray : public GVArray_For_VArray<T> {
  private:
   std::unique_ptr<VArray<T>> owned_varray_;
diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc b/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc
index 678c9d5a1b2..aaf337ab638 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc
@@ -398,8 +398,7 @@ BLI_NOINLINE static void interpolate_existing_attributes(
       attribute_math::convert_to_static_type(output_data_type, [&](auto dummy) {
         using T = decltype(dummy);
 
-        GVArray_Typed<T> source_attribute_typed{*source_attribute};
-        VArray_Span<T> source_span{source_attribute_typed};
+        fn::GVArray_Span<T> source_span{*source_attribute};
 
         for (const int UNUSED(i_set_instance) : set_group.transforms.index_range()) {
           const int offset = instance_start_offsets[i_instance];
diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_separate.cc b/source/blender/nodes/geometry/nodes/node_geo_point_separate.cc
index 930ecaa4c67..78a70a77bbe 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_point_separate.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_point_separate.cc
@@ -73,8 +73,7 @@ static void copy_attributes_based_on_mask(const GeometryComponent &in_component,
 
     attribute_math::convert_to_static_type(data_type, [&](auto dummy) {
       using T = decltype(dummy);
-      GVArray_Typed<T> attribute_typed{*attribute.varray};
-      VArray_Span<T> span{attribute_typed};
+      fn::GVArray_Span<T> span{*attribute.varray};
       MutableSpan<T> out_span = result_attribute.as_span<T>();
       copy_data_based_on_mask(span, masks, invert, out_span);
     });



More information about the Bf-blender-cvs mailing list