Blender V4.5
blender::nodes::socket_items Namespace Reference

Namespaces

namespace  detail
namespace  ops
namespace  ui

Classes

struct  SocketItemsAccessorDefaults
struct  SocketItemsRef

Functions

template<typename Accessor>
bNodefind_node_by_item (bNodeTree &ntree, const typename Accessor::ItemT &item)
template<typename Accessor>
void destruct_array (bNode &node)
template<typename Accessor>
void clear (bNode &node)
template<typename Accessor>
void copy_array (const bNode &src_node, bNode &dst_node)
template<typename Accessor>
std::string get_validated_name (const StringRef name)
template<typename Accessor>
void set_item_name_and_make_unique (bNode &node, typename Accessor::ItemT &item, const char *value)
template<typename Accessor>
Accessor::ItemT * add_item_with_socket_type_and_name (bNode &node, const eNodeSocketDatatype socket_type, const char *name)
template<typename Accessor>
Accessor::ItemT * add_item_with_name (bNode &node, const char *name)
template<typename Accessor>
Accessor::ItemT * add_item (bNode &node)
template<typename Accessor>
std::string get_socket_identifier (const typename Accessor::ItemT &item, const eNodeSocketInOut in_out)
template<typename Accessor>
bool try_add_item_via_extend_socket (bNodeTree &ntree, bNode &extend_node, bNodeSocket &extend_socket, bNode &storage_node, bNodeLink &link)
template<typename Accessor>
bool try_add_item_via_any_extend_socket (bNodeTree &ntree, bNode &extend_node, bNode &storage_node, bNodeLink &link, const std::optional< StringRef > socket_identifier=std::nullopt)
template<typename Accessor>
void blend_write (BlendWriter *writer, const bNode &node)
template<typename Accessor>
void blend_read_data (BlendDataReader *reader, bNode &node)

Detailed Description

Some nodes have a dynamic number of sockets (e.g. simulation input/output). These nodes store an array of items in their bNode->storage (e.g. NodeSimulationItem). Different nodes have slightly different storage requirements, but a lot of the logic is still the same between nodes. This file implements various shared functionality that can be used by different nodes to deal with these item arrays.

In order to use the functions, one has to implement an "accessor" which tells the shared code how to deal with specific item arrays. Different functions have different requirements for the accessor. It's easiest to just look at existing accessors like SimulationItemsAccessor and RepeatItemsAccessor and to implement the same methods.

Function Documentation

◆ add_item()

template<typename Accessor>
Accessor::ItemT * blender::nodes::socket_items::add_item ( bNode & node)
inline

◆ add_item_with_name()

template<typename Accessor>
Accessor::ItemT * blender::nodes::socket_items::add_item_with_name ( bNode & node,
const char * name )
inline

◆ add_item_with_socket_type_and_name()

◆ blend_read_data()

◆ blend_write()

◆ clear()

◆ copy_array()

◆ destruct_array()

◆ find_node_by_item()

template<typename Accessor>
bNode * blender::nodes::socket_items::find_node_by_item ( bNodeTree & ntree,
const typename Accessor::ItemT & item )
inline

Iterates over the node tree to find the node that this item belongs to.

Definition at line 53 of file NOD_socket_items.hh.

◆ get_socket_identifier()

template<typename Accessor>
std::string blender::nodes::socket_items::get_socket_identifier ( const typename Accessor::ItemT & item,
const eNodeSocketInOut in_out )
inline

Definition at line 228 of file NOD_socket_items.hh.

References SOCK_IN.

Referenced by try_add_item_via_extend_socket().

◆ get_validated_name()

template<typename Accessor>
std::string blender::nodes::socket_items::get_validated_name ( const StringRef name)
inline

Enforce constraints on the name of the item.

Definition at line 108 of file NOD_socket_items.hh.

Referenced by set_item_name_and_make_unique().

◆ set_item_name_and_make_unique()

template<typename Accessor>
void blender::nodes::socket_items::set_item_name_and_make_unique ( bNode & node,
typename Accessor::ItemT & item,
const char * value )
inline

Changes the name of an existing item and makes sure that the name is unique among other the other items in the same array.

Definition at line 123 of file NOD_socket_items.hh.

References ARRAY_SIZE, BLI_assert, BLI_strdup(), BLI_uniquename_cb(), blender::StringRefNull::c_str(), get_validated_name(), MAX_NAME, MEM_SAFE_FREE, blender::bke::node_static_socket_label(), STRNCPY(), and unique_name().

Referenced by blender::nodes::MenuSwitchItemsAccessor::init_with_name(), blender::nodes::BakeItemsAccessor::init_with_socket_type_and_name(), blender::nodes::CaptureAttributeItemsAccessor::init_with_socket_type_and_name(), blender::nodes::ClosureInputItemsAccessor::init_with_socket_type_and_name(), blender::nodes::ClosureOutputItemsAccessor::init_with_socket_type_and_name(), blender::nodes::CombineBundleItemsAccessor::init_with_socket_type_and_name(), blender::nodes::EvaluateClosureInputItemsAccessor::init_with_socket_type_and_name(), blender::nodes::EvaluateClosureOutputItemsAccessor::init_with_socket_type_and_name(), blender::nodes::ForeachGeometryElementGenerationItemsAccessor::init_with_socket_type_and_name(), blender::nodes::ForeachGeometryElementInputItemsAccessor::init_with_socket_type_and_name(), blender::nodes::ForeachGeometryElementMainItemsAccessor::init_with_socket_type_and_name(), blender::nodes::FormatStringItemsAccessor::init_with_socket_type_and_name(), blender::nodes::RepeatItemsAccessor::init_with_socket_type_and_name(), blender::nodes::SeparateBundleItemsAccessor::init_with_socket_type_and_name(), and blender::nodes::SimulationItemsAccessor::init_with_socket_type_and_name().

◆ try_add_item_via_any_extend_socket()

template<typename Accessor>
bool blender::nodes::socket_items::try_add_item_via_any_extend_socket ( bNodeTree & ntree,
bNode & extend_node,
bNode & storage_node,
bNodeLink & link,
const std::optional< StringRef > socket_identifier = std::nullopt )
inlinenodiscard

◆ try_add_item_via_extend_socket()

template<typename Accessor>
bool blender::nodes::socket_items::try_add_item_via_extend_socket ( bNodeTree & ntree,
bNode & extend_node,
bNodeSocket & extend_socket,
bNode & storage_node,
bNodeLink & link )
inlinenodiscard

Check if the link connects to the extend_socket. If yes, create a new item for the linked socket, update the node and then change the link to point to the new socket.

Returns
False if the link should be removed.

Definition at line 248 of file NOD_socket_items.hh.

References add_item(), add_item_with_name(), add_item_with_socket_type_and_name(), bNodeLink::fromsock, get_socket_identifier(), bNodeSocket::name, blender::bke::node_find_socket(), SOCK_IN, SOCK_OUT, bNodeLink::tosock, bNodeSocket::type, and blender::nodes::update_node_declaration_and_sockets().

Referenced by try_add_item_via_any_extend_socket().