Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/NOD_geometry_exec.hh
| Show All 18 Lines | |||||
| #include "FN_generic_value_map.hh" | #include "FN_generic_value_map.hh" | ||||
| #include "BKE_attribute_access.hh" | #include "BKE_attribute_access.hh" | ||||
| #include "BKE_geometry_set.hh" | #include "BKE_geometry_set.hh" | ||||
| #include "BKE_persistent_data_handle.hh" | #include "BKE_persistent_data_handle.hh" | ||||
| #include "DNA_node_types.h" | #include "DNA_node_types.h" | ||||
| struct Depsgraph; | |||||
| namespace blender::nodes { | namespace blender::nodes { | ||||
| using bke::BooleanReadAttribute; | using bke::BooleanReadAttribute; | ||||
| using bke::BooleanWriteAttribute; | using bke::BooleanWriteAttribute; | ||||
| using bke::Color4fReadAttribute; | using bke::Color4fReadAttribute; | ||||
| using bke::Color4fWriteAttribute; | using bke::Color4fWriteAttribute; | ||||
| using bke::Float2ReadAttribute; | |||||
| using bke::Float2WriteAttribute; | |||||
| using bke::Float3ReadAttribute; | using bke::Float3ReadAttribute; | ||||
| using bke::Float3WriteAttribute; | using bke::Float3WriteAttribute; | ||||
| using bke::FloatReadAttribute; | using bke::FloatReadAttribute; | ||||
| using bke::FloatWriteAttribute; | using bke::FloatWriteAttribute; | ||||
| using bke::Int32ReadAttribute; | using bke::Int32ReadAttribute; | ||||
| using bke::Int32WriteAttribute; | using bke::Int32WriteAttribute; | ||||
| using bke::PersistentDataHandleMap; | using bke::PersistentDataHandleMap; | ||||
| using bke::PersistentObjectHandle; | using bke::PersistentObjectHandle; | ||||
| using bke::ReadAttribute; | using bke::ReadAttribute; | ||||
| using bke::ReadAttributePtr; | using bke::ReadAttributePtr; | ||||
| using bke::WriteAttribute; | using bke::WriteAttribute; | ||||
| using bke::WriteAttributePtr; | using bke::WriteAttributePtr; | ||||
| using fn::CPPType; | using fn::CPPType; | ||||
| using fn::GMutablePointer; | using fn::GMutablePointer; | ||||
| using fn::GPointer; | using fn::GPointer; | ||||
| using fn::GValueMap; | using fn::GValueMap; | ||||
| class GeoNodeExecParams { | class GeoNodeExecParams { | ||||
| private: | private: | ||||
| const bNode &node_; | const bNode &node_; | ||||
| GValueMap<StringRef> &input_values_; | GValueMap<StringRef> &input_values_; | ||||
| GValueMap<StringRef> &output_values_; | GValueMap<StringRef> &output_values_; | ||||
| const PersistentDataHandleMap &handle_map_; | const PersistentDataHandleMap &handle_map_; | ||||
| const Object *self_object_; | const Object *self_object_; | ||||
| Depsgraph *depsgraph_; | |||||
| public: | public: | ||||
| GeoNodeExecParams(const bNode &node, | GeoNodeExecParams(const bNode &node, | ||||
| GValueMap<StringRef> &input_values, | GValueMap<StringRef> &input_values, | ||||
| GValueMap<StringRef> &output_values, | GValueMap<StringRef> &output_values, | ||||
| const PersistentDataHandleMap &handle_map, | const PersistentDataHandleMap &handle_map, | ||||
| const Object *self_object) | const Object *self_object, | ||||
| Depsgraph *depsgraph) | |||||
| : node_(node), | : node_(node), | ||||
| input_values_(input_values), | input_values_(input_values), | ||||
| output_values_(output_values), | output_values_(output_values), | ||||
| handle_map_(handle_map), | handle_map_(handle_map), | ||||
| self_object_(self_object) | self_object_(self_object), | ||||
| depsgraph_(depsgraph) | |||||
| { | { | ||||
| } | } | ||||
| /** | /** | ||||
| * Get the input value for the input socket with the given identifier. | * 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 | * The node calling becomes responsible for destructing the value before it is done | ||||
| * executing. This method can only be called once for each identifier. | * executing. This method can only be called once for each identifier. | ||||
| Show All 15 Lines | #endif | ||||
| { | { | ||||
| #ifdef DEBUG | #ifdef DEBUG | ||||
| this->check_extract_input(identifier, &CPPType::get<T>()); | this->check_extract_input(identifier, &CPPType::get<T>()); | ||||
| #endif | #endif | ||||
| return input_values_.extract<T>(identifier); | return input_values_.extract<T>(identifier); | ||||
| } | } | ||||
| /** | /** | ||||
| * Get input as vector for multi input socket with the given identifier. | |||||
| * | |||||
| * This method can only be called once for each identifier. | |||||
| */ | |||||
| template<typename T> Vector<T> extract_multi_input(StringRef identifier) | |||||
| { | |||||
| Vector<T> values; | |||||
| values.append(input_values_.extract<T>(identifier)); | |||||
| int i = 1; | |||||
| std::string sub_identifier = identifier + "[1]"; | |||||
| while (input_values_.contains(sub_identifier)) { | |||||
| values.append(input_values_.extract<T>(sub_identifier)); | |||||
| i++; | |||||
| sub_identifier = identifier + "[" + std::to_string(i) + "]"; | |||||
| } | |||||
| return values; | |||||
| } | |||||
| /** | |||||
| * Get the input value for the input socket with the given 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 | * This makes a copy of the value, which is fine for most types but should be avoided for | ||||
| * geometry sets. | * geometry sets. | ||||
| */ | */ | ||||
| template<typename T> T get_input(StringRef identifier) const | template<typename T> T get_input(StringRef identifier) const | ||||
| { | { | ||||
| #ifdef DEBUG | #ifdef DEBUG | ||||
| ▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | const PersistentDataHandleMap &handle_map() const | ||||
| return handle_map_; | return handle_map_; | ||||
| } | } | ||||
| const Object *self_object() const | const Object *self_object() const | ||||
| { | { | ||||
| return self_object_; | return self_object_; | ||||
| } | } | ||||
| Depsgraph *depsgraph() const | |||||
| { | |||||
| return depsgraph_; | |||||
| } | |||||
| /** | /** | ||||
| * Creates a read-only attribute based on node inputs. The method automatically detects which | * Creates a read-only attribute based on node inputs. The method automatically detects which | ||||
| * input with the given name is available. | * input with the given name is available. | ||||
| */ | */ | ||||
| ReadAttributePtr get_input_attribute(const StringRef name, | ReadAttributePtr get_input_attribute(const StringRef name, | ||||
| const GeometryComponent &component, | const GeometryComponent &component, | ||||
| const AttributeDomain domain, | const AttributeDomain domain, | ||||
| const CustomDataType type, | const CustomDataType type, | ||||
| Show All 30 Lines | |||||