diff options
author | Jacques Lucke <jacques@blender.org> | 2022-06-03 14:51:05 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2022-06-03 14:51:05 +0300 |
commit | 6b84465352edebcc204d578221501073b7fa06d1 (patch) | |
tree | 982f569fa7e7a1a85f0930ce84555fe1d698063a | |
parent | 0a2a8d702ad28016eb73819dfd2be1b26f1cf05b (diff) |
Cleanup: remove dead code
-rw-r--r-- | source/blender/nodes/NOD_geometry_exec.hh | 41 | ||||
-rw-r--r-- | source/blender/nodes/intern/node_geometry_exec.cc | 131 |
2 files changed, 0 insertions, 172 deletions
diff --git a/source/blender/nodes/NOD_geometry_exec.hh b/source/blender/nodes/NOD_geometry_exec.hh index 8ffa9d978a8..b82c05f33be 100644 --- a/source/blender/nodes/NOD_geometry_exec.hh +++ b/source/blender/nodes/NOD_geometry_exec.hh @@ -298,47 +298,6 @@ class GeoNodeExecParams { */ void error_message_add(const NodeWarningType type, std::string message) const; - /** - * Creates a read-only attribute based on node inputs. The method automatically detects which - * input socket with the given name is available. - * - * \note This will add an error message if the string socket is active and - * the input attribute does not exist. - */ - GVArray get_input_attribute(const StringRef name, - const GeometryComponent &component, - eAttrDomain domain, - eCustomDataType type, - const void *default_value) const; - - template<typename T> - VArray<T> get_input_attribute(const StringRef name, - const GeometryComponent &component, - const eAttrDomain domain, - const T &default_value) const - { - const eCustomDataType type = bke::cpp_type_to_custom_data_type(CPPType::get<T>()); - GVArray varray = this->get_input_attribute(name, component, domain, type, &default_value); - return varray.typed<T>(); - } - - /** - * Get the type of an input property or the associated constant socket types with the - * same names. Fall back to the default value if no attribute exists with the name. - */ - eCustomDataType get_input_attribute_data_type(const StringRef name, - const GeometryComponent &component, - eCustomDataType default_type) const; - - /** - * If any of the corresponding input sockets are attributes instead of single values, - * use the highest priority attribute domain from among them. - * Otherwise return the default domain. - */ - eAttrDomain get_highest_priority_input_domain(Span<std::string> names, - const GeometryComponent &component, - eAttrDomain default_domain) const; - std::string attribute_producer_name() const; void set_default_remaining_outputs(); diff --git a/source/blender/nodes/intern/node_geometry_exec.cc b/source/blender/nodes/intern/node_geometry_exec.cc index 27ad12ba252..56e9c9f0496 100644 --- a/source/blender/nodes/intern/node_geometry_exec.cc +++ b/source/blender/nodes/intern/node_geometry_exec.cc @@ -110,137 +110,6 @@ const bNodeSocket *GeoNodeExecParams::find_available_socket(const StringRef name return nullptr; } -GVArray GeoNodeExecParams::get_input_attribute(const StringRef name, - const GeometryComponent &component, - const eAttrDomain domain, - const eCustomDataType type, - const void *default_value) const -{ - const bNodeSocket *found_socket = this->find_available_socket(name); - BLI_assert(found_socket != nullptr); /* There should always be available socket for the name. */ - const CPPType *cpp_type = bke::custom_data_type_to_cpp_type(type); - const int64_t domain_num = component.attribute_domain_num(domain); - - if (default_value == nullptr) { - default_value = cpp_type->default_value(); - } - - if (found_socket == nullptr) { - return GVArray::ForSingle(*cpp_type, domain_num, default_value); - } - - if (found_socket->type == SOCK_STRING) { - const std::string name = this->get_input<std::string>(found_socket->identifier); - /* Try getting the attribute without the default value. */ - GVArray attribute = component.attribute_try_get_for_read(name, domain, type); - if (attribute) { - return attribute; - } - - /* If the attribute doesn't exist, use the default value and output an error message - * (except when the field is empty, to avoid spamming error messages, and not when - * the domain is empty and we don't expect an attribute anyway). */ - if (!name.empty() && component.attribute_domain_num(domain) != 0) { - this->error_message_add(NodeWarningType::Error, - TIP_("No attribute with name \"") + name + "\""); - } - return GVArray::ForSingle(*cpp_type, domain_num, default_value); - } - const bke::DataTypeConversions &conversions = bke::get_implicit_type_conversions(); - if (found_socket->type == SOCK_FLOAT) { - const float value = this->get_input<float>(found_socket->identifier); - BUFFER_FOR_CPP_TYPE_VALUE(*cpp_type, buffer); - conversions.convert_to_uninitialized(CPPType::get<float>(), *cpp_type, &value, buffer); - return GVArray::ForSingle(*cpp_type, domain_num, buffer); - } - if (found_socket->type == SOCK_INT) { - const int value = this->get_input<int>(found_socket->identifier); - BUFFER_FOR_CPP_TYPE_VALUE(*cpp_type, buffer); - conversions.convert_to_uninitialized(CPPType::get<int>(), *cpp_type, &value, buffer); - return GVArray::ForSingle(*cpp_type, domain_num, buffer); - } - if (found_socket->type == SOCK_VECTOR) { - const float3 value = this->get_input<float3>(found_socket->identifier); - BUFFER_FOR_CPP_TYPE_VALUE(*cpp_type, buffer); - conversions.convert_to_uninitialized(CPPType::get<float3>(), *cpp_type, &value, buffer); - return GVArray::ForSingle(*cpp_type, domain_num, buffer); - } - if (found_socket->type == SOCK_RGBA) { - const ColorGeometry4f value = this->get_input<ColorGeometry4f>(found_socket->identifier); - BUFFER_FOR_CPP_TYPE_VALUE(*cpp_type, buffer); - conversions.convert_to_uninitialized( - CPPType::get<ColorGeometry4f>(), *cpp_type, &value, buffer); - return GVArray::ForSingle(*cpp_type, domain_num, buffer); - } - BLI_assert(false); - return GVArray::ForSingle(*cpp_type, domain_num, default_value); -} - -eCustomDataType GeoNodeExecParams::get_input_attribute_data_type( - const StringRef name, - const GeometryComponent &component, - const eCustomDataType default_type) const -{ - const bNodeSocket *found_socket = this->find_available_socket(name); - BLI_assert(found_socket != nullptr); /* There should always be available socket for the name. */ - if (found_socket == nullptr) { - return default_type; - } - - if (found_socket->type == SOCK_STRING) { - const std::string name = this->get_input<std::string>(found_socket->identifier); - std::optional<AttributeMetaData> info = component.attribute_get_meta_data(name); - if (info) { - return info->data_type; - } - return default_type; - } - if (found_socket->type == SOCK_FLOAT) { - return CD_PROP_FLOAT; - } - if (found_socket->type == SOCK_VECTOR) { - return CD_PROP_FLOAT3; - } - if (found_socket->type == SOCK_RGBA) { - return CD_PROP_COLOR; - } - if (found_socket->type == SOCK_BOOLEAN) { - return CD_PROP_BOOL; - } - - BLI_assert(false); - return default_type; -} - -eAttrDomain GeoNodeExecParams::get_highest_priority_input_domain( - Span<std::string> names, - const GeometryComponent &component, - const eAttrDomain default_domain) const -{ - Vector<eAttrDomain, 8> input_domains; - for (const std::string &name : names) { - const bNodeSocket *found_socket = this->find_available_socket(name); - BLI_assert(found_socket != nullptr); /* A socket should be available socket for the name. */ - if (found_socket == nullptr) { - continue; - } - - if (found_socket->type == SOCK_STRING) { - const std::string name = this->get_input<std::string>(found_socket->identifier); - std::optional<AttributeMetaData> info = component.attribute_get_meta_data(name); - if (info) { - input_domains.append(info->domain); - } - } - } - - if (input_domains.size() > 0) { - return bke::attribute_domain_highest_priority(input_domains); - } - - return default_domain; -} - std::string GeoNodeExecParams::attribute_producer_name() const { return provider_->dnode->label_or_name() + TIP_(" node"); |