diff options
author | Jacques Lucke <jacques@blender.org> | 2021-08-31 14:22:05 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-08-31 14:22:05 +0300 |
commit | a275572e0b9d6c96b10bfac33a31310c7231d5eb (patch) | |
tree | e39d2d92bb123530134ea8575fdf47296ec7380a | |
parent | 9ec7e23c44791e4d20b7ec40d228fdd4b028d702 (diff) |
fix string socket
-rw-r--r-- | source/blender/functions/intern/cpp_types.cc | 1 | ||||
-rw-r--r-- | source/blender/nodes/NOD_geometry_exec.hh | 12 | ||||
-rw-r--r-- | source/blender/nodes/intern/node_socket.cc | 11 |
3 files changed, 19 insertions, 5 deletions
diff --git a/source/blender/functions/intern/cpp_types.cc b/source/blender/functions/intern/cpp_types.cc index 92ebfd5edf2..058fb76af2b 100644 --- a/source/blender/functions/intern/cpp_types.cc +++ b/source/blender/functions/intern/cpp_types.cc @@ -46,5 +46,6 @@ MAKE_FIELD_CPP_TYPE(Float3Field, float3); MAKE_FIELD_CPP_TYPE(ColorGeometry4fField, blender::ColorGeometry4f); MAKE_FIELD_CPP_TYPE(BoolField, bool); MAKE_FIELD_CPP_TYPE(Int32Field, int32_t); +MAKE_FIELD_CPP_TYPE(StringField, std::string); } // namespace blender::fn diff --git a/source/blender/nodes/NOD_geometry_exec.hh b/source/blender/nodes/NOD_geometry_exec.hh index f9a40e48d53..6c49e71d7ab 100644 --- a/source/blender/nodes/NOD_geometry_exec.hh +++ b/source/blender/nodes/NOD_geometry_exec.hh @@ -130,7 +130,8 @@ class GeoNodeExecParams { std::is_same_v<T, int> || std::is_same_v<T, bool> || std::is_same_v<T, ColorGeometry4f> || - std::is_same_v<T, float3>; + std::is_same_v<T, float3> || + std::is_same_v<T, std::string>; /** * Get the input value for the input socket with the given identifier. @@ -173,11 +174,16 @@ class GeoNodeExecParams { */ template<typename T> Vector<T> extract_multi_input(StringRef identifier) { - // static_assert(!is_stored_as_field_v<T>); Vector<GMutablePointer> gvalues = provider_->extract_multi_input(identifier); Vector<T> values; for (GMutablePointer gvalue : gvalues) { - values.append(gvalue.relocate_out<T>()); + if constexpr (is_stored_as_field_v<T>) { + const Field<T> &field = *gvalue.get<Field<T>>(); + values.append(fn::evaluate_constant_field(field)); + } + else { + values.append(gvalue.relocate_out<T>()); + } } return values; } diff --git a/source/blender/nodes/intern/node_socket.cc b/source/blender/nodes/intern/node_socket.cc index 383153df756..8efd6c55459 100644 --- a/source/blender/nodes/intern/node_socket.cc +++ b/source/blender/nodes/intern/node_socket.cc @@ -795,8 +795,15 @@ static bNodeSocketType *make_socket_type_string() socktype->get_base_cpp_value = [](const bNodeSocket &socket, void *r_value) { new (r_value) std::string(((bNodeSocketValueString *)socket.default_value)->value); }; - socktype->get_geometry_nodes_cpp_type = socktype->get_base_cpp_type; - socktype->get_geometry_nodes_cpp_value = socktype->get_base_cpp_value; + socktype->get_geometry_nodes_cpp_type = []() { + return &blender::fn::CPPType::get<blender::fn::Field<std::string>>(); + }; + socktype->get_geometry_nodes_cpp_value = [](const bNodeSocket &socket, void *r_value) { + std::string value; + value.~basic_string(); + socket.typeinfo->get_base_cpp_value(socket, &value); + new (r_value) blender::fn::Field<std::string>(blender::fn::make_constant_field(value)); + }; return socktype; } |