diff options
author | Colin Basnett <cmbasnett@gmail.com> | 2022-09-17 03:50:37 +0300 |
---|---|---|
committer | Colin Basnett <cmbasnett@gmail.com> | 2022-09-17 03:50:37 +0300 |
commit | 564bda241a973396da51d7c3ccd9efd97d51728a (patch) | |
tree | 4d9aa4cccd82e2e606b47774afa5e1015bf14768 /source/blender/makesdna/DNA_node_types.h | |
parent | 0fff238150d076576053c25b646f653d6e3b0edb (diff) | |
parent | 48d7ff68f0df209c77bbb081ab46fbc109fd825a (diff) |
Merge branch 'master' into feature-imformatfeature-imformat
Diffstat (limited to 'source/blender/makesdna/DNA_node_types.h')
-rw-r--r-- | source/blender/makesdna/DNA_node_types.h | 306 |
1 files changed, 269 insertions, 37 deletions
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index 25c8a1f1514..735f5c7b20a 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -12,8 +12,33 @@ #include "DNA_scene_types.h" /* for #ImageFormatData */ #include "DNA_vec_types.h" /* for #rctf */ +/** Workaround to forward-declare C++ type in C header. */ #ifdef __cplusplus -extern "C" { +namespace blender { +template<typename T> class Span; +class StringRef; +class StringRefNull; +} // namespace blender +namespace blender::nodes { +class NodeDeclaration; +class SocketDeclaration; +} // namespace blender::nodes +namespace blender::bke { +class bNodeTreeRuntime; +class bNodeRuntime; +class bNodeSocketRuntime; +} // namespace blender::bke +using NodeDeclarationHandle = blender::nodes::NodeDeclaration; +using SocketDeclarationHandle = blender::nodes::SocketDeclaration; +using bNodeTreeRuntimeHandle = blender::bke::bNodeTreeRuntime; +using bNodeRuntimeHandle = blender::bke::bNodeRuntime; +using bNodeSocketRuntimeHandle = blender::bke::bNodeSocketRuntime; +#else +typedef struct NodeDeclarationHandle NodeDeclarationHandle; +typedef struct SocketDeclarationHandle SocketDeclarationHandle; +typedef struct bNodeTreeRuntimeHandle bNodeTreeRuntimeHandle; +typedef struct bNodeRuntimeHandle bNodeRuntimeHandle; +typedef struct bNodeSocketRuntimeHandle bNodeSocketRuntimeHandle; #endif struct AnimData; @@ -30,6 +55,7 @@ struct bNodeLink; struct bNodePreview; struct bNodeTreeExec; struct bNodeType; +struct bNode; struct uiBlock; #define NODE_MAXSTR 64 @@ -65,30 +91,6 @@ typedef struct bNodeStack { #define NS_CR_FIT 4 #define NS_CR_STRETCH 5 -/** Workaround to forward-declare C++ type in C header. */ -#ifdef __cplusplus -namespace blender::nodes { -class NodeDeclaration; -class SocketDeclaration; -} // namespace blender::nodes -namespace blender::bke { -class bNodeTreeRuntime; -class bNodeRuntime; -class bNodeSocketRuntime; -} // namespace blender::bke -using NodeDeclarationHandle = blender::nodes::NodeDeclaration; -using SocketDeclarationHandle = blender::nodes::SocketDeclaration; -using bNodeTreeRuntimeHandle = blender::bke::bNodeTreeRuntime; -using bNodeRuntimeHandle = blender::bke::bNodeRuntime; -using bNodeSocketRuntimeHandle = blender::bke::bNodeSocketRuntime; -#else -typedef struct NodeDeclarationHandle NodeDeclarationHandle; -typedef struct SocketDeclarationHandle SocketDeclarationHandle; -typedef struct bNodeTreeRuntimeHandle bNodeTreeRuntimeHandle; -typedef struct bNodeRuntimeHandle bNodeRuntimeHandle; -typedef struct bNodeSocketRuntimeHandle bNodeSocketRuntimeHandle; -#endif - typedef struct bNodeSocket { struct bNodeSocket *next, *prev; @@ -181,6 +183,50 @@ typedef struct bNodeSocket { bNodeStack ns DNA_DEPRECATED; bNodeSocketRuntimeHandle *runtime; + +#ifdef __cplusplus + bool is_available() const; + bool is_multi_input() const; + bool is_input() const; + bool is_output() const; + + /** Utility to access the value of the socket. */ + template<typename T> const T *default_value_typed() const; + + /* The following methods are only available when #bNodeTree.ensure_topology_cache has been + * called. */ + + /** Zero based index for every input and output socket. */ + int index() const; + /** Socket index in the entire node tree. Inputs and outputs share the same index space. */ + int index_in_tree() const; + /** Node this socket belongs to. */ + bNode &owner_node(); + const bNode &owner_node() const; + /** Node tree this socket belongs to. */ + const bNodeTree &owner_tree() const; + + /** Links which are incident to this socket. */ + blender::Span<bNodeLink *> directly_linked_links(); + blender::Span<const bNodeLink *> directly_linked_links() const; + /** Sockets which are connected to this socket with a link. */ + blender::Span<bNodeSocket *> directly_linked_sockets(); + blender::Span<const bNodeSocket *> directly_linked_sockets() const; + bool is_directly_linked() const; + /** + * Sockets which are connected to this socket when reroutes and muted nodes are taken into + * account. + */ + blender::Span<const bNodeSocket *> logically_linked_sockets() const; + bool is_logically_linked() const; + + /** + * For output sockets, this is the corresponding input socket the value of which should be + * forwarded when the node is muted. + */ + const bNodeSocket *internal_link_input() const; + +#endif } bNodeSocket; /** #bNodeSocket.type & #bNodeSocketType.type */ @@ -333,6 +379,40 @@ typedef struct bNode { char iter_flag; bNodeRuntimeHandle *runtime; + +#ifdef __cplusplus + blender::StringRefNull label_or_name() const; + bool is_muted() const; + bool is_reroute() const; + bool is_frame() const; + bool is_group() const; + bool is_group_input() const; + bool is_group_output() const; + const blender::nodes::NodeDeclaration *declaration() const; + + /* The following methods are only available when #bNodeTree.ensure_topology_cache has been + * called. */ + + /** A span containing all input sockets of the node (including unavailable sockets). */ + blender::Span<bNodeSocket *> input_sockets(); + blender::Span<const bNodeSocket *> input_sockets() const; + /** A span containing all output sockets of the node (including unavailable sockets). */ + blender::Span<bNodeSocket *> output_sockets(); + blender::Span<const bNodeSocket *> output_sockets() const; + /** Utility to get an input socket by its index. */ + bNodeSocket &input_socket(int index); + const bNodeSocket &input_socket(int index) const; + /** Utility to get an output socket by its index. */ + bNodeSocket &output_socket(int index); + const bNodeSocket &output_socket(int index) const; + /** A span containing all internal links when the node is muted. */ + blender::Span<const bNodeLink *> internal_links_span() const; + /** Lookup socket of this node by its identifier. */ + const bNodeSocket &input_by_identifier(blender::StringRef identifier) const; + const bNodeSocket &output_by_identifier(blender::StringRef identifier) const; + /** Node tree this node belongs to. */ + const bNodeTree &owner_tree() const; +#endif } bNode; /* node->flag */ @@ -422,6 +502,11 @@ typedef struct bNodeLink { int flag; int multi_input_socket_index; + +#ifdef __cplusplus + bool is_muted() const; +#endif + } bNodeLink; /* link->flag */ @@ -453,6 +538,9 @@ typedef struct bNodeTree { /** Animation data (must be immediately after id for utilities to use it). */ struct AnimData *adt; + /** The ID owning this node tree, in case it is an embedded one. */ + ID *owner_id; + /** Runtime type information. */ struct bNodeTreeType *typeinfo; /** Runtime type identifier. */ @@ -535,6 +623,53 @@ typedef struct bNodeTree { struct PreviewImage *preview; bNodeTreeRuntimeHandle *runtime; + +#ifdef __cplusplus + /** + * Update a run-time cache for the node tree based on it's current state. This makes many methods + * available which allow efficient lookup for topology information (like neighboring sockets). + */ + void ensure_topology_cache() const; + + /* The following methods are only available when #bNodeTree.ensure_topology_cache has been + * called. */ + + /** A span containing all nodes in the node tree. */ + blender::Span<bNode *> all_nodes(); + blender::Span<const bNode *> all_nodes() const; + /** A span containing all group nodes in the node tree. */ + blender::Span<bNode *> group_nodes(); + blender::Span<const bNode *> group_nodes() const; + /** A span containing all input sockets in the node tree. */ + blender::Span<bNodeSocket *> all_input_sockets(); + blender::Span<const bNodeSocket *> all_input_sockets() const; + /** A span containing all output sockets in the node tree. */ + blender::Span<bNodeSocket *> all_output_sockets(); + blender::Span<const bNodeSocket *> all_output_sockets() const; + /** A span containing all sockets in the node tree. */ + blender::Span<bNodeSocket *> all_sockets(); + blender::Span<const bNodeSocket *> all_sockets() const; + /** Efficient lookup of all nodes with a specific type. */ + blender::Span<bNode *> nodes_by_type(blender::StringRefNull type_idname); + blender::Span<const bNode *> nodes_by_type(blender::StringRefNull type_idname) const; + /** + * Cached toposort of all nodes. If there are cycles, the returned array is not actually a + * toposort. However, if a connected component does not contain a cycle, this component is sorted + * correctly. Use #has_link_cycle to check for cycles. + */ + blender::Span<const bNode *> toposort_left_to_right() const; + blender::Span<const bNode *> toposort_right_to_left() const; + /** True when there are any cycles in the node tree. */ + bool has_link_cycle() const; + /** + * True when there are nodes or sockets in the node tree that don't use a known type. This can + * happen when nodes don't exist in the current Blender version that existed in the version where + * this node tree was saved. + */ + bool has_undefined_nodes_or_sockets() const; + /** Get the active group output node. */ + const bNode *group_output_node() const; +#endif } bNodeTree; /** #NodeTree.type, index */ @@ -632,19 +767,19 @@ typedef struct bNodeSocketValueMaterial { /* Data structs, for `node->storage`. */ -enum { +typedef enum CMPNodeMaskType { CMP_NODE_MASKTYPE_ADD = 0, CMP_NODE_MASKTYPE_SUBTRACT = 1, CMP_NODE_MASKTYPE_MULTIPLY = 2, CMP_NODE_MASKTYPE_NOT = 3, -}; +} CMPNodeMaskType; -enum { - CMP_NODE_DILATEERODE_STEP = 0, - CMP_NODE_DILATEERODE_DISTANCE_THRESH = 1, - CMP_NODE_DILATEERODE_DISTANCE = 2, - CMP_NODE_DILATEERODE_DISTANCE_FEATHER = 3, -}; +typedef enum CMPNodeDilateErodeMethod { + CMP_NODE_DILATE_ERODE_STEP = 0, + CMP_NODE_DILATE_ERODE_DISTANCE_THRESHOLD = 1, + CMP_NODE_DILATE_ERODE_DISTANCE = 2, + CMP_NODE_DILATE_ERODE_DISTANCE_FEATHER = 3, +} CMPNodeDilateErodeMethod; enum { CMP_NODE_INPAINT_SIMPLE = 0, @@ -1248,6 +1383,11 @@ typedef struct NodeGeometryVolumeToMesh { uint8_t resolution_mode; } NodeGeometryVolumeToMesh; +typedef struct NodeGeometryMeshToVolume { + /* MeshToVolumeModifierResolutionMode */ + uint8_t resolution_mode; +} NodeGeometryMeshToVolume; + typedef struct NodeGeometrySubdivisionSurface { /* eSubsurfUVSmooth. */ uint8_t uv_smooth; @@ -1450,6 +1590,11 @@ typedef struct NodeGeometryViewer { int8_t data_type; } NodeGeometryViewer; +typedef struct NodeGeometryUVUnwrap { + /* GeometryNodeUVUnwrapMethod. */ + uint8_t method; +} NodeGeometryUVUnwrap; + typedef struct NodeFunctionCompare { /* NodeCompareOperation */ int8_t operation; @@ -1465,6 +1610,17 @@ typedef struct NodeCombSepColor { int8_t mode; } NodeCombSepColor; +typedef struct NodeShaderMix { + /* eNodeSocketDatatype */ + int8_t data_type; + /* NodeShaderMixMode */ + int8_t factor_mode; + int8_t clamp_factor; + int8_t clamp_result; + int8_t blend_type; + char _pad[3]; +} NodeShaderMix; + /* script node mode */ #define NODE_SCRIPT_INTERNAL 0 #define NODE_SCRIPT_EXTERNAL 1 @@ -1752,6 +1908,11 @@ typedef enum NodeBooleanMathOperation { NODE_BOOLEAN_MATH_NIMPLY = 8, } NodeBooleanMathOperation; +typedef enum NodeShaderMixMode { + NODE_MIX_MODE_UNIFORM = 0, + NODE_MIX_MODE_NON_UNIFORM = 1, +} NodeShaderMixMode; + typedef enum NodeCompareMode { NODE_COMPARE_MODE_ELEMENT = 0, NODE_COMPARE_MODE_LENGTH = 1, @@ -1828,6 +1989,76 @@ enum { /* viewer and composite output. */ #define CMP_NODE_OUTPUT_IGNORE_ALPHA 1 +/** Split Viewer Node. Stored in `custom2`. */ +typedef enum CMPNodeSplitViewerAxis { + CMP_NODE_SPLIT_VIEWER_HORIZONTAL = 0, + CMP_NODE_SPLIT_VIEWER_VERTICAL = 1, +} CMPNodeSplitViewerAxis; + +/** Color Balance Node. Stored in `custom1`. */ +typedef enum CMPNodeColorBalanceMethod { + CMP_NODE_COLOR_BALANCE_LGG = 0, + CMP_NODE_COLOR_BALANCE_ASC_CDL = 1, +} CMPNodeColorBalanceMethod; + +/** Alpha Convert Node. Stored in `custom1`. */ +typedef enum CMPNodeAlphaConvertMode { + CMP_NODE_ALPHA_CONVERT_PREMULTIPLY = 0, + CMP_NODE_ALPHA_CONVERT_UNPREMULTIPLY = 1, +} CMPNodeAlphaConvertMode; + +/** Distance Matte Node. Stored in #NodeChroma.channel. */ +typedef enum CMPNodeDistanceMatteColorSpace { + CMP_NODE_DISTANCE_MATTE_COLOR_SPACE_YCCA = 0, + CMP_NODE_DISTANCE_MATTE_COLOR_SPACE_RGBA = 1, +} CMPNodeDistanceMatteColorSpace; + +/** Color Spill Node. Stored in `custom2`. */ +typedef enum CMPNodeColorSpillLimitAlgorithm { + CMP_NODE_COLOR_SPILL_LIMIT_ALGORITHM_SINGLE = 0, + CMP_NODE_COLOR_SPILL_LIMIT_ALGORITHM_AVERAGE = 1, +} CMPNodeColorSpillLimitAlgorithm; + +/** Channel Matte Node. Stored in #NodeChroma.algorithm. */ +typedef enum CMPNodeChannelMatteLimitAlgorithm { + CMP_NODE_CHANNEL_MATTE_LIMIT_ALGORITHM_SINGLE = 0, + CMP_NODE_CHANNEL_MATTE_LIMIT_ALGORITHM_MAX = 1, +} CMPNodeChannelMatteLimitAlgorithm; + +/* Flip Node. Stored in custom1. */ +typedef enum CMPNodeFlipMode { + CMP_NODE_FLIP_X = 0, + CMP_NODE_FLIP_Y = 1, + CMP_NODE_FLIP_X_Y = 2, +} CMPNodeFlipMode; + +/* Scale Node. Stored in custom1. */ +typedef enum CMPNodeScaleMethod { + CMP_NODE_SCALE_RELATIVE = 0, + CMP_NODE_SCALE_ABSOLUTE = 1, + CMP_NODE_SCALE_RENDER_PERCENT = 2, + CMP_NODE_SCALE_RENDER_SIZE = 3, +} CMPNodeScaleMethod; + +/* Scale Node. Stored in custom2. */ +typedef enum CMPNodeScaleRenderSizeMethod { + CMP_NODE_SCALE_RENDER_SIZE_STRETCH = 0, + CMP_NODE_SCALE_RENDER_SIZE_FIT = 1, + CMP_NODE_SCALE_RENDER_SIZE_CROP = 2, +} CMPNodeScaleRenderSizeMethod; + +/* Filter Node. Stored in custom1. */ +typedef enum CMPNodeFilterMethod { + CMP_NODE_FILTER_SOFT = 0, + CMP_NODE_FILTER_SHARP_BOX = 1, + CMP_NODE_FILTER_LAPLACE = 2, + CMP_NODE_FILTER_SOBEL = 3, + CMP_NODE_FILTER_PREWITT = 4, + CMP_NODE_FILTER_KIRSCH = 5, + CMP_NODE_FILTER_SHADOW = 6, + CMP_NODE_FILTER_SHARP_DIAMOND = 7, +} CMPNodeFilterMethod; + /* Plane track deform node. */ enum { @@ -2000,6 +2231,11 @@ typedef enum GeometryNodeMergeByDistanceMode { GEO_NODE_MERGE_BY_DISTANCE_MODE_CONNECTED = 1, } GeometryNodeMergeByDistanceMode; +typedef enum GeometryNodeUVUnwrapMethod { + GEO_NODE_UV_UNWRAP_METHOD_ANGLE_BASED = 0, + GEO_NODE_UV_UNWRAP_METHOD_CONFORMAL = 1, +} GeometryNodeUVUnwrapMethod; + typedef enum GeometryNodeMeshLineMode { GEO_NODE_MESH_LINE_MODE_END_POINTS = 0, GEO_NODE_MESH_LINE_MODE_OFFSET = 1, @@ -2124,7 +2360,3 @@ typedef enum NodeCombSepColorMode { NODE_COMBSEP_COLOR_HSV = 1, NODE_COMBSEP_COLOR_HSL = 2, } NodeCombSepColorMode; - -#ifdef __cplusplus -} -#endif |