[Bf-blender-cvs] [54cf7eaf922] temp-geometry-nodes-fields--fields: Cleanup: Make construction of function fields easier to read

Hans Goudey noreply at git.blender.org
Mon Aug 30 21:01:35 CEST 2021


Commit: 54cf7eaf922d565bc272d026865aa91d817dd091
Author: Hans Goudey
Date:   Mon Aug 30 14:01:26 2021 -0500
Branches: temp-geometry-nodes-fields--fields
https://developer.blender.org/rB54cf7eaf922d565bc272d026865aa91d817dd091

Cleanup: Make construction of function fields easier to read

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

M	source/blender/functions/tests/FN_field_test.cc

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

diff --git a/source/blender/functions/tests/FN_field_test.cc b/source/blender/functions/tests/FN_field_test.cc
index e974d99ba93..5db878d32b3 100644
--- a/source/blender/functions/tests/FN_field_test.cc
+++ b/source/blender/functions/tests/FN_field_test.cc
@@ -84,11 +84,11 @@ TEST(field, InputAndFunction)
 {
   Field index_field{CPPType::get<int>(), std::make_shared<IndexFieldInput>()};
 
+  std::unique_ptr<MultiFunction> add_fn = std::make_unique<CustomMF_SI_SI_SO<int, int, int>>(
+      "add", [](int a, int b) { return a + b; });
   Field output_field{CPPType::get<int>(),
                      std::make_shared<FieldFunction>(
-                         FieldFunction(std::make_unique<CustomMF_SI_SI_SO<int, int, int>>(
-                                           "add", [](int a, int b) { return a + b; }),
-                                       {index_field, index_field})),
+                         FieldFunction(std::move(add_fn), {index_field, index_field})),
                      0};
 
   Array<int> result(10);
@@ -104,18 +104,18 @@ TEST(field, TwoFunctions)
 {
   Field index_field{CPPType::get<int>(), std::make_shared<IndexFieldInput>()};
 
+  std::unique_ptr<MultiFunction> add_fn = std::make_unique<CustomMF_SI_SI_SO<int, int, int>>(
+      "add", [](int a, int b) { return a + b; });
   Field add_field{CPPType::get<int>(),
                   std::make_shared<FieldFunction>(
-                      FieldFunction(std::make_unique<CustomMF_SI_SI_SO<int, int, int>>(
-                                        "add", [](int a, int b) { return a + b; }),
-                                    {index_field, index_field})),
+                      FieldFunction(std::move(add_fn), {index_field, index_field})),
                   0};
 
+  std::unique_ptr<MultiFunction> add_10_fn = std::make_unique<CustomMF_SI_SO<int, int>>(
+      "add_10", [](int a) { return a + 10; });
   Field result_field{
       CPPType::get<int>(),
-      std::make_shared<FieldFunction>(FieldFunction(
-          std::make_unique<CustomMF_SI_SO<int, int>>("add_10", [](int a) { return a + 10; }),
-          {add_field})),
+      std::make_shared<FieldFunction>(FieldFunction(std::move(add_10_fn), {add_field})),
       0};
 
   Array<int> result(10);



More information about the Bf-blender-cvs mailing list