[Bf-blender-cvs] [a3457704fb6] master: Geometry Nodes: De-duplicate index input nodes during evaluation

Hans Goudey noreply at git.blender.org
Tue Oct 19 03:14:07 CEST 2021


Commit: a3457704fb63a59045b093dc4499b43f6676fabb
Author: Hans Goudey
Date:   Mon Oct 18 20:13:37 2021 -0500
Branches: master
https://developer.blender.org/rBa3457704fb63a59045b093dc4499b43f6676fabb

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.

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

M	source/blender/functions/FN_field.hh
M	source/blender/functions/intern/field.cc

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

diff --git a/source/blender/functions/FN_field.hh b/source/blender/functions/FN_field.hh
index 2fca78fa6e7..78a49e342a5 100644
--- a/source/blender/functions/FN_field.hh
+++ b/source/blender/functions/FN_field.hh
@@ -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;
 };
 
 /** \} */
diff --git a/source/blender/functions/intern/field.cc b/source/blender/functions/intern/field.cc
index 03af3f53065..1f7bad134a8 100644
--- a/source/blender/functions/intern/field.cc
+++ b/source/blender/functions/intern/field.cc
@@ -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.
  */



More information about the Bf-blender-cvs mailing list