diff options
author | Hans Goudey <h.goudey@me.com> | 2021-08-31 01:54:43 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-08-31 01:54:43 +0300 |
commit | 3fec225931fd345c4d9b6fd57bc06ac6232dd789 (patch) | |
tree | c9ab69d68dd15f12bcec5c55edb41e199c7ee39f /source/blender | |
parent | f0443b88593e1964b64ae999d6b6297d55028267 (diff) |
Cleanup: Rename function, add comments
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/functions/FN_field.hh | 2 | ||||
-rw-r--r-- | source/blender/functions/intern/field.cc | 17 | ||||
-rw-r--r-- | source/blender/functions/tests/FN_field_test.cc | 2 |
3 files changed, 12 insertions, 9 deletions
diff --git a/source/blender/functions/FN_field.hh b/source/blender/functions/FN_field.hh index 14790d4e9e7..38aefde5e9f 100644 --- a/source/blender/functions/FN_field.hh +++ b/source/blender/functions/FN_field.hh @@ -154,7 +154,7 @@ class FieldInput { { } - virtual GVArrayPtr retrieve_data(IndexMask mask) const = 0; + virtual GVArrayPtr get_varray_generic_context(IndexMask mask) const = 0; blender::StringRef name() const { diff --git a/source/blender/functions/intern/field.cc b/source/blender/functions/intern/field.cc index 6750aac2fe4..0066a7973b2 100644 --- a/source/blender/functions/intern/field.cc +++ b/source/blender/functions/intern/field.cc @@ -20,6 +20,10 @@ #include "FN_field.hh" +/** + * TODO: There might be a more obvious way to implement this, or we might end up with + * a separate map for functions and inputs anyway, so we could just remove it. + */ struct InputOrFunction { const void *ptr; @@ -55,11 +59,6 @@ template<> struct blender::DefaultHash<InputOrFunction> { namespace blender::fn { /** - * A map to hold the output variables for each function or input so they can be reused. - */ -// using VariableMap = Map<const FunctionOrInput *, Vector<MFVariable *>>; - -/** * TODO: This exists because it seemed helpful for the procedure creation to be able to store * mutable data for each input or function output. That still may be helpful in the future, but * currently it isn't useful. @@ -71,6 +70,9 @@ struct FieldVariable { } }; +/** + * A map to hold the output variables for each function output or input so they can be reused. + */ using VariableMap = Map<InputOrFunction, Vector<FieldVariable>>; /** @@ -268,7 +270,7 @@ static void gather_inputs(const Span<Field> fields, const FieldInput &input = field.input(); const FieldVariable &variable = get_field_variable(field, unique_variables); if (!computed_inputs.contains(variable.mf_variable)) { - GVArrayPtr data = input.retrieve_data(mask); + GVArrayPtr data = input.get_varray_generic_context(mask); computed_inputs.add_new(variable.mf_variable); params.add_readonly_single_input(*data, input.name()); r_inputs.append(std::move(data)); @@ -328,7 +330,8 @@ void evaluate_fields(const Span<Field> fields, Vector<GMutableSpan> non_input_outputs{outputs}; 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()); + non_input_fields[i].input().get_varray_generic_context(mask)->materialize(mask, + outputs[i].data()); non_input_fields.remove_and_reorder(i); non_input_outputs.remove_and_reorder(i); diff --git a/source/blender/functions/tests/FN_field_test.cc b/source/blender/functions/tests/FN_field_test.cc index a002e286b45..d904f39d0d7 100644 --- a/source/blender/functions/tests/FN_field_test.cc +++ b/source/blender/functions/tests/FN_field_test.cc @@ -29,7 +29,7 @@ TEST(field, ConstantFunction) class IndexFieldInput final : public FieldInput { /* TODO: I don't think this is a valid way to override the name, but I wish it was. */ StringRef name_ = "Index"; - GVArrayPtr retrieve_data(IndexMask mask) const final + GVArrayPtr get_varray_generic_context(IndexMask mask) const final { auto index_func = [](int i) { return i; }; return std::make_unique< |