[Bf-blender-cvs] [b3cc26bf352] temp-geometry-nodes-fields--fields: Add another very simple passing test

Hans Goudey noreply at git.blender.org
Sat Aug 28 07:41:08 CEST 2021


Commit: b3cc26bf35237825965070261e3198e28e43f960
Author: Hans Goudey
Date:   Sat Aug 28 00:21:01 2021 -0500
Branches: temp-geometry-nodes-fields--fields
https://developer.blender.org/rBb3cc26bf35237825965070261e3198e28e43f960

Add another very simple passing test

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

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

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

diff --git a/source/blender/functions/intern/field.cc b/source/blender/functions/intern/field.cc
index 62e7d8d31aa..c4148d0fdc1 100644
--- a/source/blender/functions/intern/field.cc
+++ b/source/blender/functions/intern/field.cc
@@ -187,7 +187,7 @@ void evaluate_fields(const Span<Field> fields,
    * special case to avoid sharing the same variable for an input and output elsewhere. */
   Vector<Field> non_input_fields{fields};
   Vector<GMutableSpan> non_input_outputs{outputs};
-  for (const int i : fields.index_range()) {
+  for (int i = fields.size() - 1; i >= 0; i--) {
     if (non_input_fields[i].is_input()) {
       non_input_fields[i].input().retrieve_data(mask)->materialize(mask, outputs[i].data());
 
diff --git a/source/blender/functions/tests/FN_field_test.cc b/source/blender/functions/tests/FN_field_test.cc
index 3dd22b5cde9..029527249ef 100644
--- a/source/blender/functions/tests/FN_field_test.cc
+++ b/source/blender/functions/tests/FN_field_test.cc
@@ -17,7 +17,7 @@ TEST(field, ConstantFunction)
 
   Array<int> result(4);
   GMutableSpan result_generic(result.as_mutable_span());
-  evaluate_fields({&constant_field, 1}, IndexMask(IndexRange(4)), {&result_generic, 1});
+  evaluate_fields({constant_field}, IndexMask(IndexRange(4)), {result_generic});
 
   EXPECT_EQ(result[0], 10);
   EXPECT_EQ(result[1], 10);
@@ -41,15 +41,34 @@ TEST(field, VArrayInput)
 
   Array<int> result_1(4);
   GMutableSpan result_generic_1(result_1.as_mutable_span());
-  evaluate_fields({&index_field, 1}, IndexMask(IndexRange(4)), {&result_generic_1, 1});
+  evaluate_fields({index_field}, IndexMask(IndexRange(4)), {result_generic_1});
   EXPECT_EQ(result_1[0], 0);
   EXPECT_EQ(result_1[1], 1);
   EXPECT_EQ(result_1[2], 2);
   EXPECT_EQ(result_1[3], 3);
 
+  /* Evaluate a second time, just to test that the first didn't break anything. */
   Array<int> result_2(10);
   GMutableSpan result_generic_2(result_2.as_mutable_span());
-  evaluate_fields({&index_field, 1}, {2, 4, 6, 8}, {&result_generic_2, 1});
+  evaluate_fields({index_field}, {2, 4, 6, 8}, {result_generic_2});
+  EXPECT_EQ(result_2[2], 2);
+  EXPECT_EQ(result_2[4], 4);
+  EXPECT_EQ(result_2[6], 6);
+  EXPECT_EQ(result_2[8], 8);
+}
+
+TEST(field, VArrayInputMultipleOutputs)
+{
+  std::shared_ptr<FieldInput> index_input = std::make_shared<IndexFieldInput>();
+  Field field_1 = Field(CPPType::get<int>(), index_input);
+  Field field_2 = Field(CPPType::get<int>(), index_input);
+
+  Array<int> result_1(10);
+  Array<int> result_2(10);
+  GMutableSpan result_generic_1(result_1.as_mutable_span());
+  GMutableSpan result_generic_2(result_2.as_mutable_span());
+
+  evaluate_fields({field_1, field_2}, {2, 4, 6, 8}, {result_generic_1, result_generic_2});
   EXPECT_EQ(result_2[2], 2);
   EXPECT_EQ(result_2[4], 4);
   EXPECT_EQ(result_2[6], 6);



More information about the Bf-blender-cvs mailing list