Geometry Nodes: De-duplicate index input nodes during evaluation

We do this in other nodes to reduce overhead of using the same node more
than once. I don't think it will make a difference with index nodes
currently, but at least it's consistent.
This commit is contained in:
Hans Goudey 2021-10-18 20:13:37 -05:00
parent 482c5f0014
commit a3457704fb
2 changed files with 14 additions and 0 deletions

View File

@ -421,6 +421,9 @@ class IndexFieldInput final : public FieldInput {
const GVArray *get_varray_for_context(const FieldContext &context,
IndexMask mask,
ResourceScope &scope) const final;
uint64_t hash() const override;
bool is_equal_to(const fn::FieldNode &other) const override;
};
/** \} */

View File

@ -530,6 +530,17 @@ const GVArray *IndexFieldInput::get_varray_for_context(const fn::FieldContext &U
mask.min_array_size(), mask.min_array_size(), index_func);
}
uint64_t IndexFieldInput::hash() const
{
/* Some random constant hash. */
return 128736487678;
}
bool IndexFieldInput::is_equal_to(const fn::FieldNode &other) const
{
return dynamic_cast<const IndexFieldInput *>(&other) != nullptr;
}
/* --------------------------------------------------------------------
* FieldOperation.
*/