diff options
Diffstat (limited to 'source/blender/nodes')
5 files changed, 27 insertions, 51 deletions
diff --git a/source/blender/nodes/geometry/CMakeLists.txt b/source/blender/nodes/geometry/CMakeLists.txt index 2b8de906a77..930f9731258 100644 --- a/source/blender/nodes/geometry/CMakeLists.txt +++ b/source/blender/nodes/geometry/CMakeLists.txt @@ -173,7 +173,6 @@ set(SRC nodes/node_geo_volume_cube.cc nodes/node_geo_volume_to_mesh.cc - node_geometry_exec.cc node_geometry_tree.cc node_geometry_util.cc diff --git a/source/blender/nodes/geometry/node_geometry_exec.cc b/source/blender/nodes/geometry/node_geometry_exec.cc deleted file mode 100644 index ef4daf94bbe..00000000000 --- a/source/blender/nodes/geometry/node_geometry_exec.cc +++ /dev/null @@ -1,7 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ - -#include "BLI_cpp_type_make.hh" -#include "NOD_geometry_exec.hh" - -BLI_CPP_TYPE_MAKE(GeometrySet, GeometrySet, CPPTypeFlags::Printable); -BLI_CPP_TYPE_MAKE(GeometrySetVector, blender::Vector<GeometrySet>, CPPTypeFlags::None); diff --git a/source/blender/nodes/intern/geometry_nodes_lazy_function.cc b/source/blender/nodes/intern/geometry_nodes_lazy_function.cc index 96c369f2f6b..d9e82c6b4ee 100644 --- a/source/blender/nodes/intern/geometry_nodes_lazy_function.cc +++ b/source/blender/nodes/intern/geometry_nodes_lazy_function.cc @@ -16,6 +16,7 @@ #include "NOD_multi_function.hh" #include "NOD_node_declaration.hh" +#include "BLI_cpp_types.hh" #include "BLI_lazy_threading.hh" #include "BLI_map.hh" @@ -53,14 +54,11 @@ static const CPPType *get_socket_cpp_type(const bNodeSocket &socket) static const CPPType *get_vector_type(const CPPType &type) { - /* This could be generalized in the future. For now we only support a small set of vectors. */ - if (type.is<GeometrySet>()) { - return &CPPType::get<Vector<GeometrySet>>(); - } - if (type.is<ValueOrField<std::string>>()) { - return &CPPType::get<Vector<ValueOrField<std::string>>>(); + const VectorCPPType *vector_type = VectorCPPType::get_from_value(type); + if (vector_type == nullptr) { + return nullptr; } - return nullptr; + return &vector_type->self; } /** @@ -296,19 +294,17 @@ static void execute_multi_function_on_value_or_field( for (const int i : input_types.index_range()) { const ValueOrFieldCPPType &type = *input_types[i]; - const CPPType &base_type = type.base_type(); const void *value_or_field = input_values[i]; const void *value = type.get_value_ptr(value_or_field); - params.add_readonly_single_input(GVArray::ForSingleRef(base_type, 1, value)); + params.add_readonly_single_input(GVArray::ForSingleRef(type.value, 1, value)); } for (const int i : output_types.index_range()) { const ValueOrFieldCPPType &type = *output_types[i]; - const CPPType &base_type = type.base_type(); void *value_or_field = output_values[i]; - type.default_construct(value_or_field); + type.self.default_construct(value_or_field); void *value = type.get_value_ptr(value_or_field); - base_type.destruct(value); - params.add_uninitialized_single_output(GMutableSpan{base_type, value, 1}); + type.value.destruct(value); + params.add_uninitialized_single_output(GMutableSpan{type.value, value, 1}); } fn.call(IndexRange(1), params, context); } @@ -380,16 +376,14 @@ class LazyFunctionForMutedNode : public LazyFunction { } /* Perform a type conversion and then format the value. */ const bke::DataTypeConversions &conversions = bke::get_implicit_type_conversions(); - const auto *from_field_type = dynamic_cast<const ValueOrFieldCPPType *>(&input_type); - const auto *to_field_type = dynamic_cast<const ValueOrFieldCPPType *>(&output_type); - if (from_field_type != nullptr && to_field_type != nullptr) { - const CPPType &from_base_type = from_field_type->base_type(); - const CPPType &to_base_type = to_field_type->base_type(); - if (conversions.is_convertible(from_base_type, to_base_type)) { + const auto *from_type = ValueOrFieldCPPType::get_from_self(input_type); + const auto *to_type = ValueOrFieldCPPType::get_from_self(output_type); + if (from_type != nullptr && to_type != nullptr) { + if (conversions.is_convertible(from_type->value, to_type->value)) { const MultiFunction &multi_fn = *conversions.get_conversion_multi_function( - MFDataType::ForSingle(from_base_type), MFDataType::ForSingle(to_base_type)); + MFDataType::ForSingle(from_type->value), MFDataType::ForSingle(to_type->value)); execute_multi_function_on_value_or_field( - multi_fn, {}, {from_field_type}, {to_field_type}, {input_value}, {output_value}); + multi_fn, {}, {from_type}, {to_type}, {input_value}, {output_value}); } params.output_set(output_i); continue; @@ -420,8 +414,8 @@ class LazyFunctionForMultiFunctionConversion : public LazyFunction { : fn_(fn), from_type_(from), to_type_(to), target_sockets_(std::move(target_sockets)) { debug_name_ = "Convert"; - inputs_.append({"From", from}); - outputs_.append({"To", to}); + inputs_.append({"From", from.self}); + outputs_.append({"To", to.self}); } void execute_impl(lf::Params ¶ms, const lf::Context & /*context*/) const override @@ -458,10 +452,10 @@ class LazyFunctionForMultiFunctionNode : public LazyFunction { debug_name_ = node.name; lazy_function_interface_from_node(node, r_used_inputs, r_used_outputs, inputs_, outputs_); for (const lf::Input &fn_input : inputs_) { - input_types_.append(dynamic_cast<const ValueOrFieldCPPType *>(fn_input.type)); + input_types_.append(ValueOrFieldCPPType::get_from_self(*fn_input.type)); } for (const lf::Output &fn_output : outputs_) { - output_types_.append(dynamic_cast<const ValueOrFieldCPPType *>(fn_output.type)); + output_types_.append(ValueOrFieldCPPType::get_from_self(*fn_output.type)); } } @@ -552,8 +546,7 @@ class LazyFunctionForViewerNode : public LazyFunction { if (use_field_input_) { const void *value_or_field = params.try_get_input_data_ptr(1); BLI_assert(value_or_field != nullptr); - const ValueOrFieldCPPType &value_or_field_type = static_cast<const ValueOrFieldCPPType &>( - *inputs_[1].type); + const auto &value_or_field_type = *ValueOrFieldCPPType::get_from_self(*inputs_[1].type); GField field = value_or_field_type.as_field(value_or_field); const eAttrDomain domain = eAttrDomain(storage->domain); const StringRefNull viewer_attribute_name = ".viewer"; @@ -1193,14 +1186,13 @@ struct GeometryNodesLazyFunctionGraphBuilder { if (from_type == to_type) { return &from_socket; } - const auto *from_field_type = dynamic_cast<const ValueOrFieldCPPType *>(&from_type); - const auto *to_field_type = dynamic_cast<const ValueOrFieldCPPType *>(&to_type); + const auto *from_field_type = ValueOrFieldCPPType::get_from_self(from_type); + const auto *to_field_type = ValueOrFieldCPPType::get_from_self(to_type); if (from_field_type != nullptr && to_field_type != nullptr) { - const CPPType &from_base_type = from_field_type->base_type(); - const CPPType &to_base_type = to_field_type->base_type(); - if (conversions_->is_convertible(from_base_type, to_base_type)) { + if (conversions_->is_convertible(from_field_type->value, to_field_type->value)) { const MultiFunction &multi_fn = *conversions_->get_conversion_multi_function( - MFDataType::ForSingle(from_base_type), MFDataType::ForSingle(to_base_type)); + MFDataType::ForSingle(from_field_type->value), + MFDataType::ForSingle(to_field_type->value)); auto fn = std::make_unique<LazyFunctionForMultiFunctionConversion>( multi_fn, *from_field_type, *to_field_type, std::move(target_sockets)); lf::Node &conversion_node = lf_graph_->add_function(*fn); diff --git a/source/blender/nodes/intern/geometry_nodes_log.cc b/source/blender/nodes/intern/geometry_nodes_log.cc index 0f122307328..640296ead66 100644 --- a/source/blender/nodes/intern/geometry_nodes_log.cc +++ b/source/blender/nodes/intern/geometry_nodes_log.cc @@ -166,10 +166,9 @@ void GeoTreeLogger::log_value(const bNode &node, const bNodeSocket &socket, cons const GeometrySet &geometry = *value.get<GeometrySet>(); store_logged_value(this->allocator->construct<GeometryInfoLog>(geometry)); } - else if (const auto *value_or_field_type = dynamic_cast<const fn::ValueOrFieldCPPType *>( - &type)) { + else if (const auto *value_or_field_type = fn::ValueOrFieldCPPType::get_from_self(type)) { const void *value_or_field = value.get(); - const CPPType &base_type = value_or_field_type->base_type(); + const CPPType &base_type = value_or_field_type->value; if (value_or_field_type->is_field(value_or_field)) { const GField *field = value_or_field_type->get_field_ptr(value_or_field); if (field->node().depends_on_input()) { diff --git a/source/blender/nodes/intern/node_socket.cc b/source/blender/nodes/intern/node_socket.cc index f2f4519625a..6d02ed7d553 100644 --- a/source/blender/nodes/intern/node_socket.cc +++ b/source/blender/nodes/intern/node_socket.cc @@ -10,7 +10,6 @@ #include "DNA_node_types.h" #include "BLI_color.hh" -#include "BLI_cpp_type_make.hh" #include "BLI_listbase.h" #include "BLI_math_vec_types.hh" #include "BLI_string.h" @@ -779,12 +778,6 @@ static bNodeSocketType *make_socket_type_string() return socktype; } -BLI_CPP_TYPE_MAKE(Object, Object *, CPPTypeFlags::BasicType) -BLI_CPP_TYPE_MAKE(Collection, Collection *, CPPTypeFlags::BasicType) -BLI_CPP_TYPE_MAKE(Texture, Tex *, CPPTypeFlags::BasicType) -BLI_CPP_TYPE_MAKE(Image, Image *, CPPTypeFlags::BasicType) -BLI_CPP_TYPE_MAKE(Material, Material *, CPPTypeFlags::BasicType) - static bNodeSocketType *make_socket_type_object() { bNodeSocketType *socktype = make_standard_socket_type(SOCK_OBJECT, PROP_NONE); |