diff options
author | Jacques Lucke <jacques@blender.org> | 2021-07-05 11:46:00 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-07-05 11:46:36 +0300 |
commit | 9009ac2c3d62e0d30d96b8d35ff5ff620cfe053b (patch) | |
tree | b5b25b36ed769fcdc707aa4d6efd1146fb54621d /source/blender/modifiers/intern/MOD_nodes.cc | |
parent | 04313f1bb5ff89168099cdc03d1855ae5118d29c (diff) |
Geometry Nodes: new Viewer node
This adds a viewer node similar to the one in the compositor.
The icon in the headers of nodes is removed because it served
the same purpose and is not necessary anymore.
Node outputs can be connected to the active viewer using
ctrl+shift+LMB, just like in the compositor. Right now this collides
with the shortcut used in the node wrangler addon, which will
be changed separately.
As of now, the viewed geometry is only visible in the spreadsheet.
Viewport visualization will be added separately.
There are a couple of benefits of using a viewer node compared
to the old approach with the icon in the node header:
* Better support for nodes that have more than one geometry output.
* It's more consistent with the compositor.
* If attributes become decoupled from geometry in the future,
the viewer can have a separate input for the attribute to visualize.
* The viewer node could potentially have visualization settings.
* Allows to keep "visualization points" around by having multiple
viewer nodes.
* Less visual clutter in node headers.
Differential Revision: https://developer.blender.org/D11470
Diffstat (limited to 'source/blender/modifiers/intern/MOD_nodes.cc')
-rw-r--r-- | source/blender/modifiers/intern/MOD_nodes.cc | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc index f7f7c7b0276..76eec76acb4 100644 --- a/source/blender/modifiers/intern/MOD_nodes.cc +++ b/source/blender/modifiers/intern/MOD_nodes.cc @@ -768,22 +768,6 @@ static Vector<SpaceSpreadsheet *> find_spreadsheet_editors(Main *bmain) using PreviewSocketMap = blender::MultiValueMap<DSocket, uint64_t>; -static DSocket try_find_preview_socket_in_node(const DNode node) -{ - for (const SocketRef *socket : node->outputs()) { - if (socket->bsocket()->type == SOCK_GEOMETRY) { - return {node.context(), socket}; - } - } - for (const SocketRef *socket : node->inputs()) { - if (socket->bsocket()->type == SOCK_GEOMETRY && - (socket->bsocket()->flag & SOCK_MULTI_INPUT) == 0) { - return {node.context(), socket}; - } - } - return {}; -} - static DSocket try_get_socket_to_preview_for_spreadsheet(SpaceSpreadsheet *sspreadsheet, NodesModifierData *nmd, const ModifierEvalContext *ctx, @@ -839,7 +823,17 @@ static DSocket try_get_socket_to_preview_for_spreadsheet(SpaceSpreadsheet *sspre const NodeTreeRef &tree_ref = context->tree(); for (const NodeRef *node_ref : tree_ref.nodes()) { if (node_ref->name() == last_context->node_name) { - return try_find_preview_socket_in_node({context, node_ref}); + const DNode viewer_node{context, node_ref}; + DSocket socket_to_view; + viewer_node.input(0).foreach_origin_socket( + [&](const DSocket socket) { socket_to_view = socket; }); + if (!socket_to_view) { + return {}; + } + bNodeSocket *bsocket = socket_to_view->bsocket(); + if (bsocket->type == SOCK_GEOMETRY && bsocket->flag != SOCK_MULTI_INPUT) { + return socket_to_view; + } } } return {}; @@ -975,6 +969,8 @@ static GeometrySet compute_geometry(const DerivedNodeTree &tree, blender::modifiers::geometry_nodes::GeometryNodesEvaluationParams eval_params; eval_params.input_values = group_inputs; eval_params.output_sockets = group_outputs; + eval_params.force_compute_sockets.extend(preview_sockets.keys().begin(), + preview_sockets.keys().end()); eval_params.mf_by_node = &mf_by_node; eval_params.modifier_ = nmd; eval_params.depsgraph = ctx->depsgraph; |