[Bf-blender-cvs] [70d493e5ee7] geometry-nodes: Geometry Nodes: allow getting inputs without removing them

Jacques Lucke noreply at git.blender.org
Fri Nov 20 17:36:39 CET 2020


Commit: 70d493e5ee7960893131417c9ec2463ba8d99e18
Author: Jacques Lucke
Date:   Fri Nov 20 17:31:46 2020 +0100
Branches: geometry-nodes
https://developer.blender.org/rB70d493e5ee7960893131417c9ec2463ba8d99e18

Geometry Nodes: allow getting inputs without removing them

This is useful when one wants to get an input value multiple times.

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

M	source/blender/nodes/NOD_geometry_exec.hh
M	source/blender/nodes/intern/node_geometry_exec.cc

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

diff --git a/source/blender/nodes/NOD_geometry_exec.hh b/source/blender/nodes/NOD_geometry_exec.hh
index 912f45c6d58..086ce76c851 100644
--- a/source/blender/nodes/NOD_geometry_exec.hh
+++ b/source/blender/nodes/NOD_geometry_exec.hh
@@ -89,6 +89,20 @@ class GeoNodeExecParams {
     return input_values_.extract<T>(identifier);
   }
 
+  /**
+   * Get the input value for the input socket with the given identifier.
+   *
+   * This makes a copy of the value, which is fine for most types but should be avoided for
+   * geometry sets.
+   */
+  template<typename T> T get_input(StringRef identifier) const
+  {
+#ifdef DEBUG
+    this->check_extract_input(identifier, &CPPType::get<T>());
+#endif
+    return input_values_.lookup<T>(identifier);
+  }
+
   /**
    * Move-construct a new value based on the given value and store it for the given socket
    * identifier.
@@ -133,8 +147,8 @@ class GeoNodeExecParams {
   }
 
  private:
-  void check_extract_input(StringRef identifier, const CPPType *requested_type = nullptr);
-  void check_set_output(StringRef identifier, const CPPType &value_type);
+  void check_extract_input(StringRef identifier, const CPPType *requested_type = nullptr) const;
+  void check_set_output(StringRef identifier, const CPPType &value_type) const;
 };
 
 }  // namespace blender::nodes
diff --git a/source/blender/nodes/intern/node_geometry_exec.cc b/source/blender/nodes/intern/node_geometry_exec.cc
index 7f841027006..50292cb8cfb 100644
--- a/source/blender/nodes/intern/node_geometry_exec.cc
+++ b/source/blender/nodes/intern/node_geometry_exec.cc
@@ -19,7 +19,8 @@
 
 namespace blender::nodes {
 
-void GeoNodeExecParams::check_extract_input(StringRef identifier, const CPPType *requested_type)
+void GeoNodeExecParams::check_extract_input(StringRef identifier,
+                                            const CPPType *requested_type) const
 {
   bNodeSocket *found_socket = nullptr;
   LISTBASE_FOREACH (bNodeSocket *, socket, &node_.inputs) {
@@ -60,7 +61,7 @@ void GeoNodeExecParams::check_extract_input(StringRef identifier, const CPPType
   }
 }
 
-void GeoNodeExecParams::check_set_output(StringRef identifier, const CPPType &value_type)
+void GeoNodeExecParams::check_set_output(StringRef identifier, const CPPType &value_type) const
 {
   bNodeSocket *found_socket = nullptr;
   LISTBASE_FOREACH (bNodeSocket *, socket, &node_.outputs) {



More information about the Bf-blender-cvs mailing list