32 const bool is_auto_structure_type =
storage.structure_type ==
35 auto &
list =
b.add_input(type,
"List"_ustr).structure_type(StructureType::List).hide_value();
36 b.add_input<
decl::Int>(
"Index"_ustr).
min(0).structure_type(StructureType::Dynamic);
37 b.add_output(type,
"Value"_ustr)
38 .propagate_all({
list.index()})
39 .propagate_references()
40 .structure_type(is_auto_structure_type ? StructureType::Dynamic :
41 StructureType(
storage.structure_type));
59 auto *
storage = MEM_new<NodeGeometryListGetItem>(__func__);
95 "Value may be implicitly converted if the type does not match",
112 "What kind of higher order types are expected to flow through this socket",
128 if (
const auto *
data = std::get_if<GList::ArrayData>(&
list->data())) {
129 if (
list->is_mutable() &&
data->sharing_info->is_mutable()) {
131 list->cpp_type().move_construct(data_span[
index], value_ptr);
135 list->cpp_type().copy_construct(data_span[
index], value_ptr);
138 if (
const auto *
data = std::get_if<GList::SingleData>(&
list->data())) {
139 if (
list->is_mutable() &&
data->sharing_info->is_mutable()) {
140 list->cpp_type().move_construct(
const_cast<void *
>(
data->value), value_ptr);
143 list->cpp_type().copy_construct(
data->value, value_ptr);
152 if (
const auto *
data = std::get_if<GList::ArrayData>(&
list->data())) {
153 if (
list->is_mutable() &&
data->sharing_info->is_mutable()) {
156 return std::move(data_span[
index]);
160 return data_span[
index];
162 if (
const auto *
data = std::get_if<GList::SingleData>(&
list->data())) {
163 if (
list->is_mutable() &&
data->sharing_info->is_mutable()) {
181 const std::optional<eNodeSocketDatatype> socket_type =
185 if (!
index.is_single()) {
190 const int index_int =
index.ensure_type<
int>();
205 std::string error_message;
208 std::make_shared<SampleIndexFunction>(std::move(
list)),
219 params.
set_output(
"Value"_ustr, std::move(output_value));
226 ntype.
ui_name =
"Get List Item";
#define NODE_CLASS_CONVERTER
#define NOD_REGISTER_NODE(REGISTER_FUNC)
#define NOD_storage_enum_accessors(member)
#define BLI_assert_unreachable()
constexpr IndexRange()=default
void * allocate_single(const CPPType &type)
void add_item(std::string socket_name, SocketLinkOperation::LinkSocketFn fn, int weight=0)
const bNodeTree & node_tree() const
const bNodeSocket & other_socket() const
eNodeSocketInOut in_out() const
void error_message_add(const NodeWarningType type, StringRef message) const
T extract_input(const UString identifier)
GeoNodesUserData * user_data() const
void set_default_remaining_outputs()
void set_output(const UString identifier, T &&value)
void update_and_connect_available_socket(bNode &new_node, UString socket_name)
bNode & add_node(UString idname)
eNodeSocketDatatype socket_type
void operator()(LinkSearchOpParams ¶ms)
#define storage(slot, qualifiers)
std::optional< eNodeSocketDatatype > geo_nodes_base_cpp_type_to_socket_type(const CPPType &type)
void node_register_type(bNodeType &ntype)
const CPPType * socket_type_to_geo_nodes_base_cpp_type(eNodeSocketDatatype type)
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))
static void node_layout(ui::Layout &layout, bContext *, PointerRNA *ptr)
NODE_STORAGE_FUNCS(NodeGeometryListGetItem)
static void node_declare(NodeDeclarationBuilder &b)
static void node_init(bNodeTree *, bNode *node)
static void node_geo_exec(GeoNodeExecParams params)
static void node_register()
static bke::SocketValueVariant get_single_item(GListPtr &list, const eNodeSocketDatatype socket_type, const int64_t index)
static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms)
static void node_layout_ex(ui::Layout &layout, bContext *, PointerRNA *ptr)
static void node_rna(StructRNA *srna)
static bke::SocketValueVariant get_socket_value_item(GListPtr &list, const int64_t index)
PropertyRNA * RNA_def_node_enum(StructRNA *srna, const char *identifier, const char *ui_name, const char *ui_description, const EnumPropertyItem *static_items, const EnumRNAAccessors accessors, std::optional< int > default_value, const EnumPropertyItemFunc item_func, const bool allow_animation)
bool execute_multi_function_on_value_variant(const MultiFunction &fn, const std::shared_ptr< MultiFunction > &owned_fn, const Span< SocketValueVariant * > input_values, const Span< SocketValueVariant * > output_values, GeoNodesUserData *user_data, std::string &r_error_message)
bool socket_type_supports_fields(const eNodeSocketDatatype socket_type)
const EnumPropertyItem * enum_items_filter(const EnumPropertyItem *original_item_array, FunctionRef< bool(const EnumPropertyItem &item)> fn)
BMesh const char void * data
const EnumPropertyItem rna_enum_node_socket_structure_type_items[]
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
const EnumPropertyItem rna_enum_node_socket_data_type_items[]
void node_free_standard_storage(bNode *node)
void geo_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
bke::bNodeTreeType * typeinfo
bool(*) valid_socket_type(bNodeTreeType *ntreetype, bNodeSocketType *socket_type)
bool(*) validate_link(eNodeSocketDatatype from, eNodeSocketDatatype to)
void(*) draw_buttons(ui::Layout &, bContext *C, PointerRNA *ptr)
std::string ui_description
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
void use_property_decorate_set(bool is_decorate)
void use_property_split_set(bool is_sep)
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)