Blender V5.3
blender::nodes::socket_items Namespace Reference

Namespaces

namespace  detail
namespace  ops
namespace  ui

Classes

struct  SocketItemsAccessorDefaults
struct  SocketItemsRef

Functions

std::string variable_name_find_short (StringRef src_name, FunctionRef< bool(StringRef)> exists_fn)
std::string variable_name_validate (StringRef name)
template<typename Accessor>
bNode * find_node_by_item (bNodeTree &ntree, const typename Accessor::ItemT &item)
template<typename Accessor>
Accessor::ItemT * find_item_by_identifier (bNode &node, const StringRef identifier)
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 (bNodeTree &ntree, bNode &node, const eNodeSocketDatatype socket_type, const char *name, std::optional< int > dimensions=std::nullopt)
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)
std::optional< eNodeSocketDatatype > get_socket_item_type_to_add (const eNodeSocketDatatype linked_type, const FunctionRef< bool(eNodeSocketDatatype type)> is_supported)
template<typename Accessor>
bool try_add_item_via_extend_socket (bNodeTree &ntree, bNode &extend_node, bNodeSocket &extend_socket, bNode &storage_node, bNodeLink &link, typename Accessor::ItemT **r_new_item=nullptr)
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, typename Accessor::ItemT **r_new_item=nullptr)
template<typename Accessor>
void blend_write (BlendWriter *writer, const bNode &node)
template<typename Accessor>
void blend_read_data (BlendDataReader *reader, bNode &node)
template<typename Accessor>
std::string variable_name_find_short (const bNode &node, const StringRef src_name)

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()

template<typename Accessor>
Accessor::ItemT * blender::nodes::socket_items::add_item_with_socket_type_and_name ( bNodeTree & ntree,
bNode & node,
const eNodeSocketDatatype socket_type,
const char * name,
std::optional< int > dimensions = std::nullopt )
inline

Add a new item at the end with the given socket type and name. The optional dimensions argument can be provided for types that support multiple possible dimensions like Vector. It is expected to be in the range [2, 4] and if not provided, 3 should be assumed.

Definition at line 225 of file NOD_socket_items.hh.

References blender::nodes::socket_items::detail::add_item_to_array(), add_item_with_socket_type_and_name(), blender::BLI_assert(), ELEM, node, blender::SOCK_VECTOR, blender::bNodeTree::type, and UNUSED_VARS_NDEBUG.

Referenced by blender::nodes::socket_items::ops::add_item(), add_item_with_socket_type_and_name(), blender::ed::space_node::viewer_linking::ensure_geometry_nodes_viewer_has_non_geometry_socket(), blender::ed::space_node::viewer_linking::ensure_geometry_nodes_viewer_starts_with_geometry_socket(), blender::nodes::node_geo_closure_to_list_cc::node_gather_link_search_ops(), blender::nodes::node_geo_field_to_grid_cc::node_gather_link_search_ops(), blender::nodes::node_geo_field_to_list_cc::node_gather_link_search_ops(), blender::nodes::node_composite_file_output_cc::node_gather_link_searches(), blender::nodes::node_geo_attribute_capture_cc::node_gather_link_searches(), blender::nodes::node_geo_bake_cc::node_gather_link_searches(), blender::nodes::node_geo_combine_bundle_cc::node_gather_link_searches(), blender::nodes::node_geo_evaluate_closure_cc::node_gather_link_searches(), blender::nodes::node_geo_repeat_cc::repeat_output_node::node_gather_link_searches(), blender::nodes::node_geo_separate_bundle_cc::node_gather_link_searches(), blender::nodes::node_geo_simulation_cc::sim_output_node::node_gather_link_searches(), blender::nodes::node_geo_viewer_cc::node_gather_link_searches(), blender::nodes::sync_sockets_closure(), blender::nodes::sync_sockets_closure_to_list(), blender::nodes::sync_sockets_combine_bundle(), blender::nodes::sync_sockets_evaluate_closure(), blender::nodes::sync_sockets_separate_bundle(), and try_add_item_via_extend_socket().

◆ blend_read_data()

template<typename Accessor>
void blender::nodes::socket_items::blend_read_data ( BlendDataReader * reader,
bNode & node )
inline

Definition at line 28 of file NOD_socket_items_blend.hh.

References blend_read_data(), blender::BLO_read_array_and_validate_size(), blender::nodes::socket_items::SocketItemsRef< T >::items, blender::nodes::socket_items::SocketItemsRef< T >::items_num, blender::MutableSpan< T >::MutableSpan(), and node.

Referenced by blend_read_data(), blender::nodes::node_composite_file_output_cc::node_blend_read(), blender::nodes::node_fn_format_string_cc::node_blend_read(), blender::nodes::node_geo_attribute_capture_cc::node_blend_read(), blender::nodes::node_geo_bake_cc::node_blend_read(), blender::nodes::node_geo_closure_cc::output_node::node_blend_read(), blender::nodes::node_geo_closure_to_list_cc::node_blend_read(), blender::nodes::node_geo_combine_bundle_cc::node_blend_read(), blender::nodes::node_geo_combine_list_cc::node_blend_read(), blender::nodes::node_geo_evaluate_closure_cc::node_blend_read(), blender::nodes::node_geo_field_to_grid_cc::node_blend_read(), blender::nodes::node_geo_field_to_list_cc::node_blend_read(), blender::nodes::node_geo_foreach_geometry_element_cc::output_node::node_blend_read(), blender::nodes::node_geo_index_switch_cc::node_blend_read(), blender::nodes::node_geo_menu_switch_cc::node_blend_read(), blender::nodes::node_geo_rasterize_points::node_blend_read(), blender::nodes::node_geo_repeat_cc::repeat_output_node::node_blend_read(), blender::nodes::node_geo_separate_bundle_cc::node_blend_read(), blender::nodes::node_geo_simulation_cc::sim_output_node::node_blend_read(), blender::nodes::node_geo_viewer_cc::node_blend_read(), and blender::nodes::node_shader_raycast_cc::node_blend_read().

◆ blend_write()

template<typename Accessor>
void blender::nodes::socket_items::blend_write ( BlendWriter * writer,
const bNode & node )
inline

Definition at line 17 of file NOD_socket_items_blend.hh.

References blend_write(), blender::nodes::socket_items::SocketItemsRef< T >::items, blender::nodes::socket_items::SocketItemsRef< T >::items_num, node, blender::dna::sdna_struct_id_get(), blender::Span< T >::Span(), and blender::BlendWriter::write_struct_array_by_id().

Referenced by blend_write(), blender::nodes::node_composite_file_output_cc::node_blend_write(), blender::nodes::node_fn_format_string_cc::node_blend_write(), blender::nodes::node_geo_attribute_capture_cc::node_blend_write(), blender::nodes::node_geo_bake_cc::node_blend_write(), blender::nodes::node_geo_closure_cc::output_node::node_blend_write(), blender::nodes::node_geo_closure_to_list_cc::node_blend_write(), blender::nodes::node_geo_combine_bundle_cc::node_blend_write(), blender::nodes::node_geo_combine_list_cc::node_blend_write(), blender::nodes::node_geo_evaluate_closure_cc::node_blend_write(), blender::nodes::node_geo_field_to_grid_cc::node_blend_write(), blender::nodes::node_geo_field_to_list_cc::node_blend_write(), blender::nodes::node_geo_foreach_geometry_element_cc::output_node::node_blend_write(), blender::nodes::node_geo_index_switch_cc::node_blend_write(), blender::nodes::node_geo_menu_switch_cc::node_blend_write(), blender::nodes::node_geo_rasterize_points::node_blend_write(), blender::nodes::node_geo_repeat_cc::repeat_output_node::node_blend_write(), blender::nodes::node_geo_separate_bundle_cc::node_blend_write(), blender::nodes::node_geo_simulation_cc::sim_output_node::node_blend_write(), blender::nodes::node_geo_viewer_cc::node_blend_write(), and blender::nodes::node_shader_raycast_cc::node_blend_write().

◆ clear()

◆ copy_array()

template<typename Accessor>
void blender::nodes::socket_items::copy_array ( const bNode & src_node,
bNode & dst_node )
inline

Copy the items from the storage of the source node to the storage of the destination node.

Definition at line 119 of file NOD_socket_items.hh.

References copy_array(), blender::IndexRange::IndexRange(), blender::nodes::socket_items::SocketItemsRef< T >::items, and blender::nodes::socket_items::SocketItemsRef< T >::items_num.

Referenced by copy_array(), blender::nodes::node_composite_file_output_cc::node_copy_storage(), blender::nodes::node_fn_format_string_cc::node_copy_storage(), blender::nodes::node_geo_attribute_capture_cc::node_copy_storage(), blender::nodes::node_geo_bake_cc::node_copy_storage(), blender::nodes::node_geo_closure_cc::output_node::node_copy_storage(), blender::nodes::node_geo_closure_to_list_cc::node_copy_storage(), blender::nodes::node_geo_combine_bundle_cc::node_copy_storage(), blender::nodes::node_geo_combine_list_cc::node_copy_storage(), blender::nodes::node_geo_evaluate_closure_cc::node_copy_storage(), blender::nodes::node_geo_field_to_grid_cc::node_copy_storage(), blender::nodes::node_geo_field_to_list_cc::node_copy_storage(), blender::nodes::node_geo_foreach_geometry_element_cc::output_node::node_copy_storage(), blender::nodes::node_geo_index_switch_cc::node_copy_storage(), blender::nodes::node_geo_menu_switch_cc::node_copy_storage(), blender::nodes::node_geo_rasterize_points::node_copy_storage(), blender::nodes::node_geo_repeat_cc::repeat_output_node::node_copy_storage(), blender::nodes::node_geo_separate_bundle_cc::node_copy_storage(), blender::nodes::node_geo_simulation_cc::sim_output_node::node_copy_storage(), blender::nodes::node_geo_viewer_cc::node_copy_storage(), and blender::nodes::node_shader_raycast_cc::node_copy_storage().

◆ destruct_array()

template<typename Accessor>
void blender::nodes::socket_items::destruct_array ( bNode & node)
inline

Destruct all the items and the free the array itself.

Definition at line 92 of file NOD_socket_items.hh.

References destruct_array(), blender::IndexRange::IndexRange(), blender::nodes::socket_items::SocketItemsRef< T >::items, blender::nodes::socket_items::SocketItemsRef< T >::items_num, and node.

Referenced by clear(), destruct_array(), blender::nodes::node_composite_file_output_cc::node_free_storage(), blender::nodes::node_fn_format_string_cc::node_free_storage(), blender::nodes::node_geo_attribute_capture_cc::node_free_storage(), blender::nodes::node_geo_bake_cc::node_free_storage(), blender::nodes::node_geo_closure_cc::output_node::node_free_storage(), blender::nodes::node_geo_closure_to_list_cc::node_free_storage(), blender::nodes::node_geo_combine_bundle_cc::node_free_storage(), blender::nodes::node_geo_combine_list_cc::node_free_storage(), blender::nodes::node_geo_evaluate_closure_cc::node_free_storage(), blender::nodes::node_geo_field_to_grid_cc::node_free_storage(), blender::nodes::node_geo_field_to_list_cc::node_free_storage(), blender::nodes::node_geo_foreach_geometry_element_cc::output_node::node_free_storage(), blender::nodes::node_geo_index_switch_cc::node_free_storage(), blender::nodes::node_geo_menu_switch_cc::node_free_storage(), blender::nodes::node_geo_rasterize_points::node_free_storage(), blender::nodes::node_geo_repeat_cc::repeat_output_node::node_free_storage(), blender::nodes::node_geo_separate_bundle_cc::node_free_storage(), blender::nodes::node_geo_simulation_cc::sim_output_node::node_free_storage(), blender::nodes::node_geo_viewer_cc::node_free_storage(), and blender::nodes::node_shader_raycast_cc::node_free_storage().

◆ find_item_by_identifier()

template<typename Accessor>
Accessor::ItemT * blender::nodes::socket_items::find_item_by_identifier ( bNode & node,
const StringRef identifier )
inline

Find the item with the given identifier.

Definition at line 76 of file NOD_socket_items.hh.

References find_item_by_identifier(), blender::IndexRange::IndexRange(), and node.

Referenced by blender::ed::space_node::viewer_linking::finalize_viewer_link(), and find_item_by_identifier().

◆ 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 62 of file NOD_socket_items.hh.

References find_node_by_item(), and node.

Referenced by find_node_by_item().

◆ 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

◆ get_socket_item_type_to_add()

std::optional< eNodeSocketDatatype > blender::nodes::socket_items::get_socket_item_type_to_add ( const eNodeSocketDatatype linked_type,
const FunctionRef< bool(eNodeSocketDatatype type)> is_supported )
inline

◆ 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 134 of file NOD_socket_items.hh.

References get_validated_name().

Referenced by get_validated_name(), and 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 149 of file NOD_socket_items.hh.

References blender::BLI_assert(), blender::BLI_strdup(), blender::BLI_uniquename_cb(), get_validated_name(), blender::MutableSpan< T >::MutableSpan(), node, blender::bke::node_static_socket_label(), and set_item_name_and_make_unique().

Referenced by blender::nodes::MenuSwitchItemsAccessor::init_with_name(), blender::nodes::RasterizePointsItemsAccessor::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::ClosureToListItemsAccessor::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::FieldToGridItemsAccessor::init_with_socket_type_and_name(), blender::nodes::FieldToListItemsAccessor::init_with_socket_type_and_name(), blender::nodes::FileOutputItemsAccessor::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::GeoViewerItemsAccessor::init_with_socket_type_and_name(), blender::nodes::RaycastSampleAttributeItemsAccessor::init_with_socket_type_and_name(), blender::nodes::RepeatItemsAccessor::init_with_socket_type_and_name(), blender::nodes::SeparateBundleItemsAccessor::init_with_socket_type_and_name(), blender::nodes::SimulationItemsAccessor::init_with_socket_type_and_name(), blender::ed::space_node::viewer_linking::node_link_viewer_get_socket(), and set_item_name_and_make_unique().

◆ 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,
typename Accessor::ItemT ** r_new_item = nullptr )
inlinenodiscard

Allow the item array to be extended from any extend-socket in the node.

Returns
False if the link should be removed.

Definition at line 389 of file NOD_socket_items.hh.

References blender::bNodeLink::fromnode, blender::bNodeLink::fromsock, blender::bNodeSocket::identifier, blender::bNodeSocket::idname, STREQ, blender::bNodeLink::tonode, blender::bNodeLink::tosock, try_add_item_via_any_extend_socket(), and try_add_item_via_extend_socket().

Referenced by blender::nodes::node_composite_file_output_cc::node_insert_link(), blender::nodes::node_fn_format_string_cc::node_insert_link(), blender::nodes::node_geo_attribute_capture_cc::node_insert_link(), blender::nodes::node_geo_bake_cc::node_insert_link(), blender::nodes::node_geo_closure_cc::input_node::node_insert_link(), blender::nodes::node_geo_closure_cc::output_node::node_insert_link(), blender::nodes::node_geo_closure_to_list_cc::node_insert_link(), blender::nodes::node_geo_combine_bundle_cc::node_insert_link(), blender::nodes::node_geo_combine_list_cc::node_insert_link(), blender::nodes::node_geo_evaluate_closure_cc::node_insert_link(), blender::nodes::node_geo_field_to_grid_cc::node_insert_link(), blender::nodes::node_geo_field_to_list_cc::node_insert_link(), blender::nodes::node_geo_foreach_geometry_element_cc::input_node::node_insert_link(), blender::nodes::node_geo_foreach_geometry_element_cc::output_node::node_insert_link(), blender::nodes::node_geo_index_switch_cc::node_insert_link(), blender::nodes::node_geo_menu_switch_cc::node_insert_link(), blender::nodes::node_geo_rasterize_points::node_insert_link(), blender::nodes::node_geo_repeat_cc::repeat_input_node::node_insert_link(), blender::nodes::node_geo_repeat_cc::repeat_output_node::node_insert_link(), blender::nodes::node_geo_separate_bundle_cc::node_insert_link(), blender::nodes::node_geo_simulation_cc::sim_input_node::node_insert_link(), blender::nodes::node_geo_simulation_cc::sim_output_node::node_insert_link(), blender::nodes::node_geo_viewer_cc::node_insert_link(), blender::nodes::node_shader_raycast_cc::node_insert_link(), and try_add_item_via_any_extend_socket().

◆ 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,
typename Accessor::ItemT ** r_new_item = nullptr )
inlinenodiscard

◆ variable_name_find_short() [1/2]

template<typename Accessor>
std::string blender::nodes::socket_items::variable_name_find_short ( const bNode & node,
const StringRef src_name )
inline

◆ variable_name_find_short() [2/2]

◆ variable_name_validate()

std::string blender::nodes::socket_items::variable_name_validate ( StringRef name)