[Bf-blender-cvs] [57f87a22b29] virtual-array-attributes: cleanups and fixes

Jacques Lucke noreply at git.blender.org
Thu Apr 15 17:14:45 CEST 2021


Commit: 57f87a22b29e7261c571e35b24525fcd81599ada
Author: Jacques Lucke
Date:   Thu Apr 15 17:04:38 2021 +0200
Branches: virtual-array-attributes
https://developer.blender.org/rB57f87a22b29e7261c571e35b24525fcd81599ada

cleanups and fixes

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

M	source/blender/functions/intern/generic_virtual_array.cc
M	source/blender/nodes/geometry/nodes/node_geo_attribute_clamp.cc
M	source/blender/nodes/geometry/nodes/node_geo_attribute_color_ramp.cc

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

diff --git a/source/blender/functions/intern/generic_virtual_array.cc b/source/blender/functions/intern/generic_virtual_array.cc
index 108ff19e83f..d2ff8ac0783 100644
--- a/source/blender/functions/intern/generic_virtual_array.cc
+++ b/source/blender/functions/intern/generic_virtual_array.cc
@@ -271,6 +271,10 @@ GVMutableArray_GSpan::~GVMutableArray_GSpan()
       std::cout << "Warning: Call `apply()` to make sure that changes persist in all cases.\n";
     }
   }
+  if (owned_data_ != nullptr) {
+    type_->destruct_n(owned_data_, size_);
+    MEM_freeN(owned_data_);
+  }
 }
 
 void GVMutableArray_GSpan::apply()
diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_clamp.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_clamp.cc
index 0da3d92dc79..96e7be003af 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_clamp.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_clamp.cc
@@ -113,7 +113,7 @@ template<> inline Color4f clamp_value(const Color4f val, const Color4f min, cons
 
 template<typename T>
 static void clamp_attribute(const VArray<T> &inputs,
-                            const MutableSpan<T> &outputs,
+                            const MutableSpan<T> outputs,
                             const T min,
                             const T max)
 {
@@ -186,7 +186,7 @@ static void clamp_attribute(GeometryComponent &component, const GeoNodeExecParam
         }
       }
       MutableSpan<float3> results = attribute_result.as_span<float3>();
-      clamp_attribute<float3>(*attribute_input->typed<float3>(), results, min, max);
+      clamp_attribute<float3>(attribute_input->typed<float3>(), results, min, max);
       break;
     }
     case CD_PROP_FLOAT: {
@@ -194,10 +194,10 @@ static void clamp_attribute(GeometryComponent &component, const GeoNodeExecParam
       const float max = params.get_input<float>("Max_001");
       MutableSpan<float> results = attribute_result.as_span<float>();
       if (operation == NODE_CLAMP_RANGE && min > max) {
-        clamp_attribute<float>(*attribute_input->typed<float>(), results, max, min);
+        clamp_attribute<float>(attribute_input->typed<float>(), results, max, min);
       }
       else {
-        clamp_attribute<float>(*attribute_input->typed<float>(), results, min, max);
+        clamp_attribute<float>(attribute_input->typed<float>(), results, min, max);
       }
       break;
     }
@@ -206,10 +206,10 @@ static void clamp_attribute(GeometryComponent &component, const GeoNodeExecParam
       const int max = params.get_input<int>("Max_002");
       MutableSpan<int> results = attribute_result.as_span<int>();
       if (operation == NODE_CLAMP_RANGE && min > max) {
-        clamp_attribute<int>(*attribute_input->typed<int>(), results, max, min);
+        clamp_attribute<int>(attribute_input->typed<int>(), results, max, min);
       }
       else {
-        clamp_attribute<int>(*attribute_input->typed<int>(), results, min, max);
+        clamp_attribute<int>(attribute_input->typed<int>(), results, min, max);
       }
       break;
     }
@@ -231,7 +231,7 @@ static void clamp_attribute(GeometryComponent &component, const GeoNodeExecParam
         }
       }
       MutableSpan<Color4f> results = attribute_result.as_span<Color4f>();
-      clamp_attribute<Color4f>(*attribute_input->typed<Color4f>(), results, min, max);
+      clamp_attribute<Color4f>(attribute_input->typed<Color4f>(), results, min, max);
       break;
     }
     default: {
diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_color_ramp.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_color_ramp.cc
index 19d4fb6e951..af65fe110e9 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_color_ramp.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_color_ramp.cc
@@ -82,14 +82,13 @@ static void execute_on_component(const GeoNodeExecParams &params, GeometryCompon
   GVArray_Typed<float> attribute_in = component.attribute_get_for_read<float>(
       input_name, result_domain, 0.0f);
 
-  VMutableArray_Span<Color4f> results{*attribute_result};
+  MutableSpan<Color4f> results = attribute_result.as_span();
 
   ColorBand *color_ramp = &node_storage->color_ramp;
   for (const int i : IndexRange(attribute_in.size())) {
     BKE_colorband_evaluate(color_ramp, attribute_in[i], results[i]);
   }
 
-  results.apply();
   attribute_result.save();
 }



More information about the Bf-blender-cvs mailing list