2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2008 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2011-02-27 20:29:51 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup spnode
|
2011-02-27 20:29:51 +00:00
|
|
|
*/
|
|
|
|
|
|
2012-02-17 18:59:41 +00:00
|
|
|
#pragma once
|
2008-12-13 18:09:49 +00:00
|
|
|
|
2023-08-08 17:36:06 +02:00
|
|
|
#include "BLI_compute_context.hh"
|
2022-02-15 10:27:03 -06:00
|
|
|
#include "BLI_math_vector.h"
|
|
|
|
|
#include "BLI_math_vector.hh"
|
2021-11-12 12:12:27 -06:00
|
|
|
#include "BLI_vector.hh"
|
2022-12-02 13:20:40 -06:00
|
|
|
#include "BLI_vector_set.hh"
|
2021-11-12 12:12:27 -06:00
|
|
|
|
2023-05-15 15:14:22 +02:00
|
|
|
#include "BKE_node.hh"
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2021-12-03 11:31:25 -05:00
|
|
|
#include "UI_interface.hh"
|
2023-08-05 02:57:52 +02:00
|
|
|
#include "UI_view2d.hh"
|
2008-12-13 18:09:49 +00:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
struct ARegion;
|
2021-02-18 14:14:17 +11:00
|
|
|
struct NodeInsertOfsData;
|
2008-12-24 10:33:10 +00:00
|
|
|
struct View2D;
|
|
|
|
|
struct bContext;
|
2011-03-13 22:07:55 +00:00
|
|
|
struct bNode;
|
|
|
|
|
struct bNodeLink;
|
2019-01-28 21:08:24 +11:00
|
|
|
struct bNodeSocket;
|
2020-04-16 15:09:49 +02:00
|
|
|
struct wmGizmoGroupType;
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
struct wmKeyConfig;
|
2019-01-28 21:08:24 +11:00
|
|
|
struct wmWindow;
|
2011-03-13 22:07:55 +00:00
|
|
|
|
2022-01-20 15:10:28 -06:00
|
|
|
/* Outside of blender namespace to avoid Python documentation build error with `ctypes`. */
|
2022-05-18 19:24:08 +10:00
|
|
|
extern "C" {
|
2022-01-20 15:10:28 -06:00
|
|
|
extern const char *node_context_dir[];
|
2022-05-18 19:24:08 +10:00
|
|
|
};
|
2022-01-20 15:10:28 -06:00
|
|
|
|
2023-06-29 13:57:54 +02:00
|
|
|
namespace blender::ed::asset {
|
2022-11-01 16:09:49 +01:00
|
|
|
struct AssetItemTree;
|
2023-06-29 13:57:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace blender::ed::space_node {
|
2023-08-08 17:36:06 +02:00
|
|
|
struct NestedTreePreviews;
|
2022-11-01 16:09:49 +01:00
|
|
|
|
2021-12-03 11:31:25 -05:00
|
|
|
/** Temporary data used in node link drag modal operator. */
|
2021-11-18 11:46:44 -05:00
|
|
|
struct bNodeLinkDrag {
|
2021-11-19 15:36:32 -05:00
|
|
|
/** Links dragged by the operator. */
|
2022-12-29 14:09:58 -05:00
|
|
|
Vector<bNodeLink> links;
|
2021-12-15 09:51:57 -06:00
|
|
|
eNodeSocketInOut in_out;
|
|
|
|
|
|
2023-01-28 10:07:29 +01:00
|
|
|
/** Draw handler for the tooltip icon when dragging a link in empty space. */
|
2021-12-15 09:51:57 -06:00
|
|
|
void *draw_handle;
|
2021-03-02 23:09:38 +01:00
|
|
|
|
2021-04-15 10:00:25 +02:00
|
|
|
/** Temporarily stores the last picked link from multi-input socket operator. */
|
2021-12-15 09:51:57 -06:00
|
|
|
bNodeLink *last_picked_multi_input_socket_link;
|
|
|
|
|
|
|
|
|
|
/**
|
2023-01-28 10:07:29 +01:00
|
|
|
* Temporarily stores the last hovered node for multi-input socket operator.
|
2021-12-15 09:51:57 -06:00
|
|
|
* Store it to recalculate sorting after it is no longer hovered.
|
|
|
|
|
*/
|
|
|
|
|
bNode *last_node_hovered_while_dragging_a_link;
|
2021-03-15 15:41:41 +01:00
|
|
|
|
2023-01-28 10:07:29 +01:00
|
|
|
/**
|
|
|
|
|
* Temporarily stores the currently hovered socket for link swapping to allow reliably swap links
|
|
|
|
|
* even when dragging multiple links at once. `nullptr`, when no socket is hovered.
|
|
|
|
|
*/
|
|
|
|
|
bNodeSocket *hovered_socket;
|
|
|
|
|
|
2021-12-15 09:51:57 -06:00
|
|
|
/* The cursor position, used for drawing a + icon when dragging a node link. */
|
|
|
|
|
std::array<int, 2> cursor;
|
|
|
|
|
|
|
|
|
|
/** The node the drag started at. */
|
|
|
|
|
bNode *start_node;
|
|
|
|
|
/** The socket the drag started at. */
|
|
|
|
|
bNodeSocket *start_socket;
|
|
|
|
|
/** The number of links connected to the #start_socket when the drag started. */
|
|
|
|
|
int start_link_count;
|
2021-06-16 18:17:07 +01:00
|
|
|
|
2023-01-28 10:07:29 +01:00
|
|
|
bool swap_links = false;
|
|
|
|
|
|
2021-06-16 18:17:07 +01:00
|
|
|
/* Data for edge panning */
|
|
|
|
|
View2DEdgePanData pan_data;
|
2021-11-18 11:46:44 -05:00
|
|
|
};
|
2008-12-28 00:08:34 +00:00
|
|
|
|
2021-11-18 11:46:44 -05:00
|
|
|
struct SpaceNode_Runtime {
|
2021-01-19 16:43:08 -06:00
|
|
|
float aspect;
|
|
|
|
|
|
|
|
|
|
/** Mouse position for drawing socket-less links and adding nodes. */
|
2022-01-20 10:36:56 -06:00
|
|
|
float2 cursor;
|
2021-01-19 16:43:08 -06:00
|
|
|
|
2022-05-06 17:56:59 +10:00
|
|
|
/**
|
|
|
|
|
* Indicates that the compositing tree in the space needs to be re-evaluated using the
|
2022-05-05 17:33:10 +10:00
|
|
|
* auto-compositing pipeline.
|
2022-05-06 17:56:59 +10:00
|
|
|
* Takes priority over the regular compositing.
|
|
|
|
|
*/
|
2022-05-05 17:33:10 +10:00
|
|
|
bool recalc_auto_compositing;
|
|
|
|
|
|
2022-05-06 17:56:59 +10:00
|
|
|
/**
|
|
|
|
|
* Indicates that the compositing int the space tree needs to be re-evaluated using
|
|
|
|
|
* regular compositing pipeline.
|
|
|
|
|
*/
|
2022-05-05 17:33:10 +10:00
|
|
|
bool recalc_regular_compositing;
|
2021-01-19 16:43:08 -06:00
|
|
|
|
|
|
|
|
/** Temporary data for modal linking operator. */
|
2021-11-19 15:36:32 -05:00
|
|
|
std::unique_ptr<bNodeLinkDrag> linkdrag;
|
2021-01-19 16:43:08 -06:00
|
|
|
|
|
|
|
|
/* XXX hack for translate_attach op-macros to pass data from transform op to insert_offset op */
|
|
|
|
|
/** Temporary data for node insert offset (in UI called Auto-offset). */
|
2023-08-04 22:47:22 -04:00
|
|
|
NodeInsertOfsData *iofsd;
|
2022-11-01 16:09:49 +01:00
|
|
|
|
2023-08-08 17:36:06 +02:00
|
|
|
/**
|
|
|
|
|
* Use this to store data for the displayed node tree. It has an entry for every distinct
|
2023-08-09 11:20:04 +10:00
|
|
|
* nested node-group.
|
2023-08-08 17:36:06 +02:00
|
|
|
*/
|
|
|
|
|
Map<ComputeContextHash, std::unique_ptr<space_node::NestedTreePreviews>>
|
|
|
|
|
tree_previews_per_context;
|
|
|
|
|
|
2022-11-01 16:09:49 +01:00
|
|
|
/**
|
|
|
|
|
* Temporary data for node add menu in order to provide longer-term storage for context pointers.
|
|
|
|
|
* Recreated every time the root menu is opened. In the future this will be replaced with an "all
|
|
|
|
|
* libraries" cache in the asset system itself.
|
|
|
|
|
*
|
|
|
|
|
* Stored with a shared pointer so that it can be forward declared.
|
|
|
|
|
*/
|
2023-06-29 13:57:54 +02:00
|
|
|
std::shared_ptr<asset::AssetItemTree> assets_for_menu;
|
2021-11-18 11:46:44 -05:00
|
|
|
};
|
2021-01-19 16:43:08 -06:00
|
|
|
|
2021-12-05 16:45:41 -05:00
|
|
|
enum NodeResizeDirection {
|
|
|
|
|
NODE_RESIZE_NONE = 0,
|
|
|
|
|
NODE_RESIZE_TOP = (1 << 0),
|
|
|
|
|
NODE_RESIZE_BOTTOM = (1 << 1),
|
|
|
|
|
NODE_RESIZE_RIGHT = (1 << 2),
|
|
|
|
|
NODE_RESIZE_LEFT = (1 << 3),
|
|
|
|
|
};
|
|
|
|
|
ENUM_OPERATORS(NodeResizeDirection, NODE_RESIZE_LEFT);
|
|
|
|
|
|
2022-05-06 17:56:59 +10:00
|
|
|
/* Nodes draw without DPI - the view zoom is flexible. */
|
2022-02-03 15:34:01 -06:00
|
|
|
#define HIDDEN_RAD (0.75f * U.widget_unit)
|
|
|
|
|
#define BASIS_RAD (0.2f * U.widget_unit)
|
|
|
|
|
#define NODE_DYS (U.widget_unit / 2)
|
|
|
|
|
#define NODE_DY U.widget_unit
|
2023-09-20 11:56:40 +02:00
|
|
|
#define NODE_ITEM_SPACING_Y (0.1f * U.widget_unit)
|
2023-03-17 04:19:05 +01:00
|
|
|
#define NODE_WIDTH(node) (node.width * UI_SCALE_FAC)
|
|
|
|
|
#define NODE_HEIGHT(node) (node.height * UI_SCALE_FAC)
|
2022-02-03 15:34:01 -06:00
|
|
|
#define NODE_MARGIN_X (1.2f * U.widget_unit)
|
|
|
|
|
#define NODE_SOCKSIZE (0.25f * U.widget_unit)
|
2022-02-28 18:05:12 -05:00
|
|
|
#define NODE_SOCKSIZE_DRAW_MULIPLIER 2.25f
|
|
|
|
|
#define NODE_SOCK_OUTLINE_SCALE 1.0f
|
2022-02-03 15:34:01 -06:00
|
|
|
#define NODE_MULTI_INPUT_LINK_GAP (0.25f * U.widget_unit)
|
|
|
|
|
#define NODE_RESIZE_MARGIN (0.20f * U.widget_unit)
|
|
|
|
|
#define NODE_LINK_RESOL 12
|
|
|
|
|
|
2023-08-05 13:46:22 +10:00
|
|
|
/* `space_node.cc` */
|
2022-02-03 15:34:01 -06:00
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Transform between View2Ds in the tree path.
|
|
|
|
|
*/
|
2022-01-20 10:36:56 -06:00
|
|
|
float2 space_node_group_offset(const SpaceNode &snode);
|
2013-03-18 16:34:57 +00:00
|
|
|
|
2021-12-03 11:05:59 -05:00
|
|
|
int node_get_resize_cursor(NodeResizeDirection directions);
|
2023-09-20 17:43:19 +02:00
|
|
|
|
|
|
|
|
/* `node_draw.cc` */
|
|
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Usual convention here would be #node_socket_get_color(),
|
|
|
|
|
* but that's already used (for setting a color property socket).
|
|
|
|
|
*/
|
2023-08-30 12:37:21 +02:00
|
|
|
void node_socket_color_get(const bNodeSocketType &type, float r_color[4]);
|
2022-02-03 15:34:01 -06:00
|
|
|
|
2023-09-20 17:43:19 +02:00
|
|
|
const char *node_socket_get_label(const bNodeSocket *socket, const char *panel_label);
|
2022-02-03 15:34:01 -06:00
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
void node_draw_space(const bContext &C, ARegion ®ion);
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2023-01-02 16:45:49 -05:00
|
|
|
void node_socket_add_tooltip(const bNodeTree &ntree, const bNodeSocket &sock, uiLayout &layout);
|
UI: Add support for showing socket descriptions in tooltips
Currently, hovering over a socket itself shows no tooltip at all, while
hovering over its value field shows "Default value", which is not helpful.
This patch therefore implements socket tooltips following the proposal at
https://blender.community/c/rightclickselect/2Qgbbc/.
A lot of the basic functionality was already implemented for Geometry Nodes,
where hovering over the socket itself shows introspection info.
This patch extends this by:
- Supporting dynamic tooltips on labels, which is important for good tooltip
coverage in a socket's region of the node.
- Adding a function to setting a dynamic tooltip for an entire uiLayout, which
avoids needing to set it manually for a wide variety of socket types.
- Hiding the property label field in a tooltip when dynamic tooltip is also
provided. If really needed, this label can be restored through the dynamic
tooltip, but in all current cases the label is actually pointless anyways
since the dynamic tooltip gives more accurate and specific information.
- Adding dynamic tooltips to a socket's UI layout row if it has a description
configured, both in the Node Editor as well as in the Material Properties.
Note that the patch does not add any actual tooltip content yet, just the
infrastructure to show them. By default, sockets without a description still
show the old "Default value" tooltip.
For an example of how to add socket descriptions, check the Cylinder node
in the Geometry Nodes.
Differential Revision: https://developer.blender.org/D9967
2022-04-11 02:02:12 +02:00
|
|
|
|
2022-01-18 13:07:18 -06:00
|
|
|
/**
|
|
|
|
|
* Sort nodes by selection: unselected nodes first, then selected,
|
|
|
|
|
* then the active node at the very end. Relative order is kept intact.
|
|
|
|
|
*/
|
2022-01-18 13:32:36 -06:00
|
|
|
void node_sort(bNodeTree &ntree);
|
2022-01-18 13:07:18 -06:00
|
|
|
|
2022-01-20 10:36:56 -06:00
|
|
|
void node_set_cursor(wmWindow &win, SpaceNode &snode, const float2 &cursor);
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
/* DPI scaled coords */
|
2022-01-20 10:36:56 -06:00
|
|
|
float2 node_to_view(const bNode &node, const float2 &co);
|
2021-12-03 16:25:17 -05:00
|
|
|
void node_to_updated_rect(const bNode &node, rctf &r_rect);
|
2022-01-20 10:36:56 -06:00
|
|
|
float2 node_from_view(const bNode &node, const float2 &co);
|
2012-05-22 14:13:33 +00:00
|
|
|
|
2023-08-05 13:46:22 +10:00
|
|
|
/* `node_ops.cc` */
|
2022-02-03 15:34:01 -06:00
|
|
|
|
2022-01-05 21:44:03 -05:00
|
|
|
void node_operatortypes();
|
2021-11-18 11:46:44 -05:00
|
|
|
void node_keymap(wmKeyConfig *keyconf);
|
2008-12-28 00:08:34 +00:00
|
|
|
|
2023-08-05 13:46:22 +10:00
|
|
|
/* `node_select.cc` */
|
2022-02-03 15:34:01 -06:00
|
|
|
|
2023-06-03 12:45:12 +02:00
|
|
|
rctf node_frame_rect_inside(const SpaceNode &snode, const bNode &node);
|
2022-09-02 16:38:08 -05:00
|
|
|
bool node_or_socket_isect_event(const bContext &C, const wmEvent &event);
|
2022-05-18 14:25:05 +10:00
|
|
|
|
2022-12-20 17:14:34 -06:00
|
|
|
void node_deselect_all(bNodeTree &node_tree);
|
2021-12-03 16:25:17 -05:00
|
|
|
void node_socket_select(bNode *node, bNodeSocket &sock);
|
2022-01-07 11:38:08 +11:00
|
|
|
void node_socket_deselect(bNode *node, bNodeSocket &sock, bool deselect_node);
|
2022-12-20 17:14:34 -06:00
|
|
|
void node_deselect_all_input_sockets(bNodeTree &node_tree, bool deselect_nodes);
|
|
|
|
|
void node_deselect_all_output_sockets(bNodeTree &node_tree, bool deselect_nodes);
|
Geometry Nodes: add simulation support
This adds support for building simulations with geometry nodes. A new
`Simulation Input` and `Simulation Output` node allow maintaining a
simulation state across multiple frames. Together these two nodes form
a `simulation zone` which contains all the nodes that update the simulation
state from one frame to the next.
A new simulation zone can be added via the menu
(`Simulation > Simulation Zone`) or with the node add search.
The simulation state contains a geometry by default. However, it is possible
to add multiple geometry sockets as well as other socket types. Currently,
field inputs are evaluated and stored for the preceding geometry socket in
the order that the sockets are shown. Simulation state items can be added
by linking one of the empty sockets to something else. In the sidebar, there
is a new panel that allows adding, removing and reordering these sockets.
The simulation nodes behave as follows:
* On the first frame, the inputs of the `Simulation Input` node are evaluated
to initialize the simulation state. In later frames these sockets are not
evaluated anymore. The `Delta Time` at the first frame is zero, but the
simulation zone is still evaluated.
* On every next frame, the `Simulation Input` node outputs the simulation
state of the previous frame. Nodes in the simulation zone can edit that
data in arbitrary ways, also taking into account the `Delta Time`. The new
simulation state has to be passed to the `Simulation Output` node where it
is cached and forwarded.
* On a frame that is already cached or baked, the nodes in the simulation
zone are not evaluated, because the `Simulation Output` node can return
the previously cached data directly.
It is not allowed to connect sockets from inside the simulation zone to the
outside without going through the `Simulation Output` node. This is a necessary
restriction to make caching and sub-frame interpolation work. Links can go into
the simulation zone without problems though.
Anonymous attributes are not propagated by the simulation nodes unless they
are explicitly stored in the simulation state. This is unfortunate, but
currently there is no practical and reliable alternative. The core problem
is detecting which anonymous attributes will be required for the simulation
and afterwards. While we can detect this for the current evaluation, we can't
look into the future in time to see what data will be necessary. We intend to
make it easier to explicitly pass data through a simulation in the future,
even if the simulation is in a nested node group.
There is a new `Simulation Nodes` panel in the physics tab in the properties
editor. It allows baking all simulation zones on the selected objects. The
baking options are intentially kept at a minimum for this MVP. More features
for simulation baking as well as baking in general can be expected to be added
separately.
All baked data is stored on disk in a folder next to the .blend file. #106937
describes how baking is implemented in more detail. Volumes can not be baked
yet and materials are lost during baking for now. Packing the baked data into
the .blend file is not yet supported.
The timeline indicates which frames are currently cached, baked or cached but
invalidated by user-changes.
Simulation input and output nodes are internally linked together by their
`bNode.identifier` which stays the same even if the node name changes. They
are generally added and removed together. However, there are still cases where
"dangling" simulation nodes can be created currently. Those generally don't
cause harm, but would be nice to avoid this in more cases in the future.
Co-authored-by: Hans Goudey <h.goudey@me.com>
Co-authored-by: Lukas Tönne <lukas@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/104924
2023-05-03 13:18:51 +02:00
|
|
|
/**
|
|
|
|
|
* Select nodes that are paired to a selected node.
|
|
|
|
|
*/
|
|
|
|
|
void node_select_paired(bNodeTree &node_tree);
|
2021-12-03 16:25:17 -05:00
|
|
|
void node_select_single(bContext &C, bNode &node);
|
2021-11-18 11:46:44 -05:00
|
|
|
|
|
|
|
|
void NODE_OT_select(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_select_all(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_select_linked_to(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_select_linked_from(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_select_box(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_select_circle(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_select_lasso(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_select_grouped(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_select_same_type_step(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_find_node(wmOperatorType *ot);
|
2008-12-28 00:08:34 +00:00
|
|
|
|
2023-08-05 13:46:22 +10:00
|
|
|
/* `node_view.cc` */
|
2022-02-03 15:34:01 -06:00
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
bool space_node_view_flag(
|
|
|
|
|
bContext &C, SpaceNode &snode, ARegion ®ion, int node_flag, int smooth_viewtx);
|
2013-03-27 17:22:12 +00:00
|
|
|
|
2021-11-18 11:46:44 -05:00
|
|
|
void NODE_OT_view_all(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_view_selected(wmOperatorType *ot);
|
2011-12-18 12:51:50 +00:00
|
|
|
|
2021-11-18 11:46:44 -05:00
|
|
|
void NODE_OT_backimage_move(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_backimage_zoom(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_backimage_fit(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_backimage_sample(wmOperatorType *ot);
|
2012-08-02 21:52:09 +00:00
|
|
|
|
2023-08-05 13:46:22 +10:00
|
|
|
/* `drawnode.cc` */
|
2022-02-03 15:34:01 -06:00
|
|
|
|
2023-06-03 12:45:12 +02:00
|
|
|
NodeResizeDirection node_get_resize_direction(const SpaceNode &snode,
|
|
|
|
|
const bNode *node,
|
|
|
|
|
int x,
|
|
|
|
|
int y);
|
2022-02-03 15:34:01 -06:00
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
void nodelink_batch_start(SpaceNode &snode);
|
|
|
|
|
void nodelink_batch_end(SpaceNode &snode);
|
|
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* \note this is used for fake links in groups too.
|
|
|
|
|
*/
|
2023-08-30 12:37:21 +02:00
|
|
|
void node_draw_link(const View2D &v2d,
|
2021-12-03 16:25:17 -05:00
|
|
|
const SpaceNode &snode,
|
2022-02-28 15:52:00 -05:00
|
|
|
const bNodeLink &link,
|
|
|
|
|
bool selected);
|
2023-08-30 12:37:21 +02:00
|
|
|
void node_draw_link_dragged(const View2D &v2d, const SpaceNode &snode, const bNodeLink &link);
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Don't do shadows if th_col3 is -1.
|
|
|
|
|
*/
|
2023-08-30 12:37:21 +02:00
|
|
|
void node_draw_link_bezier(const View2D &v2d,
|
2021-12-03 16:25:17 -05:00
|
|
|
const SpaceNode &snode,
|
|
|
|
|
const bNodeLink &link,
|
2018-04-05 15:41:17 +02:00
|
|
|
int th_col1,
|
|
|
|
|
int th_col2,
|
2022-02-28 15:52:00 -05:00
|
|
|
int th_col3,
|
|
|
|
|
bool selected);
|
2022-09-02 15:43:53 -05:00
|
|
|
|
Geometry Nodes: add simulation support
This adds support for building simulations with geometry nodes. A new
`Simulation Input` and `Simulation Output` node allow maintaining a
simulation state across multiple frames. Together these two nodes form
a `simulation zone` which contains all the nodes that update the simulation
state from one frame to the next.
A new simulation zone can be added via the menu
(`Simulation > Simulation Zone`) or with the node add search.
The simulation state contains a geometry by default. However, it is possible
to add multiple geometry sockets as well as other socket types. Currently,
field inputs are evaluated and stored for the preceding geometry socket in
the order that the sockets are shown. Simulation state items can be added
by linking one of the empty sockets to something else. In the sidebar, there
is a new panel that allows adding, removing and reordering these sockets.
The simulation nodes behave as follows:
* On the first frame, the inputs of the `Simulation Input` node are evaluated
to initialize the simulation state. In later frames these sockets are not
evaluated anymore. The `Delta Time` at the first frame is zero, but the
simulation zone is still evaluated.
* On every next frame, the `Simulation Input` node outputs the simulation
state of the previous frame. Nodes in the simulation zone can edit that
data in arbitrary ways, also taking into account the `Delta Time`. The new
simulation state has to be passed to the `Simulation Output` node where it
is cached and forwarded.
* On a frame that is already cached or baked, the nodes in the simulation
zone are not evaluated, because the `Simulation Output` node can return
the previously cached data directly.
It is not allowed to connect sockets from inside the simulation zone to the
outside without going through the `Simulation Output` node. This is a necessary
restriction to make caching and sub-frame interpolation work. Links can go into
the simulation zone without problems though.
Anonymous attributes are not propagated by the simulation nodes unless they
are explicitly stored in the simulation state. This is unfortunate, but
currently there is no practical and reliable alternative. The core problem
is detecting which anonymous attributes will be required for the simulation
and afterwards. While we can detect this for the current evaluation, we can't
look into the future in time to see what data will be necessary. We intend to
make it easier to explicitly pass data through a simulation in the future,
even if the simulation is in a nested node group.
There is a new `Simulation Nodes` panel in the physics tab in the properties
editor. It allows baking all simulation zones on the selected objects. The
baking options are intentially kept at a minimum for this MVP. More features
for simulation baking as well as baking in general can be expected to be added
separately.
All baked data is stored on disk in a folder next to the .blend file. #106937
describes how baking is implemented in more detail. Volumes can not be baked
yet and materials are lost during baking for now. Packing the baked data into
the .blend file is not yet supported.
The timeline indicates which frames are currently cached, baked or cached but
invalidated by user-changes.
Simulation input and output nodes are internally linked together by their
`bNode.identifier` which stays the same even if the node name changes. They
are generally added and removed together. However, there are still cases where
"dangling" simulation nodes can be created currently. Those generally don't
cause harm, but would be nice to avoid this in more cases in the future.
Co-authored-by: Hans Goudey <h.goudey@me.com>
Co-authored-by: Lukas Tönne <lukas@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/104924
2023-05-03 13:18:51 +02:00
|
|
|
std::array<float2, 4> node_link_bezier_points_dragged(const SpaceNode &snode,
|
|
|
|
|
const bNodeLink &link);
|
2023-03-19 07:03:01 +01:00
|
|
|
void node_link_bezier_points_evaluated(const bNodeLink &link,
|
2022-09-02 15:43:53 -05:00
|
|
|
std::array<float2, NODE_LINK_RESOL + 1> &coords);
|
2022-09-02 15:25:34 -05:00
|
|
|
|
2023-03-19 07:03:01 +01:00
|
|
|
std::optional<float2> link_path_intersection(const bNodeLink &link, Span<float2> path);
|
2022-09-03 14:52:27 -05:00
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
void draw_nodespace_back_pix(const bContext &C,
|
|
|
|
|
ARegion ®ion,
|
|
|
|
|
SpaceNode &snode,
|
2013-04-24 16:36:50 +00:00
|
|
|
bNodeInstanceKey parent_key);
|
2012-08-01 19:11:17 +00:00
|
|
|
|
2023-08-05 13:46:22 +10:00
|
|
|
/* `node_add.cc` */
|
2022-01-18 13:07:18 -06:00
|
|
|
|
2022-08-01 16:32:43 -05:00
|
|
|
bNode *add_node(const bContext &C, StringRef idname, const float2 &location);
|
|
|
|
|
bNode *add_static_node(const bContext &C, int type, const float2 &location);
|
|
|
|
|
|
2021-11-18 11:46:44 -05:00
|
|
|
void NODE_OT_add_reroute(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_add_group(wmOperatorType *ot);
|
2022-11-01 16:09:49 +01:00
|
|
|
void NODE_OT_add_group_asset(wmOperatorType *ot);
|
2021-11-18 11:46:44 -05:00
|
|
|
void NODE_OT_add_object(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_add_collection(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_add_file(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_add_mask(wmOperatorType *ot);
|
2023-08-29 15:51:18 +02:00
|
|
|
void NODE_OT_add_material(wmOperatorType *ot);
|
2021-11-18 11:46:44 -05:00
|
|
|
void NODE_OT_new_node_tree(wmOperatorType *ot);
|
2012-08-01 19:11:17 +00:00
|
|
|
|
2023-08-05 13:46:22 +10:00
|
|
|
/* `node_group.cc` */
|
2022-02-03 15:34:01 -06:00
|
|
|
|
2021-11-18 11:46:44 -05:00
|
|
|
const char *node_group_idname(bContext *C);
|
|
|
|
|
void NODE_OT_group_make(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_group_insert(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_group_ungroup(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_group_separate(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_group_edit(wmOperatorType *ot);
|
2012-08-01 19:11:17 +00:00
|
|
|
|
2023-08-05 13:46:22 +10:00
|
|
|
/* `node_relationships.cc` */
|
2022-02-03 15:34:01 -06:00
|
|
|
|
2022-10-14 14:07:55 -05:00
|
|
|
void update_multi_input_indices_for_removed_links(bNode &node);
|
2023-06-05 20:21:07 +02:00
|
|
|
bool all_links_muted(const bNodeSocket &socket);
|
2023-08-11 16:47:56 +02:00
|
|
|
bNodeSocket *get_main_socket(bNodeTree &ntree, bNode &node, eNodeSocketInOut in_out);
|
2022-10-14 14:07:55 -05:00
|
|
|
|
2021-11-18 11:46:44 -05:00
|
|
|
void NODE_OT_link(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_link_make(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_links_cut(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_links_detach(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_links_mute(wmOperatorType *ot);
|
2012-08-01 19:11:17 +00:00
|
|
|
|
2021-11-18 11:46:44 -05:00
|
|
|
void NODE_OT_parent_set(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_join(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_attach(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_detach(wmOperatorType *ot);
|
2012-08-01 19:11:17 +00:00
|
|
|
|
2021-11-18 11:46:44 -05:00
|
|
|
void NODE_OT_link_viewer(wmOperatorType *ot);
|
2012-08-01 19:11:17 +00:00
|
|
|
|
2021-11-18 11:46:44 -05:00
|
|
|
void NODE_OT_insert_offset(wmOperatorType *ot);
|
2015-08-01 17:39:48 +02:00
|
|
|
|
2023-08-03 01:11:28 +02:00
|
|
|
wmKeyMap *node_link_modal_keymap(wmKeyConfig *keyconf);
|
2023-02-03 17:41:12 +01:00
|
|
|
|
2023-08-05 13:46:22 +10:00
|
|
|
/* `node_edit.cc` */
|
2022-02-03 15:34:01 -06:00
|
|
|
|
|
|
|
|
float2 node_link_calculate_multi_input_position(const float2 &socket_position,
|
|
|
|
|
int index,
|
|
|
|
|
int total_inputs);
|
|
|
|
|
|
|
|
|
|
float node_socket_calculate_height(const bNodeSocket &socket);
|
|
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
void snode_set_context(const bContext &C);
|
2021-11-18 11:46:44 -05:00
|
|
|
|
|
|
|
|
bool composite_node_active(bContext *C);
|
2021-12-09 00:55:11 +11:00
|
|
|
/** Operator poll callback. */
|
2021-11-18 11:46:44 -05:00
|
|
|
bool composite_node_editable(bContext *C);
|
|
|
|
|
|
|
|
|
|
bool node_has_hidden_sockets(bNode *node);
|
2023-06-04 14:55:20 +10:00
|
|
|
void node_set_hidden_sockets(bNode *node, int set);
|
2023-08-09 14:04:11 +02:00
|
|
|
bool node_is_previewable(const SpaceNode &snode, const bNodeTree &ntree, const bNode &node);
|
2021-11-18 11:46:44 -05:00
|
|
|
int node_render_changed_exec(bContext *, wmOperator *);
|
2023-01-03 13:34:51 -05:00
|
|
|
bNodeSocket *node_find_indicated_socket(SpaceNode &snode,
|
|
|
|
|
const float2 &cursor,
|
|
|
|
|
eNodeSocketInOut in_out);
|
2023-03-19 07:03:01 +01:00
|
|
|
float node_link_dim_factor(const View2D &v2d, const bNodeLink &link);
|
|
|
|
|
bool node_link_is_hidden_or_dimmed(const View2D &v2d, const bNodeLink &link);
|
2021-11-18 11:46:44 -05:00
|
|
|
|
2023-06-16 17:03:13 +02:00
|
|
|
void remap_node_pairing(bNodeTree &dst_tree, const Map<const bNode *, bNode *> &node_map);
|
|
|
|
|
|
2021-11-18 11:46:44 -05:00
|
|
|
void NODE_OT_duplicate(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_delete(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_delete_reconnect(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_resize(wmOperatorType *ot);
|
|
|
|
|
|
|
|
|
|
void NODE_OT_mute_toggle(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_hide_toggle(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_hide_socket_toggle(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_preview_toggle(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_options_toggle(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_node_copy_color(wmOperatorType *ot);
|
Geometry Nodes: viewport preview
This adds support for showing geometry passed to the Viewer in the 3d
viewport (instead of just in the spreadsheet). The "viewer geometry"
bypasses the group output. So it is not necessary to change the final
output of the node group to be able to see the intermediate geometry.
**Activation and deactivation of a viewer node**
* A viewer node is activated by clicking on it.
* Ctrl+shift+click on any node/socket connects it to the viewer and
makes it active.
* Ctrl+shift+click in empty space deactivates the active viewer.
* When the active viewer is not visible anymore (e.g. another object
is selected, or the current node group is exit), it is deactivated.
* Clicking on the icon in the header of the Viewer node toggles whether
its active or not.
**Pinning**
* The spreadsheet still allows pinning the active viewer as before.
When pinned, the spreadsheet still references the viewer node even
when it becomes inactive.
* The viewport does not support pinning at the moment. It always shows
the active viewer.
**Attribute**
* When a field is linked to the second input of the viewer node it is
displayed as an overlay in the viewport.
* When possible the correct domain for the attribute is determined
automatically. This does not work in all cases. It falls back to the
face corner domain on meshes and the point domain on curves. When
necessary, the domain can be picked manually.
* The spreadsheet now only shows the "Viewer" column for the domain
that is selected in the Viewer node.
* Instance attributes are visualized as a constant color per instance.
**Viewport Options**
* The attribute overlay opacity can be controlled with the "Viewer Node"
setting in the overlays popover.
* A viewport can be configured not to show intermediate viewer-geometry
by disabling the "Viewer Node" option in the "View" menu.
**Implementation Details**
* The "spreadsheet context path" was generalized to a "viewer path" that
is used in more places now.
* The viewer node itself determines the attribute domain, evaluates the
field and stores the result in a `.viewer` attribute.
* A new "viewer attribute' overlay displays the data from the `.viewer`
attribute.
* The ground truth for the active viewer node is stored in the workspace
now. Node editors, spreadsheets and viewports retrieve the active
viewer from there unless they are pinned.
* The depsgraph object iterator has a new "viewer path" setting. When set,
the viewed geometry of the corresponding object is part of the iterator
instead of the final evaluated geometry.
* To support the instance attribute overlay `DupliObject` was extended
to contain the information necessary for drawing the overlay.
* The ctrl+shift+click operator has been refactored so that it can make
existing links to viewers active again.
* The auto-domain-detection in the Viewer node works by checking the
"preferred domain" for every field input. If there is not exactly one
preferred domain, the fallback is used.
Known limitations:
* Loose edges of meshes don't have the attribute overlay. This could be
added separately if necessary.
* Some attributes are hard to visualize as a color directly. For example,
the values might have to be normalized or some should be drawn as arrays.
For now, we encourage users to build node groups that generate appropriate
viewer-geometry. We might include some of that functionality in future versions.
Support for displaying attribute values as text in the viewport is planned as well.
* There seems to be an issue with the attribute overlay for pointclouds on
nvidia gpus, to be investigated.
Differential Revision: https://developer.blender.org/D15954
2022-09-28 17:54:59 +02:00
|
|
|
void NODE_OT_deactivate_viewer(wmOperatorType *ot);
|
2021-11-18 11:46:44 -05:00
|
|
|
|
|
|
|
|
void NODE_OT_read_viewlayers(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_render_changed(wmOperatorType *ot);
|
|
|
|
|
|
|
|
|
|
void NODE_OT_output_file_add_socket(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_output_file_remove_active_socket(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_output_file_move_active_socket(wmOperatorType *ot);
|
|
|
|
|
|
|
|
|
|
void NODE_OT_switch_view_update(wmOperatorType *ot);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* \note clipboard_cut is a simple macro of copy + delete.
|
|
|
|
|
*/
|
2021-11-18 11:46:44 -05:00
|
|
|
void NODE_OT_clipboard_copy(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_clipboard_paste(wmOperatorType *ot);
|
2012-08-02 09:52:37 +00:00
|
|
|
|
2021-11-18 11:46:44 -05:00
|
|
|
void NODE_OT_shader_script_update(wmOperatorType *ot);
|
2012-11-03 14:32:26 +00:00
|
|
|
|
2021-11-18 11:46:44 -05:00
|
|
|
void NODE_OT_viewer_border(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_clear_viewer_border(wmOperatorType *ot);
|
2013-03-07 17:47:30 +00:00
|
|
|
|
2022-02-03 15:34:01 -06:00
|
|
|
void NODE_OT_cryptomatte_layer_add(wmOperatorType *ot);
|
|
|
|
|
void NODE_OT_cryptomatte_layer_remove(wmOperatorType *ot);
|
|
|
|
|
|
2023-08-05 13:46:22 +10:00
|
|
|
/* `node_gizmo.cc` */
|
2022-02-03 15:34:01 -06:00
|
|
|
|
2021-11-18 11:46:44 -05:00
|
|
|
void NODE_GGT_backdrop_transform(wmGizmoGroupType *gzgt);
|
|
|
|
|
void NODE_GGT_backdrop_crop(wmGizmoGroupType *gzgt);
|
|
|
|
|
void NODE_GGT_backdrop_sun_beams(wmGizmoGroupType *gzgt);
|
|
|
|
|
void NODE_GGT_backdrop_corner_pin(wmGizmoGroupType *gzgt);
|
2017-05-29 22:06:59 +10:00
|
|
|
|
2023-08-05 13:46:22 +10:00
|
|
|
/* `node_geometry_attribute_search.cc` */
|
2017-05-29 22:06:59 +10:00
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
void node_geometry_add_attribute_search_button(const bContext &C,
|
|
|
|
|
const bNode &node,
|
|
|
|
|
PointerRNA &socket_ptr,
|
|
|
|
|
uiLayout &layout);
|
2021-03-02 13:01:33 -06:00
|
|
|
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `node_context_path.cc` */
|
2008-12-13 18:09:49 +00:00
|
|
|
|
2021-10-26 11:05:01 -05:00
|
|
|
Vector<ui::ContextPathItem> context_path_for_space_node(const bContext &C);
|
2021-12-03 11:31:25 -05:00
|
|
|
|
2023-08-05 13:46:22 +10:00
|
|
|
/* `link_drag_search.cc` */
|
2022-02-03 15:34:01 -06:00
|
|
|
|
2021-12-15 09:51:57 -06:00
|
|
|
void invoke_node_link_drag_add_menu(bContext &C,
|
|
|
|
|
bNode &node,
|
|
|
|
|
bNodeSocket &socket,
|
|
|
|
|
const float2 &cursor);
|
|
|
|
|
|
2023-08-05 13:46:22 +10:00
|
|
|
/* `add_menu_assets.cc` */
|
2022-11-01 16:09:49 +01:00
|
|
|
|
|
|
|
|
MenuType add_catalog_assets_menu_type();
|
2023-09-14 17:35:24 +02:00
|
|
|
MenuType add_unassigned_assets_menu_type();
|
2022-11-01 16:09:49 +01:00
|
|
|
MenuType add_root_catalogs_menu_type();
|
|
|
|
|
|
2021-12-15 09:51:57 -06:00
|
|
|
} // namespace blender::ed::space_node
|