Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2021-08-28 08:21:01 +0300
committerHans Goudey <h.goudey@me.com>2021-08-28 08:21:01 +0300
commitb3cc26bf35237825965070261e3198e28e43f960 (patch)
treed8684d2a4a51b966e0d3f0f85497abde0dd8b4c7
parent5f29552be79cdb46e8e36845ed6ce1caf0feabed (diff)
Add another very simple passing test
-rw-r--r--source/blender/functions/intern/field.cc2
-rw-r--r--source/blender/functions/tests/FN_field_test.cc25
2 files changed, 23 insertions, 4 deletions
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);