2022-02-11 09:07:11 +11:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later
|
2023-02-22 10:16:42 +01:00
|
|
|
* Copyright 2009 Blender Foundation */
|
2011-02-21 07:25:24 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup editors
|
2011-02-21 07:25:24 +00:00
|
|
|
*/
|
|
|
|
|
|
2012-02-17 18:59:41 +00:00
|
|
|
#pragma once
|
2009-01-27 17:12:40 +00:00
|
|
|
|
2020-03-02 15:09:10 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2011-08-12 18:27:48 +00:00
|
|
|
struct ID;
|
|
|
|
|
struct Main;
|
2009-08-19 00:55:30 +00:00
|
|
|
struct Scene;
|
2021-07-16 11:48:54 +10:00
|
|
|
struct SpaceNode;
|
2009-08-19 00:55:30 +00:00
|
|
|
struct Tex;
|
2019-01-28 21:08:24 +11:00
|
|
|
struct View2D;
|
2009-09-16 18:59:13 +00:00
|
|
|
struct bContext;
|
|
|
|
|
struct bNode;
|
2013-03-18 16:34:57 +00:00
|
|
|
struct bNodeSocketType;
|
2011-08-12 18:27:48 +00:00
|
|
|
struct bNodeTree;
|
2013-03-18 16:34:57 +00:00
|
|
|
struct bNodeTreeType;
|
2019-01-28 21:08:24 +11:00
|
|
|
struct bNodeType;
|
2012-06-29 14:34:46 +00:00
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
|
NODE_TOP = 1,
|
|
|
|
|
NODE_BOTTOM = 2,
|
|
|
|
|
NODE_LEFT = 4,
|
2019-01-15 23:57:49 +11:00
|
|
|
NODE_RIGHT = 8,
|
2012-06-29 14:34:46 +00:00
|
|
|
} NodeBorder;
|
2022-11-17 17:13:38 +01:00
|
|
|
ENUM_OPERATORS(NodeBorder, NODE_RIGHT)
|
2009-08-19 00:55:30 +00:00
|
|
|
|
2022-03-30 21:21:57 +02:00
|
|
|
#define NODE_GRID_STEP_SIZE U.widget_unit /* Based on the grid nodes snap to. */
|
2021-06-16 18:17:07 +01:00
|
|
|
#define NODE_EDGE_PAN_INSIDE_PAD 2
|
|
|
|
|
#define NODE_EDGE_PAN_OUTSIDE_PAD 0 /* Disable clamping for node panning, use whole screen. */
|
|
|
|
|
#define NODE_EDGE_PAN_SPEED_RAMP 1
|
2021-08-24 17:45:40 +01:00
|
|
|
#define NODE_EDGE_PAN_MAX_SPEED 26 /* In UI units per second, slower than default. */
|
|
|
|
|
#define NODE_EDGE_PAN_DELAY 0.5f
|
|
|
|
|
#define NODE_EDGE_PAN_ZOOM_INFLUENCE 0.5f
|
2013-11-06 17:46:32 +00:00
|
|
|
|
2022-12-29 16:40:29 -05:00
|
|
|
/* clipboard.cc */
|
|
|
|
|
|
|
|
|
|
void ED_node_clipboard_free(void);
|
|
|
|
|
|
2022-02-03 15:34:01 -06:00
|
|
|
/* space_node.cc */
|
2021-01-19 16:43:08 -06:00
|
|
|
|
|
|
|
|
void ED_node_cursor_location_get(const struct SpaceNode *snode, float value[2]);
|
|
|
|
|
void ED_node_cursor_location_set(struct SpaceNode *snode, const float value[2]);
|
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
int ED_node_tree_path_length(struct SpaceNode *snode);
|
|
|
|
|
void ED_node_tree_path_get(struct SpaceNode *snode, char *value);
|
|
|
|
|
|
|
|
|
|
void ED_node_tree_start(struct SpaceNode *snode,
|
|
|
|
|
struct bNodeTree *ntree,
|
|
|
|
|
struct ID *id,
|
|
|
|
|
struct ID *from);
|
|
|
|
|
void ED_node_tree_push(struct SpaceNode *snode, struct bNodeTree *ntree, struct bNode *gnode);
|
|
|
|
|
void ED_node_tree_pop(struct SpaceNode *snode);
|
|
|
|
|
int ED_node_tree_depth(struct SpaceNode *snode);
|
|
|
|
|
struct bNodeTree *ED_node_tree_get(struct SpaceNode *snode, int level);
|
|
|
|
|
|
2013-04-24 16:36:50 +00:00
|
|
|
void ED_node_set_active_viewer_key(struct SpaceNode *snode);
|
|
|
|
|
|
2022-02-03 15:34:01 -06:00
|
|
|
/* drawnode.cc */
|
2021-12-09 00:55:11 +11:00
|
|
|
|
2012-08-01 13:28:19 +00:00
|
|
|
void ED_node_init_butfuncs(void);
|
2013-03-18 16:34:57 +00:00
|
|
|
void ED_init_custom_node_type(struct bNodeType *ntype);
|
|
|
|
|
void ED_init_custom_node_socket_type(struct bNodeSocketType *stype);
|
|
|
|
|
void ED_init_standard_node_socket_type(struct bNodeSocketType *stype);
|
|
|
|
|
void ED_init_node_socket_type_virtual(struct bNodeSocketType *stype);
|
2012-08-01 13:28:19 +00:00
|
|
|
void ED_node_sample_set(const float col[4]);
|
2017-02-02 03:14:52 -02:00
|
|
|
void ED_node_draw_snap(
|
2020-02-08 01:02:18 +11:00
|
|
|
struct View2D *v2d, const float cent[2], float size, NodeBorder border, unsigned int pos);
|
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
|
|
|
void ED_node_type_draw_color(const char *idname, float *r_color);
|
2012-06-29 14:34:46 +00:00
|
|
|
|
2021-02-16 10:55:10 -06:00
|
|
|
/* node_draw.cc */
|
2021-12-09 00:55:11 +11:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
void ED_node_tree_update(const struct bContext *C);
|
|
|
|
|
void ED_node_tag_update_id(struct ID *id);
|
2021-12-21 15:18:56 +01:00
|
|
|
|
2013-11-06 17:46:32 +00:00
|
|
|
float ED_node_grid_size(void);
|
2009-09-16 18:59:13 +00:00
|
|
|
|
2022-02-03 15:34:01 -06:00
|
|
|
/* node_edit.cc */
|
2021-12-09 00:55:11 +11:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
void ED_node_set_tree_type(struct SpaceNode *snode, struct bNodeTreeType *typeinfo);
|
2014-02-03 18:55:59 +11:00
|
|
|
bool ED_node_is_compositor(struct SpaceNode *snode);
|
|
|
|
|
bool ED_node_is_shader(struct SpaceNode *snode);
|
|
|
|
|
bool ED_node_is_texture(struct SpaceNode *snode);
|
2020-12-02 13:25:25 +01:00
|
|
|
bool ED_node_is_geometry(struct SpaceNode *snode);
|
2013-03-18 16:34:57 +00:00
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Assumes nothing being done in ntree yet, sets the default in/out node.
|
|
|
|
|
* Called from shading buttons or header.
|
|
|
|
|
*/
|
2013-03-18 16:34:57 +00:00
|
|
|
void ED_node_shader_default(const struct bContext *C, struct ID *id);
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Assumes nothing being done in ntree yet, sets the default in/out node.
|
|
|
|
|
* Called from shading buttons or header.
|
|
|
|
|
*/
|
2013-03-18 16:34:57 +00:00
|
|
|
void ED_node_composit_default(const struct bContext *C, struct Scene *scene);
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Assumes nothing being done in ntree yet, sets the default in/out node.
|
|
|
|
|
* Called from shading buttons or header.
|
|
|
|
|
*/
|
2013-03-18 16:34:57 +00:00
|
|
|
void ED_node_texture_default(const struct bContext *C, struct Tex *tex);
|
2012-05-22 14:13:33 +00:00
|
|
|
void ED_node_post_apply_transform(struct bContext *C, struct bNodeTree *ntree);
|
2020-05-25 10:43:44 +02:00
|
|
|
void ED_node_set_active(struct Main *bmain,
|
2021-07-05 10:46:00 +02:00
|
|
|
struct SpaceNode *snode,
|
2020-05-25 10:43:44 +02:00
|
|
|
struct bNodeTree *ntree,
|
|
|
|
|
struct bNode *node,
|
|
|
|
|
bool *r_active_texture_changed);
|
2012-06-21 14:12:14 +00:00
|
|
|
|
2021-12-21 15:18:56 +01:00
|
|
|
/**
|
|
|
|
|
* Call after one or more node trees have been changed and tagged accordingly.
|
|
|
|
|
*
|
|
|
|
|
* This function will make sure that other parts of Blender update accordingly. For example, if the
|
|
|
|
|
* node group interface changed, parent node groups have to be updated as well.
|
|
|
|
|
*
|
|
|
|
|
* Additionally, this will send notifiers and tag the depsgraph based on the changes. Depsgraph
|
|
|
|
|
* relation updates have to be triggered by the caller.
|
|
|
|
|
*
|
|
|
|
|
* \param C: Context if available. This can be null.
|
|
|
|
|
* \param bmain: Main whose data-blocks should be updated based on the changes.
|
|
|
|
|
* \param ntree: Under some circumstances the caller knows that only one node tree has
|
|
|
|
|
* changed since the last update. In this case the function may be able to skip scanning #bmain
|
|
|
|
|
* for other things that have to be changed. It may still scan #bmain if the interface of the
|
|
|
|
|
* node tree has changed.
|
|
|
|
|
*/
|
|
|
|
|
void ED_node_tree_propagate_change(const struct bContext *C,
|
|
|
|
|
struct Main *bmain,
|
|
|
|
|
struct bNodeTree *ntree);
|
|
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* \param scene_owner: is the owner of the job,
|
|
|
|
|
* we don't use it for anything else currently so could also be a void pointer,
|
|
|
|
|
* but for now keep it an 'Scene' for consistency.
|
|
|
|
|
*
|
|
|
|
|
* \note only call from spaces `refresh` callbacks, not direct! - use with care.
|
|
|
|
|
*/
|
2014-01-28 01:55:10 +11:00
|
|
|
void ED_node_composite_job(const struct bContext *C,
|
|
|
|
|
struct bNodeTree *nodetree,
|
|
|
|
|
struct Scene *scene_owner);
|
2012-08-03 20:56:04 +00:00
|
|
|
|
2022-02-03 15:34:01 -06:00
|
|
|
/* node_ops.cc */
|
2021-12-09 00:55:11 +11:00
|
|
|
|
2009-11-20 21:04:41 +00:00
|
|
|
void ED_operatormacros_node(void);
|
2009-08-19 00:55:30 +00:00
|
|
|
|
2022-02-03 15:34:01 -06:00
|
|
|
/* node_view.cc */
|
|
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Returns mouse position in image space.
|
|
|
|
|
*/
|
Compositor: Redesign Cryptomatte node for better usability
In the current implementation, cryptomatte passes are connected to the node
and elements are picked by using the eyedropper tool on a special pick channel.
This design has two disadvantages - both connecting all passes individually
and always having to switch to the picker channel are tedious.
With the new design, the user selects the RenderLayer or Image from which the
Cryptomatte layers are directly loaded (the type of pass is determined by an
enum). This allows the node to automatically detect all relevant passes.
Then, when using the eyedropper tool, the operator looks up the selected
coordinates from the picked Image, Node backdrop or Clip and reads the picked
object directly from the Renderlayer/Image, therefore allowing to pick in any
context (e.g. by clicking on the Combined pass in the Image Viewer). The
sampled color is looked up in the metadata and the actual name is stored
in the cryptomatte node. This also allows to remove a hash by just removing
the name from the matte id.
Technically there is some loss of flexibility because the Cryptomatte pass
inputs can no longer be connected to other nodes, but since any compositing
done on them is likely to break the Cryptomatte system anyways, this isn't
really a concern in practise.
In the future, this would also allow to automatically translate values to names
by looking up the value in the associated metadata of the input, or to get a
better visualization of overlapping areas in the Pick output since we could
blend colors now that the output doesn't have to contain the exact value.
Idea + Original patch: Lucas Stockner
Reviewed By: Brecht van Lommel
Differential Revision: https://developer.blender.org/D3959
2021-03-16 07:37:30 +01:00
|
|
|
bool ED_space_node_get_position(struct Main *bmain,
|
|
|
|
|
struct SpaceNode *snode,
|
|
|
|
|
struct ARegion *region,
|
|
|
|
|
const int mval[2],
|
|
|
|
|
float fpos[2]);
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Returns color in linear space, matching #ED_space_image_color_sample().
|
|
|
|
|
* And here we've got recursion in the comments tips...
|
|
|
|
|
*/
|
2020-03-06 16:56:42 +01:00
|
|
|
bool ED_space_node_color_sample(struct Main *bmain,
|
|
|
|
|
struct SpaceNode *snode,
|
|
|
|
|
struct ARegion *region,
|
2020-07-13 11:27:09 +02:00
|
|
|
const int mval[2],
|
2020-03-06 16:56:42 +01:00
|
|
|
float r_col[3]);
|
2012-08-16 14:47:14 +00:00
|
|
|
|
2020-03-02 15:09:10 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|