diff options
author | Jacques Lucke <jacques@blender.org> | 2020-11-12 18:31:32 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-11-12 18:31:32 +0300 |
commit | bc2230df715e222e344e7d0b07b9adcd41fc1d2c (patch) | |
tree | b7b0a7578f0c3486c4e9c33f7a7f38cd4316fd64 /source/blender/nodes/NOD_geometry_exec.hh | |
parent | caa942b03334b39869b0d417a5f4c5591c0c0ef0 (diff) |
Geometry Nodes: cleanup geometry node interface
Previously, the execution function of a geometry node has three parameters.
Now it has only one. This makes it easier to pass more information to the
execution function, that might only be used by a few nodes, because we
don't have to add more parameters that are unused in most cases.
Diffstat (limited to 'source/blender/nodes/NOD_geometry_exec.hh')
-rw-r--r-- | source/blender/nodes/NOD_geometry_exec.hh | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/source/blender/nodes/NOD_geometry_exec.hh b/source/blender/nodes/NOD_geometry_exec.hh index db28cdbd844..937a5a33ec8 100644 --- a/source/blender/nodes/NOD_geometry_exec.hh +++ b/source/blender/nodes/NOD_geometry_exec.hh @@ -38,37 +38,37 @@ using fn::CPPType; using fn::GMutablePointer; using fn::GValueMap; -class GeoNodeInputs { +class GeoNodeExecParams { private: - const bNode *node_; - GValueMap<StringRef> &values_; + const bNode &node_; + GValueMap<StringRef> &input_values_; + GValueMap<StringRef> &output_values_; const PersistentDataHandleMap &handle_map_; public: - GeoNodeInputs(const bNode &node, - GValueMap<StringRef> &values, - const PersistentDataHandleMap &handle_map) - : node_(&node), values_(values), handle_map_(handle_map) + GeoNodeExecParams(const bNode &node, + GValueMap<StringRef> &input_values, + GValueMap<StringRef> &output_values, + const PersistentDataHandleMap &handle_map) + : node_(node), + input_values_(input_values), + output_values_(output_values), + handle_map_(handle_map) { } - const PersistentDataHandleMap &handle_map() const - { - return handle_map_; - } - /** * Get the input value for the input socket with the given identifier. * * The node calling becomes responsible for destructing the value before it is done * executing. This method can only be called once for each identifier. */ - GMutablePointer extract(StringRef identifier) + GMutablePointer extract_input(StringRef identifier) { #ifdef DEBUG - this->check_extract(identifier); + this->check_extract_input(identifier); #endif - return values_.extract(identifier); + return input_values_.extract(identifier); } /** @@ -76,55 +76,55 @@ class GeoNodeInputs { * * This method can only be called once for each identifier. */ - template<typename T> T extract(StringRef identifier) + template<typename T> T extract_input(StringRef identifier) { #ifdef DEBUG - this->check_extract(identifier, &CPPType::get<T>()); + this->check_extract_input(identifier, &CPPType::get<T>()); #endif - return values_.extract<T>(identifier); - } - - private: - void check_extract(StringRef identifier, const CPPType *requested_type = nullptr); -}; - -class GeoNodeOutputs { - private: - const bNode *node_; - GValueMap<StringRef> &values_; - - public: - GeoNodeOutputs(const bNode &node, GValueMap<StringRef> &values) : node_(&node), values_(values) - { + return input_values_.extract<T>(identifier); } /** * Move-construct a new value based on the given value and store it for the given socket * identifier. */ - void set_by_move(StringRef identifier, GMutablePointer value) + void set_output_by_move(StringRef identifier, GMutablePointer value) { #ifdef DEBUG BLI_assert(value.type() != nullptr); BLI_assert(value.get() != nullptr); - this->check_set(identifier, *value.type()); + this->check_set_output(identifier, *value.type()); #endif - values_.add_new_by_move(identifier, value); + output_values_.add_new_by_move(identifier, value); } /** * Store the output value for the given socket identifier. */ - template<typename T> void set(StringRef identifier, T &&value) + template<typename T> void set_output(StringRef identifier, T &&value) { #ifdef DEBUG - this->check_set(identifier, CPPType::get<std::decay_t<T>>()); + this->check_set_output(identifier, CPPType::get<std::decay_t<T>>()); #endif - values_.add_new(identifier, std::forward<T>(value)); + output_values_.add_new(identifier, std::forward<T>(value)); + } + + /** + * Get the node that is currently being executed. + */ + const bNode &node() const + { + return node_; + } + + const PersistentDataHandleMap &handle_map() const + { + return handle_map_; } private: - void check_set(StringRef identifier, const CPPType &value_type); + void check_extract_input(StringRef identifier, const CPPType *requested_type = nullptr); + void check_set_output(StringRef identifier, const CPPType &value_type); }; } // namespace blender::nodes |