29#include <fmt/format.h>
39 b.add_input<
decl::Bundle>(
"Bundle"_ustr).structure_type(StructureType::Single);
49 auto &
decl =
b.add_output(socket_type, name, identifier)
57 decl.structure_type(StructureType::Dynamic);
62 .custom_draw(socket_items::ui::draw_extend_socket_fn<SeparateBundleItemsAccessor>());
67 auto *
storage = MEM_new<NodeSeparateBundle>(__func__);
74 auto *dst_storage = MEM_new<NodeSeparateBundle>(__func__,
dna::shallow_copy(src_storage));
75 dst_node->
storage = dst_storage;
111 layout.
op(
"node.sockets_sync",
IFACE_(
"Sync"), ICON_FILE_REFRESH);
112 layout.
prop(node_ptr,
"define_signature",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
114 socket_items::ui::draw_items_list_with_operators<SeparateBundleItemsAccessor>(
115 C, panel, ntree,
node);
116 socket_items::ui::draw_active_item_props<SeparateBundleItemsAccessor>(
118 panel->use_property_split_set(
true);
119 panel->use_property_decorate_set(
false);
159 fmt::format(fmt::runtime(
TIP_(
"Value not found in bundle: \"{}\"")), name));
162 const auto *socket_value = std::get_if<BundleItemSocketValue>(&value->
value);
166 fmt::format(
"{}: \"{}\"",
TIP_(
"Cannot get internal value from bundle"), name));
171 if (socket_value->type->type != stype->
type) {
173 *socket_value->type, output_value, *stype))
175 output_value = std::move(*converted_value);
179 TIP_(
"Implicit type conversion when separating bundle"),
181 TIP_(socket_value->type->label),
188 TIP_(
"Conversion not supported when separating bundle"),
190 TIP_(socket_value->type->label),
195 lf_params.set_output(i, std::move(output_value));
214 if (!
result.should_compute()) {
229 fmt::format(fmt::runtime(
TIP_(
"Value not found in bundle: \"{}\"")), name));
236 result.share_data(bundle_result);
245 TIP_(
"Conversion not supported when separating bundle"),
265 TIP_(
"Implicit type conversion when separating bundle"),
326 ntype.
ui_name =
"Separate Bundle";
#define NODE_CLASS_CONVERTER
#define NODE_SEPARATE_BUNDLE
#define BLI_SCOPED_DEFER(function_to_defer)
#define BLI_STR_UTF8_BLACK_RIGHT_POINTING_SMALL_TRIANGLE
#define NOD_REGISTER_NODE(REGISTER_FUNC)
constexpr IndexRange()=default
bool is_convertible(const CPPType &from_type, const CPPType &to_type) const
static Result get_result(Context &context, const nodes::BundleItemValue &item_value)
Result create_result(ResultType type, ResultPrecision precision)
NodeOperation(Context &context, const bNode &node)
void add_warning(nodes::NodeWarningType type, std::string message)
const bNode & node() const
Result & get_result(StringRef identifier)
void allocate_default_remaining_outputs()
Context & context() const
Result & get_input(StringRef identifier) const
void share_data(const Result &source)
const CPPType & get_cpp_type() const
static const char * type_name(const ResultType type)
static ResultType type(gpu::TextureFormat format)
static ResultPrecision precision(gpu::TextureFormat format)
const T & get_single_value() const
void map_input_to_result(Result *result)
static std::optional< BundleKey > from_str(StringRef key)
const BundleItemValue * lookup(BundleKey key) const
void add_item(std::string socket_name, SocketLinkOperation::LinkSocketFn fn, int weight=0)
const bNodeTree & node_tree() const
const bNodeSocket & other_socket() const
void error_message_add(const NodeWarningType type, StringRef message) const
T extract_input(const UString identifier)
const bNode & node() const
void set_default_remaining_outputs()
lf::Params & low_level_lazy_function_params()
void update_and_connect_available_socket(bNode &new_node, UString socket_name)
bNode & add_node(UString idname)
void connect_available_socket(bNode &new_node, UString socket_name)
NodeOperation(Context &context, const bNode &node)
#define storage(slot, qualifiers)
const DataTypeConversions & get_implicit_type_conversions()
void node_register_type(bNodeType &ntype)
bNodeSocketType * node_socket_type_find_static(int type, int subtype=0)
void node_type_storage(bNodeType &ntype, std::optional< StringRefNull > storagename, void(*freefunc)(bNode *node), void(*copyfunc)(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node))
internal::ShallowDataConstRef< T > shallow_copy(const T &other)
static void node_declare(NodeDeclarationBuilder &b)
NODE_STORAGE_FUNCS(NodeSeparateBundle)
static void node_geo_exec(GeoNodeExecParams params)
static void node_free_storage(bNode *node)
static void node_blend_write(const bNodeTree &, const bNode &node, BlendWriter &writer)
static void node_operators()
static NodeOperation * get_compositor_operation(Context &context, const bNode &node)
static bool node_insert_link(bke::NodeInsertLinkParams ¶ms)
static void node_layout_ex(ui::Layout &layout, bContext *C, PointerRNA *node_ptr)
static void node_register()
static void node_init(bNodeTree *, bNode *node)
static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms)
static void node_copy_storage(bNodeTree *, bNode *dst_node, const bNode *src_node)
static void node_blend_read(bNodeTree &, bNode &node, BlendDataReader &reader)
void make_common_operators()
void blend_write(BlendWriter *writer, const bNode &node)
void destruct_array(bNode &node)
void blend_read_data(BlendDataReader *reader, bNode &node)
void copy_array(const bNode &src_node, bNode &dst_node)
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)
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)
void sync_sockets_separate_bundle(SpaceNode &snode, bNode &separate_bundle_node, ReportList *reports, const bNodeSocket *src_bundle_socket)
std::optional< SocketValueVariant > implicitly_convert_socket_value(const bke::bNodeSocketType &from_type, const SocketValueVariant &from_value, const bke::bNodeSocketType &to_type)
ImplicitSharingPtr< Bundle > BundlePtr
SpaceNode * CTX_wm_space_node(const bContext *C)
void BLO_read_string(BlendDataReader *reader, char **ptr_p)
void common_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
void write_string(const char *data)
eNodeSocketDatatype socket_type
NodeSocketInterfaceStructureType structure_type
struct bNodeTree * edittree
bke::bNodeSocketType * typeinfo
const SocketValueVariant * geometry_nodes_default_value
NodeBlendWriteFunction blend_write_storage_content
void(*) register_operators()
std::string ui_description
NodeBlendDataReadFunction blend_data_read_storage_content
NodeGetCompositorOperationFunction get_compositor_operation
NodeGeometryExecFunction geometry_node_execute
void(*) draw_buttons_ex(ui::Layout &, bContext *C, PointerRNA *ptr)
void(*) initfunc(bNodeTree *ntree, bNode *node)
NodeGatherSocketLinkOperationsFunction gather_link_search_ops
NodeDeclareFunction declare
bool(*) insert_link(NodeInsertLinkParams ¶ms)
std::variant< BundleItemSocketValue, BundleItemInternalValue > value
static bool supports_socket_type(const eNodeSocketDatatype socket_type, const int ntree_type)
NodeSeparateBundleItem ItemT
static void blend_write_item(BlendWriter *writer, const ItemT &item)
static void blend_read_data_item(BlendDataReader *reader, ItemT &item)
static std::string socket_identifier_for_item(const ItemT &item)
static StructRNA ** item_srna
void use_property_decorate_set(bool is_decorate)
void use_property_split_set(bool is_sep)
PointerRNA op(wmOperatorType *ot, std::optional< StringRef > name, int icon, wm::OpCallContext context, eUI_Item_Flag flag)
PanelLayout panel(const bContext *C, StringRef idname, bool default_closed)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)