diff options
Diffstat (limited to 'source/blender/makesdna/DNA_node_types.h')
-rw-r--r-- | source/blender/makesdna/DNA_node_types.h | 304 |
1 files changed, 266 insertions, 38 deletions
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index 76d8207eead..06e14c3134b 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,12 @@ typedef struct bNodeLink { int flag; int multi_input_socket_index; + +#ifdef __cplusplus + bool is_muted() const; + bool is_available() const; +#endif + } bNodeLink; /* link->flag */ @@ -453,6 +539,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 +624,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_available_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_available_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 +768,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, @@ -857,7 +993,7 @@ typedef struct NodeGlare { char _pad1[4]; } NodeGlare; -/** Tonemap node. */ +/** Tone-map node. */ typedef struct NodeTonemap { float key, offset, gamma; float f, m, a, c; @@ -1460,6 +1596,11 @@ typedef struct NodeGeometryUVUnwrap { uint8_t method; } NodeGeometryUVUnwrap; +typedef struct NodeGeometryDistributePointsInVolume { + /* GeometryNodePointDistributeVolumeMode. */ + uint8_t mode; +} NodeGeometryDistributePointsInVolume; + typedef struct NodeFunctionCompare { /* NodeCompareOperation */ int8_t operation; @@ -1475,6 +1616,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 @@ -1762,6 +1914,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, @@ -1838,6 +1995,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 { @@ -1955,6 +2182,11 @@ typedef enum GeometryNodeTriangulateQuads { GEO_NODE_TRIANGULATE_QUAD_LONGEDGE = 4, } GeometryNodeTriangulateQuads; +typedef enum GeometryNodeDistributePointsInVolumeMode { + GEO_NODE_DISTRIBUTE_POINTS_IN_VOLUME_DENSITY_RANDOM = 0, + GEO_NODE_DISTRIBUTE_POINTS_IN_VOLUME_DENSITY_GRID = 1, +} GeometryNodeDistributePointsInVolumeMode; + typedef enum GeometryNodeDistributePointsOnFacesMode { GEO_NODE_POINT_DISTRIBUTE_POINTS_ON_FACES_RANDOM = 0, GEO_NODE_POINT_DISTRIBUTE_POINTS_ON_FACES_POISSON = 1, @@ -2139,7 +2371,3 @@ typedef enum NodeCombSepColorMode { NODE_COMBSEP_COLOR_HSV = 1, NODE_COMBSEP_COLOR_HSL = 2, } NodeCombSepColorMode; - -#ifdef __cplusplus -} -#endif |