[Bf-blender-cvs] [e05c93b4fc7] temp-geometry-nodes-mix-attributes: cleanup

Jacques Lucke noreply at git.blender.org
Wed Dec 9 16:48:19 CET 2020


Commit: e05c93b4fc7a5ac8d084ef65fb7e4979197c6ac0
Author: Jacques Lucke
Date:   Wed Dec 9 15:37:36 2020 +0100
Branches: temp-geometry-nodes-mix-attributes
https://developer.blender.org/rBe05c93b4fc7a5ac8d084ef65fb7e4979197c6ac0

cleanup

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

M	source/blender/nodes/geometry/nodes/node_geo_attribute_mix.cc

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

diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_mix.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_mix.cc
index c8b75a1a5b7..2635538a73d 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_mix.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_mix.cc
@@ -90,6 +90,45 @@ static void do_mix_operation_color4f(const int blend_mode,
   }
 }
 
+static void do_mix_operation(const CustomDataType result_type,
+                             int blend_mode,
+                             const FloatReadAttribute &attribute_factor,
+                             ReadAttributePtr attribute_a,
+                             ReadAttributePtr attribute_b,
+                             WriteAttributePtr attribute_result)
+{
+  if (result_type == CD_PROP_FLOAT) {
+    FloatReadAttribute attribute_a_float = std::move(attribute_a);
+    FloatReadAttribute attribute_b_float = std::move(attribute_b);
+    FloatWriteAttribute attribute_result_float = std::move(attribute_result);
+    do_mix_operation_float(blend_mode,
+                           attribute_factor,
+                           attribute_a_float,
+                           attribute_b_float,
+                           attribute_result_float);
+  }
+  else if (result_type == CD_PROP_FLOAT3) {
+    Float3ReadAttribute attribute_a_float3 = std::move(attribute_a);
+    Float3ReadAttribute attribute_b_float3 = std::move(attribute_b);
+    Float3WriteAttribute attribute_result_float3 = std::move(attribute_result);
+    do_mix_operation_float3(blend_mode,
+                            attribute_factor,
+                            attribute_a_float3,
+                            attribute_b_float3,
+                            attribute_result_float3);
+  }
+  else if (result_type == CD_PROP_COLOR) {
+    Color4fReadAttribute attribute_a_color4f = std::move(attribute_a);
+    Color4fReadAttribute attribute_b_color4f = std::move(attribute_b);
+    Color4fWriteAttribute attribute_result_color4f = std::move(attribute_result);
+    do_mix_operation_color4f(blend_mode,
+                             attribute_factor,
+                             attribute_a_color4f,
+                             attribute_b_color4f,
+                             attribute_result_color4f);
+  }
+}
+
 static void attribute_mix_calc(GeometryComponent &component, const GeoNodeExecParams &params)
 {
   const bNode &node = params.node();
@@ -119,36 +158,12 @@ static void attribute_mix_calc(GeometryComponent &component, const GeoNodeExecPa
   ReadAttributePtr attribute_b = params.get_input_attribute(
       "B", component, result_domain, result_type, nullptr);
 
-  if (result_type == CD_PROP_FLOAT) {
-    FloatReadAttribute attribute_a_float = std::move(attribute_a);
-    FloatReadAttribute attribute_b_float = std::move(attribute_b);
-    FloatWriteAttribute attribute_result_float = std::move(attribute_result);
-    do_mix_operation_float(node_storage->blend_type,
-                           attribute_factor,
-                           attribute_a_float,
-                           attribute_b_float,
-                           attribute_result_float);
-  }
-  else if (result_type == CD_PROP_FLOAT3) {
-    Float3ReadAttribute attribute_a_float3 = std::move(attribute_a);
-    Float3ReadAttribute attribute_b_float3 = std::move(attribute_b);
-    Float3WriteAttribute attribute_result_float3 = std::move(attribute_result);
-    do_mix_operation_float3(node_storage->blend_type,
-                            attribute_factor,
-                            attribute_a_float3,
-                            attribute_b_float3,
-                            attribute_result_float3);
-  }
-  else if (result_type == CD_PROP_COLOR) {
-    Color4fReadAttribute attribute_a_color4f = std::move(attribute_a);
-    Color4fReadAttribute attribute_b_color4f = std::move(attribute_b);
-    Color4fWriteAttribute attribute_result_color4f = std::move(attribute_result);
-    do_mix_operation_color4f(node_storage->blend_type,
-                             attribute_factor,
-                             attribute_a_color4f,
-                             attribute_b_color4f,
-                             attribute_result_color4f);
-  }
+  do_mix_operation(result_type,
+                   node_storage->blend_type,
+                   attribute_factor,
+                   std::move(attribute_a),
+                   std::move(attribute_b),
+                   std::move(attribute_result));
 }
 
 static void geo_node_attribute_mix_exec(GeoNodeExecParams params)



More information about the Bf-blender-cvs mailing list