From 88ce58b0d210bf49e29444cd90708eb6db2a17fa Mon Sep 17 00:00:00 2001 From: illua1 Date: Thu, 15 Dec 2022 23:54:05 +0300 Subject: [PATCH 01/14] / --- release/datafiles/locale | 2 +- release/scripts/addons | 2 +- release/scripts/addons_contrib | 2 +- .../blender/editors/space_node/node_draw.cc | 54 +++++++++++-------- .../blender/nodes/NOD_geometry_nodes_log.hh | 2 + .../nodes/intern/geometry_nodes_log.cc | 13 +++++ source/tools | 2 +- 7 files changed, 51 insertions(+), 26 deletions(-) diff --git a/release/datafiles/locale b/release/datafiles/locale index 4a581c54af9..8b4e4e91904 160000 --- a/release/datafiles/locale +++ b/release/datafiles/locale @@ -1 +1 @@ -Subproject commit 4a581c54af9b92cb670d750951b9382160f10f3e +Subproject commit 8b4e4e9190467e0d71f200681681b9d67281d01d diff --git a/release/scripts/addons b/release/scripts/addons index 0b0052bd53a..d4c8ec5cdff 160000 --- a/release/scripts/addons +++ b/release/scripts/addons @@ -1 +1 @@ -Subproject commit 0b0052bd53ad8249ed07dfb87705c338af698bde +Subproject commit d4c8ec5cdff2337c34838b2ff83108697e1d4abe diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib index 96143b1a8b0..bdcfdd47ec3 160000 --- a/release/scripts/addons_contrib +++ b/release/scripts/addons_contrib @@ -1 +1 @@ -Subproject commit 96143b1a8b037ea3c81f065f557025db9fe1ace3 +Subproject commit bdcfdd47ec3451822b21d1cff2ea2db751093c9a diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index 2790e8de6a8..11f7b6e84a0 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -1039,32 +1039,42 @@ static std::optional create_socket_inspection_string(TreeDrawContex } tree_draw_ctx.geo_tree_log->ensure_socket_values(); - ValueLog *value_log = tree_draw_ctx.geo_tree_log->find_socket_value_log(socket); - if (value_log == nullptr) { - return std::nullopt; - } + + bool newline = false; std::stringstream ss; - if (const geo_log::GenericValueLog *generic_value_log = - dynamic_cast(value_log)) { - create_inspection_string_for_generic_value(socket, generic_value_log->value, ss); - } - else if (const geo_log::FieldInfoLog *gfield_value_log = - dynamic_cast(value_log)) { - create_inspection_string_for_field_info(socket, *gfield_value_log, ss); - } - else if (const geo_log::GeometryInfoLog *geo_value_log = - dynamic_cast(value_log)) { - create_inspection_string_for_geometry_info( - *geo_value_log, - ss, - dynamic_cast(socket.runtime->declaration)); - } + tree_draw_ctx.geo_tree_log->socket_logs_callback(socket, [&](const ValueLog *value_log){ + if (newline){ + ss << "\n"; + } + if (value_log == nullptr) { + return; + } + + if (const geo_log::GenericValueLog *generic_value_log = + dynamic_cast(value_log)) { + create_inspection_string_for_generic_value(socket, generic_value_log->value, ss); + } + else if (const geo_log::FieldInfoLog *gfield_value_log = + dynamic_cast(value_log)) { + create_inspection_string_for_field_info(socket, *gfield_value_log, ss); + } + else if (const geo_log::GeometryInfoLog *geo_value_log = + dynamic_cast(value_log)) { + create_inspection_string_for_geometry_info( + *geo_value_log, + ss, + dynamic_cast(socket.runtime->declaration)); + } + newline = true; + }); std::string str = ss.str(); - if (str.empty()) { - return std::nullopt; + + if (!str.empty()){ + return str; } - return str; + + return std::nullopt; } static bool node_socket_has_tooltip(const bNodeTree &ntree, const bNodeSocket &socket) diff --git a/source/blender/nodes/NOD_geometry_nodes_log.hh b/source/blender/nodes/NOD_geometry_nodes_log.hh index e2207338823..1ed710721f1 100644 --- a/source/blender/nodes/NOD_geometry_nodes_log.hh +++ b/source/blender/nodes/NOD_geometry_nodes_log.hh @@ -30,6 +30,7 @@ #include "BLI_enumerable_thread_specific.hh" #include "BLI_generic_pointer.hh" #include "BLI_multi_value_map.hh" +#include "BLI_function_ref.hh" #include "BKE_attribute.h" #include "BKE_geometry_set.hh" @@ -288,6 +289,7 @@ class GeoTreeLog { void ensure_debug_messages(); ValueLog *find_socket_value_log(const bNodeSocket &query_socket); + void socket_logs_callback(const bNodeSocket &query_socket, FunctionRef callback); }; /** diff --git a/source/blender/nodes/intern/geometry_nodes_log.cc b/source/blender/nodes/intern/geometry_nodes_log.cc index e8b65a3d319..87370d47fea 100644 --- a/source/blender/nodes/intern/geometry_nodes_log.cc +++ b/source/blender/nodes/intern/geometry_nodes_log.cc @@ -8,6 +8,8 @@ #include "BKE_node_runtime.hh" #include "BKE_viewer_path.h" +#include "BLI_function_ref.hh" + #include "FN_field_cpp_type.hh" #include "DNA_modifier_types.h" @@ -352,6 +354,17 @@ void GeoTreeLog::ensure_debug_messages() reduced_debug_messages_ = true; } +void GeoTreeLog::socket_logs_callback(const bNodeSocket &query_socket, FunctionRef callback) +{ + if (!query_socket.is_multi_input()){ + callback(this->find_socket_value_log(query_socket)); + }else{ + for (const bNodeSocket *socket : query_socket.directly_linked_sockets()){ + callback(this->find_socket_value_log(*socket)); + } + } +} + ValueLog *GeoTreeLog::find_socket_value_log(const bNodeSocket &query_socket) { /** diff --git a/source/tools b/source/tools index 9e33a8678a3..fdfa2fcb949 160000 --- a/source/tools +++ b/source/tools @@ -1 +1 @@ -Subproject commit 9e33a8678a3b97d2fdb833349657c3cc1c04811f +Subproject commit fdfa2fcb9495d87571f2dfe2ae9fa0e032536600 -- 2.30.2 From e64b3b8454ad63398886dbcb206154e9e1a1f2c8 Mon Sep 17 00:00:00 2001 From: illua1 Date: Fri, 16 Dec 2022 18:18:47 +0300 Subject: [PATCH 02/14] / --- .../blender/editors/space_node/node_draw.cc | 92 ++++++++++--------- 1 file changed, 51 insertions(+), 41 deletions(-) diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index 11f7b6e84a0..e22cf39f6b8 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -833,8 +833,10 @@ static void create_inspection_string_for_generic_value(const bNodeSocket &socket const CPPType &socket_type = *socket.typeinfo->base_cpp_type; const bke::DataTypeConversions &convert = bke::get_implicit_type_conversions(); - if (!convert.is_convertible(value_type, socket_type)) { - return; + if (&value_type != &socket_type) { + if (!convert.is_convertible(value_type, socket_type)) { + return; + } } BUFFER_FOR_CPP_TYPE_VALUE(socket_type, socket_value); convert.convert_to_uninitialized(value_type, socket_type, buffer, socket_value); @@ -904,12 +906,14 @@ static void create_inspection_string_for_field_info(const bNodeSocket &socket, } static void create_inspection_string_for_geometry_info(const geo_log::GeometryInfoLog &value_log, - std::stringstream &ss, - const nodes::decl::Geometry *socket_decl) + std::stringstream &ss) { Span component_types = value_log.component_types; + + ss << TIP_("Geometry:\n"); + if (component_types.is_empty()) { - ss << TIP_("Empty Geometry"); + ss << TIP_("\u2022 Empty"); return; } @@ -919,9 +923,7 @@ static void create_inspection_string_for_geometry_info(const geo_log::GeometryIn return std::string(str); }; - ss << TIP_("Geometry:\n"); for (GeometryComponentType type : component_types) { - const char *line_end = (type == component_types.last()) ? "" : ".\n"; switch (type) { case GEO_COMPONENT_TYPE_MESH: { const geo_log::GeometryInfoLog::MeshInfo &mesh_info = *value_log.mesh_info; @@ -932,7 +934,7 @@ static void create_inspection_string_for_geometry_info(const geo_log::GeometryIn to_string(mesh_info.verts_num).c_str(), to_string(mesh_info.edges_num).c_str(), to_string(mesh_info.faces_num).c_str()); - ss << line << line_end; + ss << line; break; } case GEO_COMPONENT_TYPE_POINT_CLOUD: { @@ -943,7 +945,7 @@ static void create_inspection_string_for_geometry_info(const geo_log::GeometryIn sizeof(line), TIP_("\u2022 Point Cloud: %s points"), to_string(pointcloud_info.points_num).c_str()); - ss << line << line_end; + ss << line; break; } case GEO_COMPONENT_TYPE_CURVE: { @@ -953,7 +955,7 @@ static void create_inspection_string_for_geometry_info(const geo_log::GeometryIn sizeof(line), TIP_("\u2022 Curve: %s splines"), to_string(curve_info.splines_num).c_str()); - ss << line << line_end; + ss << line; break; } case GEO_COMPONENT_TYPE_INSTANCES: { @@ -963,11 +965,11 @@ static void create_inspection_string_for_geometry_info(const geo_log::GeometryIn sizeof(line), TIP_("\u2022 Instances: %s"), to_string(instances_info.instances_num).c_str()); - ss << line << line_end; + ss << line; break; } case GEO_COMPONENT_TYPE_VOLUME: { - ss << TIP_("\u2022 Volume") << line_end; + ss << TIP_("\u2022 Volume"); break; } case GEO_COMPONENT_TYPE_EDIT: { @@ -979,26 +981,33 @@ static void create_inspection_string_for_geometry_info(const geo_log::GeometryIn TIP_("\u2022 Edit Curves: %s, %s"), edit_info.has_deformed_positions ? TIP_("positions") : TIP_("no positions"), edit_info.has_deform_matrices ? TIP_("matrices") : TIP_("no matrices")); - ss << line << line_end; + ss << line; } break; } } + if (type != component_types.last()) { + ss << ".\n"; + } } +} - /* If the geometry declaration is null, as is the case for input to group output, - * or it is an output socket don't show supported types. */ - if (socket_decl == nullptr || socket_decl->in_out() == SOCK_OUT) { +static void create_inspection_string_for_geometry_socket(const nodes::decl::Geometry &socket_decl, + std::stringstream &ss, + const char *space) +{ + if (socket_decl.in_out() == SOCK_OUT) { return; } - Span supported_types = socket_decl->supported_types(); + ss << space; + Span supported_types = socket_decl.supported_types(); if (supported_types.is_empty()) { - ss << ".\n\n" << TIP_("Supported: All Types"); + ss << TIP_("Supported: All Types"); return; } - ss << ".\n\n" << TIP_("Supported: "); + ss << TIP_("Supported: "); for (GeometryComponentType type : supported_types) { switch (type) { case GEO_COMPONENT_TYPE_MESH: { @@ -1025,7 +1034,7 @@ static void create_inspection_string_for_geometry_info(const geo_log::GeometryIn break; } } - ss << ((type == supported_types.last()) ? "" : ", "); + ss << (type == supported_types.last() ? "" : ", "); } } @@ -1038,18 +1047,16 @@ static std::optional create_socket_inspection_string(TreeDrawContex return std::nullopt; } + Vector logs; tree_draw_ctx.geo_tree_log->ensure_socket_values(); + tree_draw_ctx.geo_tree_log->socket_logs_callback(socket, [&](const ValueLog *value_log) { + if (value_log) { + logs.append(value_log); + } + }); - bool newline = false; std::stringstream ss; - tree_draw_ctx.geo_tree_log->socket_logs_callback(socket, [&](const ValueLog *value_log){ - if (newline){ - ss << "\n"; - } - if (value_log == nullptr) { - return; - } - + for (const ValueLog *value_log : logs) { if (const geo_log::GenericValueLog *generic_value_log = dynamic_cast(value_log)) { create_inspection_string_for_generic_value(socket, generic_value_log->value, ss); @@ -1060,21 +1067,24 @@ static std::optional create_socket_inspection_string(TreeDrawContex } else if (const geo_log::GeometryInfoLog *geo_value_log = dynamic_cast(value_log)) { - create_inspection_string_for_geometry_info( - *geo_value_log, - ss, - dynamic_cast(socket.runtime->declaration)); + create_inspection_string_for_geometry_info(*geo_value_log, ss); + } + if (value_log != logs.last()) { + ss << ".\n"; } - newline = true; - }); - - std::string str = ss.str(); - - if (!str.empty()){ - return str; } - return std::nullopt; + if (const nodes::decl::Geometry *socket_decl = dynamic_cast( + socket.runtime->declaration)) { + const char *space = logs.is_empty() ? "" : ".\n\n"; + create_inspection_string_for_geometry_socket(*socket_decl, ss, space); + } + + std::string str = ss.str(); + if (str.empty()) { + return std::nullopt; + } + return str; } static bool node_socket_has_tooltip(const bNodeTree &ntree, const bNodeSocket &socket) -- 2.30.2 From c85e466cfae7ff4044211febf947bfb299467330 Mon Sep 17 00:00:00 2001 From: illua1 Date: Sat, 7 Jan 2023 16:46:11 +0300 Subject: [PATCH 03/14] / --- .../blender/editors/space_node/node_draw.cc | 58 +++++++++---------- .../blender/nodes/NOD_geometry_nodes_log.hh | 9 ++- .../nodes/intern/geometry_nodes_log.cc | 51 ++++++---------- 3 files changed, 53 insertions(+), 65 deletions(-) diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index b1c28f6759f..f34443bd2c3 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -826,11 +826,7 @@ static void create_inspection_string_for_generic_value(const bNodeSocket &socket const CPPType &socket_type = *socket.typeinfo->base_cpp_type; const bke::DataTypeConversions &convert = bke::get_implicit_type_conversions(); -<<<<<<< HEAD - if (&value_type != &socket_type) { -======= if (value_type != socket_type) { ->>>>>>> master if (!convert.is_convertible(value_type, socket_type)) { return; } @@ -907,11 +903,8 @@ static void create_inspection_string_for_geometry_info(const geo_log::GeometryIn std::stringstream &ss) { Span component_types = value_log.component_types; - - ss << TIP_("Geometry:\n"); - if (component_types.is_empty()) { - ss << TIP_("\u2022 Empty"); + ss << TIP_("Empty Geometry"); return; } @@ -921,6 +914,7 @@ static void create_inspection_string_for_geometry_info(const geo_log::GeometryIn return std::string(str); }; + ss << TIP_("Geometry:\n"); for (GeometryComponentType type : component_types) { switch (type) { case GEO_COMPONENT_TYPE_MESH: { @@ -990,22 +984,21 @@ static void create_inspection_string_for_geometry_info(const geo_log::GeometryIn } } -<<<<<<< HEAD -static void create_inspection_string_for_geometry_socket(const nodes::decl::Geometry &socket_decl, - std::stringstream &ss, - const char *space) +static void create_inspection_string_for_geometry_socket(std::stringstream &ss, + const nodes::decl::Geometry *socket_decl, + const bool after_log) { - if (socket_decl.in_out() == SOCK_OUT) { -======= /* If the geometry declaration is null, as is the case for input to group output, * or it is an output socket don't show supported types. */ if (socket_decl == nullptr || socket_decl->in_out == SOCK_OUT) { ->>>>>>> master return; } - ss << space; - Span supported_types = socket_decl.supported_types(); + if (after_log) { + ss << ".\n\n"; + } + + Span supported_types = socket_decl->supported_types(); if (supported_types.is_empty()) { ss << TIP_("Supported: All Types"); return; @@ -1038,7 +1031,9 @@ static void create_inspection_string_for_geometry_socket(const nodes::decl::Geom break; } } - ss << (type == supported_types.last() ? "" : ", "); + if (type != supported_types.last()) { + ss << ", "; + } } } @@ -1051,16 +1046,22 @@ static std::optional create_socket_inspection_string(TreeDrawContex return std::nullopt; } - Vector logs; tree_draw_ctx.geo_tree_log->ensure_socket_values(); - tree_draw_ctx.geo_tree_log->socket_logs_callback(socket, [&](const ValueLog *value_log) { - if (value_log) { - logs.append(value_log); - } - }); + Vector value_logs; + if (socket.is_multi_input()){ + geo_log::multi_input_socket_value_logs(*tree_draw_ctx.geo_tree_log, socket, [&](const ValueLog *value_log) { + if (value_log) { + value_logs.append(value_log); + } + }); + }else{ + value_logs.append(tree_draw_ctx.geo_tree_log->find_socket_value_log(socket)); + } std::stringstream ss; - for (const ValueLog *value_log : logs) { + for (const int index : value_logs.index_range()) { + const ValueLog *value_log = value_logs[index]; + ss << "Input " << index << ":\n"; if (const geo_log::GenericValueLog *generic_value_log = dynamic_cast(value_log)) { create_inspection_string_for_generic_value(socket, generic_value_log->value, ss); @@ -1073,15 +1074,12 @@ static std::optional create_socket_inspection_string(TreeDrawContex dynamic_cast(value_log)) { create_inspection_string_for_geometry_info(*geo_value_log, ss); } - if (value_log != logs.last()) { - ss << ".\n"; - } } if (const nodes::decl::Geometry *socket_decl = dynamic_cast( socket.runtime->declaration)) { - const char *space = logs.is_empty() ? "" : ".\n\n"; - create_inspection_string_for_geometry_socket(*socket_decl, ss, space); + const bool after_log = !value_logs.is_empty(); + create_inspection_string_for_geometry_socket(ss, socket_decl, after_log); } std::string str = ss.str(); diff --git a/source/blender/nodes/NOD_geometry_nodes_log.hh b/source/blender/nodes/NOD_geometry_nodes_log.hh index 257941b6199..7c90d4456cb 100644 --- a/source/blender/nodes/NOD_geometry_nodes_log.hh +++ b/source/blender/nodes/NOD_geometry_nodes_log.hh @@ -289,9 +289,16 @@ class GeoTreeLog { void ensure_debug_messages(); ValueLog *find_socket_value_log(const bNodeSocket &query_socket); - void socket_logs_callback(const bNodeSocket &query_socket, FunctionRef callback); }; +inline void multi_input_socket_value_logs(GeoTreeLog &tree_log, const bNodeSocket &query_socket, const FunctionRef callback) +{ + BLI_assert(query_socket.is_multi_input()); + for (const bNodeSocket *socket : query_socket.directly_linked_sockets()){ + callback(tree_log.find_socket_value_log(*socket)); + } +} + /** * There is one #GeoModifierLog for every modifier that evaluates geometry nodes. It contains all * the loggers that are used during evaluation as well as the preprocessed logs that are used by UI diff --git a/source/blender/nodes/intern/geometry_nodes_log.cc b/source/blender/nodes/intern/geometry_nodes_log.cc index 59dcaa5d6ac..00650f3bffc 100644 --- a/source/blender/nodes/intern/geometry_nodes_log.cc +++ b/source/blender/nodes/intern/geometry_nodes_log.cc @@ -8,8 +8,6 @@ #include "BKE_node_runtime.hh" #include "BKE_viewer_path.h" -#include "BLI_function_ref.hh" - #include "FN_field_cpp_type.hh" #include "DNA_modifier_types.h" @@ -353,17 +351,6 @@ void GeoTreeLog::ensure_debug_messages() reduced_debug_messages_ = true; } -void GeoTreeLog::socket_logs_callback(const bNodeSocket &query_socket, FunctionRef callback) -{ - if (!query_socket.is_multi_input()){ - callback(this->find_socket_value_log(query_socket)); - }else{ - for (const bNodeSocket *socket : query_socket.directly_linked_sockets()){ - callback(this->find_socket_value_log(*socket)); - } - } -} - ValueLog *GeoTreeLog::find_socket_value_log(const bNodeSocket &query_socket) { /** @@ -403,14 +390,24 @@ ValueLog *GeoTreeLog::find_socket_value_log(const bNodeSocket &query_socket) sockets_to_check.push(&from_socket); } } - } - else { - if (node.is_reroute()) { - const bNodeSocket &input_socket = node.input_socket(0); - if (added_sockets.add(&input_socket)) { - sockets_to_check.push(&input_socket); + } else if (node.is_reroute()) { + const bNodeSocket &input_socket = node.input_socket(0); + if (added_sockets.add(&input_socket)) { + sockets_to_check.push(&input_socket); + } + const Span links = input_socket.directly_linked_links(); + for (const bNodeLink *link : links) { + const bNodeSocket &from_socket = *link->fromsock; + if (added_sockets.add(&from_socket)) { + sockets_to_check.push(&from_socket); } - const Span links = input_socket.directly_linked_links(); + } + } else if (node.is_muted()) { + if (const bNodeSocket *input_socket = socket.internal_link_input()) { + if (added_sockets.add(input_socket)) { + sockets_to_check.push(input_socket); + } + const Span links = input_socket->directly_linked_links(); for (const bNodeLink *link : links) { const bNodeSocket &from_socket = *link->fromsock; if (added_sockets.add(&from_socket)) { @@ -418,20 +415,6 @@ ValueLog *GeoTreeLog::find_socket_value_log(const bNodeSocket &query_socket) } } } - else if (node.is_muted()) { - if (const bNodeSocket *input_socket = socket.internal_link_input()) { - if (added_sockets.add(input_socket)) { - sockets_to_check.push(input_socket); - } - const Span links = input_socket->directly_linked_links(); - for (const bNodeLink *link : links) { - const bNodeSocket &from_socket = *link->fromsock; - if (added_sockets.add(&from_socket)) { - sockets_to_check.push(&from_socket); - } - } - } - } } } -- 2.30.2 From d50d27c4a8ed8ff6735268fc53c7e267663d0aa2 Mon Sep 17 00:00:00 2001 From: illua1 Date: Sat, 7 Jan 2023 18:03:16 +0300 Subject: [PATCH 04/14] / --- .../blender/editors/space_node/node_draw.cc | 56 ++++++++++++------- 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index f34443bd2c3..ec5c8d8c7b2 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -900,11 +900,15 @@ static void create_inspection_string_for_field_info(const bNodeSocket &socket, } static void create_inspection_string_for_geometry_info(const geo_log::GeometryInfoLog &value_log, - std::stringstream &ss) + std::stringstream &ss, + const std::pair index) { Span component_types = value_log.component_types; if (component_types.is_empty()) { ss << TIP_("Empty Geometry"); + if (index.first){ + ss << " " << index.second; + } return; } @@ -914,7 +918,13 @@ static void create_inspection_string_for_geometry_info(const geo_log::GeometryIn return std::string(str); }; - ss << TIP_("Geometry:\n"); + ss << TIP_("Geometry"); + if (index.first){ + ss << " " << index.second << ":\n"; + }else{ + ss << ":\n"; + } + for (GeometryComponentType type : component_types) { switch (type) { case GEO_COMPONENT_TYPE_MESH: { @@ -1046,22 +1056,11 @@ static std::optional create_socket_inspection_string(TreeDrawContex return std::nullopt; } - tree_draw_ctx.geo_tree_log->ensure_socket_values(); - Vector value_logs; - if (socket.is_multi_input()){ - geo_log::multi_input_socket_value_logs(*tree_draw_ctx.geo_tree_log, socket, [&](const ValueLog *value_log) { - if (value_log) { - value_logs.append(value_log); - } - }); - }else{ - value_logs.append(tree_draw_ctx.geo_tree_log->find_socket_value_log(socket)); - } - std::stringstream ss; - for (const int index : value_logs.index_range()) { - const ValueLog *value_log = value_logs[index]; - ss << "Input " << index << ":\n"; + + bool declaration_after_log = false; + + auto log_value_log = [&](const ValueLog *value_log, const std::pair index){ if (const geo_log::GenericValueLog *generic_value_log = dynamic_cast(value_log)) { create_inspection_string_for_generic_value(socket, generic_value_log->value, ss); @@ -1072,14 +1071,31 @@ static std::optional create_socket_inspection_string(TreeDrawContex } else if (const geo_log::GeometryInfoLog *geo_value_log = dynamic_cast(value_log)) { - create_inspection_string_for_geometry_info(*geo_value_log, ss); + create_inspection_string_for_geometry_info(*geo_value_log, ss, index); + declaration_after_log = true; } + }; + + tree_draw_ctx.geo_tree_log->ensure_socket_values(); + if (socket.is_multi_input()){ + int input_index = 1; + geo_log::multi_input_socket_value_logs(*tree_draw_ctx.geo_tree_log, socket, [&](const ValueLog *value_log) { + if (value_log) { + if (input_index != 1) { + ss << "\n"; + } + log_value_log(value_log, std::pair{true, input_index}); + } + input_index++; + }); + }else{ + const ValueLog *value_log = tree_draw_ctx.geo_tree_log->find_socket_value_log(socket); + log_value_log(value_log, std::pair{false, 0}); } if (const nodes::decl::Geometry *socket_decl = dynamic_cast( socket.runtime->declaration)) { - const bool after_log = !value_logs.is_empty(); - create_inspection_string_for_geometry_socket(ss, socket_decl, after_log); + create_inspection_string_for_geometry_socket(ss, socket_decl, declaration_after_log); } std::string str = ss.str(); -- 2.30.2 From c67708352ccfd6b89ec2181af15109b3b7344dd5 Mon Sep 17 00:00:00 2001 From: illua1 Date: Fri, 20 Jan 2023 02:35:32 +0300 Subject: [PATCH 05/14] / --- .../blender/editors/space_node/node_draw.cc | 64 ++++++++++++------- .../blender/nodes/NOD_geometry_nodes_log.hh | 7 +- .../nodes/intern/geometry_nodes_log.cc | 6 +- 3 files changed, 49 insertions(+), 28 deletions(-) diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index 229dd7c9886..fc1457cccce 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -310,7 +310,6 @@ float2 node_from_view(const bNode &node, const float2 &co) return result; } - static char *node_socket_get_tooltip(const SpaceNode *snode, const bNodeTree &ntree, const bNodeSocket &socket); @@ -525,20 +524,33 @@ static void node_update_basis(const bContext &C, if (socket->is_multi_input()) { const float total_inputs = float(socket->directly_linked_links().size()) * 5; UI_block_emboss_set(&block, UI_EMBOSS_NONE); - uiBut *but = uiDefBut(&block, UI_BTYPE_BUT, 0, "", loc.x + NODE_DYS - 15, dy - total_inputs / 2 - 10, 10, total_inputs, nullptr, 0, 0, 0, 0, nullptr); + uiBut *but = uiDefBut(&block, + UI_BTYPE_BUT, + 0, + "", + loc.x + NODE_DYS - 15, + dy - total_inputs / 2 - 10, + 10, + total_inputs, + nullptr, + 0, + 0, + 0, + 0, + nullptr); UI_block_emboss_set(&block, UI_EMBOSS); - + UI_but_func_tooltip_set( - but, - [](bContext *C, void *argN, const char * /*tip*/) { - const SpaceNode &snode = *CTX_wm_space_node(C); - const bNodeTree &ntree = *snode.edittree; - const int index_in_tree = POINTER_AS_INT(argN); - ntree.ensure_topology_cache(); - return node_socket_get_tooltip(&snode, ntree, *ntree.all_sockets()[index_in_tree]); - }, - POINTER_FROM_INT(socket->index_in_tree()), - nullptr); + but, + [](bContext *C, void *argN, const char * /*tip*/) { + const SpaceNode &snode = *CTX_wm_space_node(C); + const bNodeTree &ntree = *snode.edittree; + const int index_in_tree = POINTER_AS_INT(argN); + ntree.ensure_topology_cache(); + return node_socket_get_tooltip(&snode, ntree, *ntree.all_sockets()[index_in_tree]); + }, + POINTER_FROM_INT(socket->index_in_tree()), + nullptr); } /* Ensure minimum socket height in case layout is empty. */ @@ -1081,15 +1093,18 @@ static std::optional create_socket_inspection_string(TreeDrawContex std::stringstream ss; auto log_socket_value = [&](const ValueLog *value_log, const char *tab_space) -> bool { - if (const geo_log::GenericValueLog *generic_value_log = dynamic_cast(value_log)) { + if (const geo_log::GenericValueLog *generic_value_log = + dynamic_cast(value_log)) { create_inspection_string_for_generic_value(socket, generic_value_log->value, ss); return true; } - if (const geo_log::FieldInfoLog *gfield_value_log = dynamic_cast(value_log)) { + if (const geo_log::FieldInfoLog *gfield_value_log = + dynamic_cast(value_log)) { create_inspection_string_for_field_info(socket, *gfield_value_log, ss); return true; } - if (const geo_log::GeometryInfoLog *geo_value_log = dynamic_cast(value_log)) { + if (const geo_log::GeometryInfoLog *geo_value_log = + dynamic_cast(value_log)) { create_inspection_string_for_geometry_info(*geo_value_log, ss, tab_space); return true; } @@ -1097,9 +1112,10 @@ static std::optional create_socket_inspection_string(TreeDrawContex }; bool after_log = false; - if (socket.is_multi_input()){ - const Vector value_logs = multi_input_socket_value_logs(*tree_draw_ctx.geo_tree_log, socket); - if (!value_logs.is_empty()){ + if (socket.is_multi_input()) { + const Vector value_logs = multi_input_socket_value_logs( + *tree_draw_ctx.geo_tree_log, socket); + if (!value_logs.is_empty()) { if (value_logs.size() >= 1) { ss << "1. "; const bool is_empty_line = !log_socket_value(value_logs.first(), " "); @@ -1108,8 +1124,8 @@ static std::optional create_socket_inspection_string(TreeDrawContex } after_log = true; } - for (const int index : value_logs.index_range().drop_front(1)){ - ss << ".\n" << index+1 << ". "; + for (const int index : value_logs.index_range().drop_front(1)) { + ss << ".\n" << index + 1 << ". "; const ValueLog *value_log = value_logs[index]; const bool is_empty_line = !log_socket_value(value_log, " "); if (is_empty_line) { @@ -1117,13 +1133,15 @@ static std::optional create_socket_inspection_string(TreeDrawContex } } } - }else{ + } + else { after_log = true; ValueLog *value_log = tree_draw_ctx.geo_tree_log->find_socket_value_log(socket); log_socket_value(value_log, ""); } - if (const nodes::decl::Geometry *socket_decl = dynamic_cast(socket.runtime->declaration)) { + if (const nodes::decl::Geometry *socket_decl = dynamic_cast( + socket.runtime->declaration)) { create_inspection_string_for_geometry_socket(ss, socket_decl, after_log); } diff --git a/source/blender/nodes/NOD_geometry_nodes_log.hh b/source/blender/nodes/NOD_geometry_nodes_log.hh index e26a0b69ead..2cc064cf4df 100644 --- a/source/blender/nodes/NOD_geometry_nodes_log.hh +++ b/source/blender/nodes/NOD_geometry_nodes_log.hh @@ -28,9 +28,9 @@ #include "BLI_compute_context.hh" #include "BLI_enumerable_thread_specific.hh" +#include "BLI_function_ref.hh" #include "BLI_generic_pointer.hh" #include "BLI_multi_value_map.hh" -#include "BLI_function_ref.hh" #include "BKE_attribute.h" #include "BKE_geometry_set.hh" @@ -289,12 +289,13 @@ class GeoTreeLog { ValueLog *find_socket_value_log(const bNodeSocket &query_socket); }; -inline Vector multi_input_socket_value_logs(GeoTreeLog &tree_log, const bNodeSocket &query_socket) +inline Vector multi_input_socket_value_logs(GeoTreeLog &tree_log, + const bNodeSocket &query_socket) { BLI_assert(query_socket.is_multi_input()); Vector logs; logs.reserve(query_socket.directly_linked_sockets().size()); - for (const bNodeSocket *socket : query_socket.directly_linked_sockets()){ + for (const bNodeSocket *socket : query_socket.directly_linked_sockets()) { logs.append(tree_log.find_socket_value_log(*socket)); } return logs; diff --git a/source/blender/nodes/intern/geometry_nodes_log.cc b/source/blender/nodes/intern/geometry_nodes_log.cc index 00650f3bffc..3fa17dea6dd 100644 --- a/source/blender/nodes/intern/geometry_nodes_log.cc +++ b/source/blender/nodes/intern/geometry_nodes_log.cc @@ -390,7 +390,8 @@ ValueLog *GeoTreeLog::find_socket_value_log(const bNodeSocket &query_socket) sockets_to_check.push(&from_socket); } } - } else if (node.is_reroute()) { + } + else if (node.is_reroute()) { const bNodeSocket &input_socket = node.input_socket(0); if (added_sockets.add(&input_socket)) { sockets_to_check.push(&input_socket); @@ -402,7 +403,8 @@ ValueLog *GeoTreeLog::find_socket_value_log(const bNodeSocket &query_socket) sockets_to_check.push(&from_socket); } } - } else if (node.is_muted()) { + } + else if (node.is_muted()) { if (const bNodeSocket *input_socket = socket.internal_link_input()) { if (added_sockets.add(input_socket)) { sockets_to_check.push(input_socket); -- 2.30.2 From a5f17f8676a51e8d9ff5b42818737816ffddec08 Mon Sep 17 00:00:00 2001 From: illua1 Date: Fri, 3 Feb 2023 01:03:22 +0300 Subject: [PATCH 06/14] / --- .../blender/editors/space_node/node_draw.cc | 162 +++++++++--------- 1 file changed, 82 insertions(+), 80 deletions(-) diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index a0b380ea02c..4e5d3134afa 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -521,38 +521,6 @@ static void node_update_basis(const bContext &C, UI_block_align_end(&block); UI_block_layout_resolve(&block, nullptr, &buty); - if (socket->is_multi_input()) { - const float total_inputs = float(socket->directly_linked_links().size()) * 5; - UI_block_emboss_set(&block, UI_EMBOSS_NONE); - uiBut *but = uiDefBut(&block, - UI_BTYPE_BUT, - 0, - "", - loc.x + NODE_DYS - 15, - dy - total_inputs / 2 - 10, - 10, - total_inputs, - nullptr, - 0, - 0, - 0, - 0, - nullptr); - UI_block_emboss_set(&block, UI_EMBOSS); - - UI_but_func_tooltip_set( - but, - [](bContext *C, void *argN, const char * /*tip*/) { - const SpaceNode &snode = *CTX_wm_space_node(C); - const bNodeTree &ntree = *snode.edittree; - const int index_in_tree = POINTER_AS_INT(argN); - ntree.ensure_topology_cache(); - return node_socket_get_tooltip(&snode, ntree, *ntree.all_sockets()[index_in_tree]); - }, - POINTER_FROM_INT(socket->index_in_tree()), - nullptr); - } - /* Ensure minimum socket height in case layout is empty. */ buty = min_ii(buty, dy - NODE_DY); @@ -765,29 +733,84 @@ static void node_socket_draw(const bNodeSocket &sock, immVertex2f(pos_id, locx, locy); } -static void node_socket_draw_multi_input(const float color[4], +/* Ideally sockets themselves should be buttons, but they aren't currently. So add an invisible + * button on top of them for the tooltip. */ +static void node_socket_tooltip_set(uiBlock &block, + const int socket_index_in_tree, + const float2 location, + const float2 size) +{ + const float2 centre = location - size / 2.0f; + + const eUIEmbossType old_emboss = UI_block_emboss_get(&block); + UI_block_emboss_set(&block, UI_EMBOSS_NONE); + uiBut *but = uiDefBut(&block, + UI_BTYPE_BUT, + 0, + "", + centre.x, + centre.y, + size.x, + size.y, + nullptr, + 0, + 0, + 0, + 0, + nullptr); + + UI_but_func_tooltip_set( + but, + [](bContext *C, void *argN, const char * /*tip*/) { + const SpaceNode &snode = *CTX_wm_space_node(C); + const bNodeTree &ntree = *snode.edittree; + const int index_in_tree = POINTER_AS_INT(argN); + ntree.ensure_topology_cache(); + return node_socket_get_tooltip(&snode, ntree, *ntree.all_sockets()[index_in_tree]); + }, + POINTER_FROM_INT(socket_index_in_tree), + nullptr); + + /* Disable the button so that clicks on it are ignored the link operator still works. */ + UI_but_flag_enable(but, UI_BUT_DISABLED); + UI_block_emboss_set(&block, old_emboss); +} + +static void node_socket_draw_multi_input(uiBlock &block, + const int index_in_tree, + const float2 location, + const float2 draw_size, + const float color[4], const float color_outline[4], - const float width, - const float height, - const float2 location) + const float2 tooltip_size, + const bool has_tooltip) { /* The other sockets are drawn with the keyframe shader. There, the outline has a base thickness * that can be varied but always scales with the size the socket is drawn at. Using `U.dpi_fac` * has the same effect here. It scales the outline correctly across different screen DPI's * and UI scales without being affected by the 'line-width'. */ - const float outline_width = NODE_SOCK_OUTLINE_SCALE * U.dpi_fac; + const float half_outline_width = NODE_SOCK_OUTLINE_SCALE * U.dpi_fac * 0.5f; /* UI_draw_roundbox draws the outline on the outer side, so compensate for the outline width. */ const rctf rect = { - location.x - width + outline_width * 0.5f, - location.x + width - outline_width * 0.5f, - location.y - height + outline_width * 0.5f, - location.y + height - outline_width * 0.5f, + location.x - draw_size.x + half_outline_width, + location.x + draw_size.x - half_outline_width, + location.y - draw_size.y + half_outline_width, + location.y + draw_size.y - half_outline_width, }; UI_draw_roundbox_corner_set(UI_CNR_ALL); - UI_draw_roundbox_4fv_ex( - &rect, color, nullptr, 1.0f, color_outline, outline_width, width - outline_width * 0.5f); + UI_draw_roundbox_4fv_ex(&rect, + color, + nullptr, + 1.0f, + color_outline, + half_outline_width * 2.0f, + draw_size.x - half_outline_width); + + if (has_tooltip) { + node_socket_tooltip_set(block, index_in_tree, location, tooltip_size); + } } static const float virtual_node_socket_outline_color[4] = {0.5, 0.5, 0.5, 1.0}; @@ -1295,39 +1318,7 @@ static void node_socket_draw_nested(const bContext &C, return; } - /* Ideally sockets themselves should be buttons, but they aren't currently. So add an invisible - * button on top of them for the tooltip. */ - const eUIEmbossType old_emboss = UI_block_emboss_get(&block); - UI_block_emboss_set(&block, UI_EMBOSS_NONE); - uiBut *but = uiDefIconBut(&block, - UI_BTYPE_BUT, - 0, - ICON_NONE, - location.x - size / 2.0f, - location.y - size / 2.0f, - size, - size, - nullptr, - 0, - 0, - 0, - 0, - nullptr); - - UI_but_func_tooltip_set( - but, - [](bContext *C, void *argN, const char * /*tip*/) { - const SpaceNode &snode = *CTX_wm_space_node(C); - const bNodeTree &ntree = *snode.edittree; - const int index_in_tree = POINTER_AS_INT(argN); - ntree.ensure_topology_cache(); - return node_socket_get_tooltip(&snode, ntree, *ntree.all_sockets()[index_in_tree]); - }, - POINTER_FROM_INT(sock.index_in_tree()), - nullptr); - /* Disable the button so that clicks on it are ignored the link operator still works. */ - UI_but_flag_enable(but, UI_BUT_DISABLED); - UI_block_emboss_set(&block, old_emboss); + node_socket_tooltip_set(block, sock.index_in_tree(), location, float2{size, size}); } void node_socket_draw(bNodeSocket *sock, const rcti *rect, const float color[4], float scale) @@ -1528,7 +1519,7 @@ static void node_draw_sockets(const View2D &v2d, continue; } /* Don't draw multi-input sockets here since they are drawn in a different batch. */ - if (sock->flag & SOCK_MULTI_INPUT) { + if (sock->is_multi_input()) { continue; } @@ -1661,7 +1652,7 @@ static void node_draw_sockets(const View2D &v2d, if (!socket->is_visible()) { continue; } - if (!(socket->flag & SOCK_MULTI_INPUT)) { + if (!(socket->is_multi_input())) { continue; } @@ -1674,8 +1665,19 @@ static void node_draw_sockets(const View2D &v2d, node_socket_color_get(C, ntree, node_ptr, *socket, color); node_socket_outline_color_get(socket->flag & SELECT, socket->type, outline_color); - const float2 location = socket_locations[socket->index_in_tree()]; - node_socket_draw_multi_input(color, outline_color, width, height, location); + const int index_in_tree = socket->index_in_tree(); + const float2 location = socket_locations[index_in_tree]; + const float2 draw_size{width, height}; + const float2 tooltip_size{scale, height * 2.0f - socket_draw_size + scale}; + const bool has_tooltip = node_socket_has_tooltip(ntree, *socket); + node_socket_draw_multi_input(block, + index_in_tree, + location, + draw_size, + color, + outline_color, + tooltip_size, + has_tooltip); } } -- 2.30.2 From 76cfcfcab9ac566dc07f8ca70fde711970c3547d Mon Sep 17 00:00:00 2001 From: illua1 Date: Fri, 3 Feb 2023 01:08:40 +0300 Subject: [PATCH 07/14] / --- source/blender/editors/space_node/node_draw.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index 4e5d3134afa..1226e33d275 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -1314,11 +1314,9 @@ static void node_socket_draw_nested(const bContext &C, size_id, outline_col_id); - if (!node_socket_has_tooltip(ntree, sock)) { - return; + if (node_socket_has_tooltip(ntree, sock)) { + node_socket_tooltip_set(block, sock.index_in_tree(), location, float2{size, size}); } - - node_socket_tooltip_set(block, sock.index_in_tree(), location, float2{size, size}); } void node_socket_draw(bNodeSocket *sock, const rcti *rect, const float color[4], float scale) -- 2.30.2 From 0ed43f45d6b22d55fb92288855adfb7b52f8a154 Mon Sep 17 00:00:00 2001 From: Iliya Katueshenock Date: Thu, 11 Apr 2024 01:23:40 +0300 Subject: [PATCH 08/14] init --- .../blender/editors/space_node/node_draw.cc | 169 ++++++++++++------ 1 file changed, 112 insertions(+), 57 deletions(-) diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index 607932e6807..51d32d3eaf2 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -1480,9 +1480,7 @@ static void create_inspection_string_for_geometry_info(const geo_log::GeometryIn } } -static void create_inspection_string_for_geometry_socket(std::stringstream &ss, - const nodes::decl::Geometry *socket_decl, - const bool after_log) +static void create_inspection_string_for_geometry_socket(std::stringstream &ss, const nodes::decl::Geometry *socket_decl) { /* If the geometry declaration is null, as is the case for input to group output, * or it is an output socket don't show supported types. */ @@ -1490,10 +1488,6 @@ static void create_inspection_string_for_geometry_socket(std::stringstream &ss, return; } - if (after_log) { - ss << ".\n\n"; - } - Span supported_types = socket_decl->supported_types(); if (supported_types.is_empty()) { ss << TIP_("Supported: All Types"); @@ -1537,40 +1531,105 @@ static void create_inspection_string_for_geometry_socket(std::stringstream &ss, } } -static std::optional create_socket_inspection_string( - geo_log::GeoTreeLog &geo_tree_log, const bNodeSocket &socket) +static void create_inspection_string_for_default_socket_value(const bNodeSocket &socket, std::stringstream &ss) +{ + if (!socket.is_input()) { + return; + } + if (socket.is_directly_linked()) { + return; + } + if (socket.flag & SOCK_HIDE_VALUE) { + return; + } + + if (socket.typeinfo->base_cpp_type == nullptr) { + return; + } + + const CPPType &value_type = *socket.typeinfo->base_cpp_type; + BUFFER_FOR_CPP_TYPE_VALUE(value_type, socket_value); + socket.typeinfo->get_base_cpp_value(socket.default_value, socket_value); + create_inspection_string_for_generic_value(socket, GPointer(value_type, socket_value), ss); + value_type.destruct(socket_value); +} + +static std::optional create_description_inspection_string(const bNodeSocket &socket) +{ + if (socket.runtime->declaration == nullptr) { + return std::nullopt; + } + const blender::nodes::SocketDeclaration &socket_decl = *socket.runtime->declaration; + blender::StringRef description = socket_decl.description; + if (description.is_empty()) { + return std::nullopt; + } + + return TIP_(description.data()); +} + +static std::optional create_log_inspection_string(geo_log::GeoTreeLog *geo_tree_log, const bNodeSocket &socket) { using namespace blender::nodes::geo_eval_log; + if (geo_tree_log == nullptr) { + return std::nullopt; + } if (socket.typeinfo->base_cpp_type == nullptr) { return std::nullopt; } - geo_tree_log.ensure_socket_values(); - ValueLog *value_log = geo_tree_log.find_socket_value_log(socket); + geo_tree_log->ensure_socket_values(); + ValueLog *value_log = geo_tree_log->find_socket_value_log(socket); std::stringstream ss; - if (const geo_log::GenericValueLog *generic_value_log = - dynamic_cast(value_log)) + if (const geo_log::GenericValueLog *generic_value_log = dynamic_cast(value_log)) { create_inspection_string_for_generic_value(socket, generic_value_log->value, ss); } - else if (const geo_log::FieldInfoLog *gfield_value_log = - dynamic_cast(value_log)) + else if (const geo_log::FieldInfoLog *gfield_value_log = dynamic_cast(value_log)) { create_inspection_string_for_field_info(socket, *gfield_value_log, ss); } - else if (const geo_log::GeometryInfoLog *geo_value_log = - dynamic_cast(value_log)) + else if (const geo_log::GeometryInfoLog *geo_value_log = dynamic_cast(value_log)) { create_inspection_string_for_geometry_info(*geo_value_log, ss); } - if (const nodes::decl::Geometry *socket_decl = dynamic_cast( - socket.runtime->declaration)) - { - const bool after_log = value_log != nullptr; - create_inspection_string_for_geometry_socket(ss, socket_decl, after_log); + std::string str = ss.str(); + if (str.empty()) { + return std::nullopt; } + return str; +} + +static std::optional create_declaration_inspection_string(const bNodeSocket &socket) +{ + std::stringstream ss; + if (const nodes::decl::Geometry *socket_decl = dynamic_cast(socket.runtime->declaration)) + { + create_inspection_string_for_geometry_socket(ss, socket_decl); + } + + if (const const nodes::SocketDeclaration * socket_decl = socket.runtime->declaration) { + if (socket_decl->input_field_type == nodes::InputSocketFieldType::Implicit) { + if (!ss.str().empty()) { + ss << ".\n\n"; + } + ss << TIP_("Implicit field input"); + } + } + + std::string str = ss.str(); + if (str.empty()) { + return std::nullopt; + } + return str; +} + +static std::optional create_default_value_inspection_string(const bNodeSocket &socket) +{ + std::stringstream ss; + create_inspection_string_for_default_socket_value(socket, ss); std::string str = ss.str(); if (str.empty()) { @@ -1581,16 +1640,7 @@ static std::optional create_socket_inspection_string( static bool node_socket_has_tooltip(const bNodeTree &ntree, const bNodeSocket &socket) { - if (ntree.type == NTREE_GEOMETRY) { - return true; - } - - if (socket.runtime->declaration != nullptr) { - const nodes::SocketDeclaration &socket_decl = *socket.runtime->declaration; - return !socket_decl.description.empty(); - } - - return false; + return true; } static std::string node_socket_get_tooltip(const SpaceNode *snode, @@ -1600,19 +1650,12 @@ static std::string node_socket_get_tooltip(const SpaceNode *snode, TreeDrawContext tree_draw_ctx; if (snode != nullptr) { if (ntree.type == NTREE_GEOMETRY) { - tree_draw_ctx.geo_log_by_zone = - geo_log::GeoModifierLog::get_tree_log_by_zone_for_node_editor(*snode); + tree_draw_ctx.geo_log_by_zone = geo_log::GeoModifierLog::get_tree_log_by_zone_for_node_editor(*snode); } } - std::stringstream output; - if (socket.runtime->declaration != nullptr) { - const blender::nodes::SocketDeclaration &socket_decl = *socket.runtime->declaration; - blender::StringRef description = socket_decl.description; - if (!description.is_empty()) { - output << TIP_(description.data()); - } - } + bool value_is_mentioned = false; + Vector inspection_strings; geo_log::GeoTreeLog *geo_tree_log = [&]() -> geo_log::GeoTreeLog * { const bNodeTreeZones *zones = ntree.zones(); @@ -1623,25 +1666,37 @@ static std::string node_socket_get_tooltip(const SpaceNode *snode, return tree_draw_ctx.geo_log_by_zone.lookup_default(zone, nullptr); }(); - if (ntree.type == NTREE_GEOMETRY && geo_tree_log != nullptr) { - if (!output.str().empty()) { - output << ".\n\n"; - } - - std::optional socket_inspection_str = create_socket_inspection_string( - *geo_tree_log, socket); - if (socket_inspection_str.has_value()) { - output << *socket_inspection_str; - } - else { - output << TIP_( - "Unknown socket value. Either the socket was not used or its value was not logged " - "during the last evaluation"); + if (std::optional info = create_description_inspection_string(socket)) { + inspection_strings.append(std::move(*info)); + } + if (std::optional info = create_log_inspection_string(geo_tree_log, socket)) { + inspection_strings.append(std::move(*info)); + value_is_mentioned = true; + } + if (std::optional info = create_declaration_inspection_string(socket)) { + inspection_strings.append(std::move(*info)); + } + if (!value_is_mentioned) { + if (std::optional info = create_default_value_inspection_string(socket)) { + inspection_strings.append(std::move(*info)); } } - if (output.str().empty()) { + std::stringstream output; + for (const std::string &info : inspection_strings) { + output << info; + if (&info != &inspection_strings.last()) { + output << ".\n\n"; + } + } + + if (inspection_strings.is_empty()) { output << bke::nodeSocketLabel(&socket); + + if (ntree.type == NTREE_GEOMETRY) { + output << ".\n\n"; + output << TIP_("Unknown socket value. Either the socket was not used or its value was not logged during the last evaluation"); + } } return output.str(); -- 2.30.2 From 3cab0b4ffb680976abe5802570054dbaf02b1971 Mon Sep 17 00:00:00 2001 From: Iliya Katueshenock Date: Thu, 11 Apr 2024 01:34:28 +0300 Subject: [PATCH 09/14] cleanup --- source/blender/editors/space_node/node_draw.cc | 9 --------- 1 file changed, 9 deletions(-) diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index c118f47e132..9ef37e7a5c0 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -1593,15 +1593,6 @@ static std::optional create_declaration_inspection_string(const bNo create_inspection_string_for_geometry_socket(ss, socket_decl); } - if (const nodes::SocketDeclaration *socket_decl = socket.runtime->declaration) { - if (socket_decl->input_field_type == nodes::InputSocketFieldType::Implicit) { - if (!ss.str().empty()) { - ss << ".\n\n"; - } - ss << TIP_("Implicit field input"); - } - } - std::string str = ss.str(); if (str.empty()) { return std::nullopt; -- 2.30.2 From 183eff45caf80a61c766e9e4539bda106eaea4ca Mon Sep 17 00:00:00 2001 From: Iliya Katueshenock Date: Thu, 11 Apr 2024 01:45:42 +0300 Subject: [PATCH 10/14] progress --- source/blender/editors/space_node/node_draw.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index 9ef37e7a5c0..3d66329ad6c 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -1612,8 +1612,6 @@ static std::string node_socket_get_tooltip(const SpaceNode *snode, } } - Vector inspection_strings; - geo_log::GeoTreeLog *geo_tree_log = [&]() -> geo_log::GeoTreeLog * { const bNodeTreeZones *zones = ntree.zones(); if (!zones) { @@ -1623,6 +1621,8 @@ static std::string node_socket_get_tooltip(const SpaceNode *snode, return tree_draw_ctx.geo_log_by_zone.lookup_default(zone, nullptr); }(); + Vector inspection_strings; + if (std::optional info = create_description_inspection_string(socket)) { inspection_strings.append(std::move(*info)); } -- 2.30.2 From d4e058badb2bf68377682d3f0aaab3e2d3fc6165 Mon Sep 17 00:00:00 2001 From: Iliya Katueshenock Date: Thu, 11 Apr 2024 23:00:36 +0300 Subject: [PATCH 11/14] merge main part 5 done --- .../blender/editors/space_node/node_draw.cc | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index 858f97906a8..6bb58f40589 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -1665,6 +1665,67 @@ static geo_log::GeoTreeLog *geo_tree_log_for_socket(const bNodeTree &ntree, return tree_draw_ctx.geo_log_by_zone.lookup_default(zone, nullptr); } +static int64_t line_size(const StringRef string) +{ + return string.find_last_of("\n"); +} + +static Vector lines(std::string text) +{ + Vector result; + std::istringstream text_stream(text); + for (std::string line; std::getline(text_stream, line);) { + result.append(line); + } + return result; +} + +static std::optional create_multi_input_log_inspection_string( + const bNodeTree &ntree, const bNodeSocket &socket, TreeDrawContext &tree_draw_ctx) +{ + if (!socket.is_multi_input()) { + return std::nullopt; + } + + Vector inputs; + + for (const bNodeLink *link : socket.directly_linked_links()) { + if (link->fromnode->is_dangling_reroute()) { + continue; + } + const bNodeSocket &connected_socket = *link->fromsock; + geo_log::GeoTreeLog *geo_tree_log = geo_tree_log_for_socket( + ntree, connected_socket, tree_draw_ctx); + std::optional input_log = create_log_inspection_string(geo_tree_log, + connected_socket); + if (input_log.has_value()) { + inputs.append(std::move(*input_log)); + } + } + if (inputs.is_empty()) { + return std::nullopt; + } + + std::stringstream ss; + for (const int index : inputs.index_range()) { + const std::string &info = inputs[index]; + ss << index + 1 << ". "; + + const Vector lines_of_info = lines(info); + for (const std::string &line : lines_of_info) { + ss << " " << line; + if (&line != &lines_of_info.last()) { + ss << "\n"; + } + } + + if (&info != &inputs.last()) { + ss << ".\n"; + } + } + return ss.str(); +} + static std::string node_socket_get_tooltip(const SpaceNode *snode, const bNodeTree &ntree, const bNodeSocket &socket) @@ -1687,6 +1748,11 @@ static std::string node_socket_get_tooltip(const SpaceNode *snode, if (std::optional info = create_log_inspection_string(geo_tree_log, socket)) { inspection_strings.append(std::move(*info)); } + else if (std::optional info = create_multi_input_log_inspection_string( + ntree, socket, tree_draw_ctx)) + { + inspection_strings.append(std::move(*info)); + } if (std::optional info = create_declaration_inspection_string(socket)) { inspection_strings.append(std::move(*info)); } -- 2.30.2 From 35ed6d11308bc062831bf837513e419dc7fe8945 Mon Sep 17 00:00:00 2001 From: Iliya Katueshenock Date: Fri, 12 Apr 2024 13:41:35 +0300 Subject: [PATCH 12/14] cleanup --- .../blender/nodes/NOD_geometry_nodes_log.hh | 13 ------- .../nodes/intern/geometry_nodes_log.cc | 38 ++++++++++--------- 2 files changed, 20 insertions(+), 31 deletions(-) diff --git a/source/blender/nodes/NOD_geometry_nodes_log.hh b/source/blender/nodes/NOD_geometry_nodes_log.hh index cb613bbd1ad..16682e3ccb0 100644 --- a/source/blender/nodes/NOD_geometry_nodes_log.hh +++ b/source/blender/nodes/NOD_geometry_nodes_log.hh @@ -32,7 +32,6 @@ #include "BLI_compute_context.hh" #include "BLI_enumerable_thread_specific.hh" -#include "BLI_function_ref.hh" #include "BLI_generic_pointer.hh" #include "BLI_linear_allocator_chunked_list.hh" #include "BLI_multi_value_map.hh" @@ -297,18 +296,6 @@ class GeoTreeLog { ValueLog *find_socket_value_log(const bNodeSocket &query_socket); }; -inline Vector multi_input_socket_value_logs(GeoTreeLog &tree_log, - const bNodeSocket &query_socket) -{ - BLI_assert(query_socket.is_multi_input()); - Vector logs; - logs.reserve(query_socket.directly_linked_sockets().size()); - for (const bNodeSocket *socket : query_socket.directly_linked_sockets()) { - logs.append(tree_log.find_socket_value_log(*socket)); - } - return logs; -} - /** * There is one #GeoModifierLog for every modifier that evaluates geometry nodes. It contains all * the loggers that are used during evaluation as well as the preprocessed logs that are used by UI diff --git a/source/blender/nodes/intern/geometry_nodes_log.cc b/source/blender/nodes/intern/geometry_nodes_log.cc index d2fbc186054..8194405201c 100644 --- a/source/blender/nodes/intern/geometry_nodes_log.cc +++ b/source/blender/nodes/intern/geometry_nodes_log.cc @@ -429,25 +429,13 @@ ValueLog *GeoTreeLog::find_socket_value_log(const bNodeSocket &query_socket) } } } - else if (node.is_reroute()) { - const bNodeSocket &input_socket = node.input_socket(0); - if (added_sockets.add(&input_socket)) { - sockets_to_check.push(&input_socket); - } - const Span links = input_socket.directly_linked_links(); - for (const bNodeLink *link : links) { - const bNodeSocket &from_socket = *link->fromsock; - if (added_sockets.add(&from_socket)) { - sockets_to_check.push(&from_socket); + else { + if (node.is_reroute()) { + const bNodeSocket &input_socket = node.input_socket(0); + if (added_sockets.add(&input_socket)) { + sockets_to_check.push(&input_socket); } - } - } - else if (node.is_muted()) { - if (const bNodeSocket *input_socket = socket.internal_link_input()) { - if (added_sockets.add(input_socket)) { - sockets_to_check.push(input_socket); - } - const Span links = input_socket->directly_linked_links(); + const Span links = input_socket.directly_linked_links(); for (const bNodeLink *link : links) { const bNodeSocket &from_socket = *link->fromsock; if (added_sockets.add(&from_socket)) { @@ -455,6 +443,20 @@ ValueLog *GeoTreeLog::find_socket_value_log(const bNodeSocket &query_socket) } } } + else if (node.is_muted()) { + if (const bNodeSocket *input_socket = socket.internal_link_input()) { + if (added_sockets.add(input_socket)) { + sockets_to_check.push(input_socket); + } + const Span links = input_socket->directly_linked_links(); + for (const bNodeLink *link : links) { + const bNodeSocket &from_socket = *link->fromsock; + if (added_sockets.add(&from_socket)) { + sockets_to_check.push(&from_socket); + } + } + } + } } } -- 2.30.2 From 8b086889c30cc42d78e4ea10df16e6af8a717de9 Mon Sep 17 00:00:00 2001 From: Iliya Katueshenock Date: Fri, 12 Apr 2024 14:24:18 +0300 Subject: [PATCH 13/14] progress --- .../blender/editors/space_node/node_draw.cc | 59 +++++++++++-------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index 6bb58f40589..4bcda62a59c 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -1665,12 +1665,7 @@ static geo_log::GeoTreeLog *geo_tree_log_for_socket(const bNodeTree &ntree, return tree_draw_ctx.geo_log_by_zone.lookup_default(zone, nullptr); } -static int64_t line_size(const StringRef string) -{ - return string.find_last_of("\n"); -} - -static Vector lines(std::string text) +static Vector lines_of_text(std::string text) { Vector result; std::istringstream text_stream(text); @@ -1687,43 +1682,55 @@ static std::optional create_multi_input_log_inspection_string( return std::nullopt; } - Vector inputs; + Vector, 8> numerated_info; - for (const bNodeLink *link : socket.directly_linked_links()) { + const Span connected_links = socket.directly_linked_links(); + for (const int index : connected_links.index_range()) { + const bNodeLink *link = connected_links[index]; + const int connection_number = index + 1; + if (!link->is_used()) { + continue; + } + if (!(link->flag & NODE_LINK_VALID)) { + continue; + } if (link->fromnode->is_dangling_reroute()) { continue; } const bNodeSocket &connected_socket = *link->fromsock; geo_log::GeoTreeLog *geo_tree_log = geo_tree_log_for_socket( ntree, connected_socket, tree_draw_ctx); - std::optional input_log = create_log_inspection_string(geo_tree_log, - connected_socket); - if (input_log.has_value()) { - inputs.append(std::move(*input_log)); + const std::optional input_log = create_log_inspection_string(geo_tree_log, + connected_socket); + if (!input_log.has_value()) { + continue; } + numerated_info.append({connection_number, std::move(*input_log)}); } - if (inputs.is_empty()) { + + if (numerated_info.is_empty()) { return std::nullopt; } + constexpr const char *indentation = " "; + std::stringstream ss; - for (const int index : inputs.index_range()) { - const std::string &info = inputs[index]; - ss << index + 1 << ". "; - - const Vector lines_of_info = lines(info); - for (const std::string &line : lines_of_info) { - ss << " " << line; - if (&line != &lines_of_info.last()) { - ss << "\n"; - } + for (const std::pair &info : numerated_info) { + const Vector lines = lines_of_text(info.second); + ss << info.first << ". " << lines.first(); + for (const std::string &line : lines.as_span().drop_front(1)) { + ss << "\n" << indentation << line; } - - if (&info != &inputs.last()) { + if (&info != &numerated_info.last()) { ss << ".\n"; } } - return ss.str(); + + if (const std::string str = ss.str(); !str.empty()) { + return str; + } + + return std::nullopt; } static std::string node_socket_get_tooltip(const SpaceNode *snode, -- 2.30.2 From 70fc1bb84bcb0ff0ec85831f39c6d2f355d97bdb Mon Sep 17 00:00:00 2001 From: Iliya Katueshenock Date: Mon, 22 Apr 2024 20:19:44 +0300 Subject: [PATCH 14/14] progress --- source/blender/editors/space_node/node_draw.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index 4bcda62a59c..794031c7057 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -1182,8 +1182,6 @@ static void node_socket_draw(const bNodeSocket &sock, immVertex2f(pos_id, locx, locy); } -/* Ideally sockets themselves should be buttons, but they aren't currently. So add an invisible - * button on top of them for the tooltip. */ static void node_socket_tooltip_set(uiBlock &block, const int socket_index_in_tree, const float2 location, @@ -1726,11 +1724,12 @@ static std::optional create_multi_input_log_inspection_string( } } - if (const std::string str = ss.str(); !str.empty()) { - return str; + const std::string str = ss.str(); + if (str.empty()) { + return std::nullopt; } - return std::nullopt; + return str; } static std::string node_socket_get_tooltip(const SpaceNode *snode, -- 2.30.2