29 .description(
"Geometry to sample a value on");
30 if (
node !=
nullptr) {
32 b.add_input(data_type,
"Value"_ustr).hide_value().evaluated_geometry_field();
35 .description(
"Which element to retrieve a value from on the geometry")
38 if (
node !=
nullptr) {
40 std::array<int, 1> dynamic_inputs = {
index.index()};
41 b.add_output(data_type,
"Value"_ustr)
42 .inferred_structure_type(dynamic_inputs)
43 .propagate_references(dynamic_inputs);
74 node_storage(
node).data_type = *type;
85 const bool use_clamp = bool(
storage.clamp);
97 if (index_value_variant.is_single()) {
101 int index = index_value_variant.extract<
int>();
103 index = std::clamp(
index, 0, domain_size - 1);
113 evaluator.
add(value_field);
116 data.get_to_uninitialized(
index, buffer);
119 cpp_type.copy_construct(cpp_type.default_value(), buffer);
121 params.
set_output(
"Value"_ustr, std::move(output_value));
125 std::string error_message;
129 static auto clamp_fn = mf::build::SI3_SO<int, int, int, int>(
131 [](
int value,
int min,
int max) {
return std::clamp(value,
min,
max); },
132 mf::build::exec_presets::SomeSpanOrSingle<0>());
138 {&index_value_variant_copy, &min_value, &max_value},
139 {&index_value_variant},
151 std::make_shared<bke::SampleIndexFunction>(
152 std::move(
geometry), std::move(value_field), domain),
153 {&index_value_variant},
163 params.
set_output(
"Value"_ustr, std::move(output_value));
171 ntype.
ui_name =
"Sample Index";
172 ntype.
ui_description =
"Retrieve values from specific geometry elements";
#define NODE_CLASS_GEOMETRY
#define GEO_NODE_SAMPLE_INDEX
#define NOD_REGISTER_NODE(REGISTER_FUNC)
constexpr IndexRange()=default
int attribute_domain_size(AttrDomain domain) const
static const GeometryComponent * find_source_component(const GeometrySet &geometry, AttrDomain domain)
void * allocate_single(const CPPType &type)
static SocketValueVariant from(T &&value)
int add(GField field, GVArray *varray_ptr)
const GVArray & get_evaluated(const int field_index) const
const CPPType & cpp_type() const
const bke::bNodeType & node_type() const
void add_item(std::string socket_name, SocketLinkOperation::LinkSocketFn fn, int weight=0)
const bNodeSocket & other_socket() const
void error_message_add(const NodeWarningType type, StringRef message) const
T extract_input(const UString identifier)
GeoNodesUserData * user_data() const
const bNode & node() 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)
Vector< SocketDeclaration * > inputs
StructureType structure_type
#define storage(slot, qualifiers)
void node_register_type(bNodeType &ntype)
const CPPType * socket_type_to_geo_nodes_base_cpp_type(eNodeSocketDatatype type)
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))
std::optional< eCustomDataType > socket_type_to_custom_data_type(eNodeSocketDatatype type)
static void node_geo_exec(GeoNodeExecParams params)
static void node_declare(NodeDeclarationBuilder &b)
NODE_STORAGE_FUNCS(NodeGeometrySampleIndex)
static void node_register()
static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms)
static void node_layout(ui::Layout &layout, bContext *, PointerRNA *ptr)
static void node_init(bNodeTree *, bNode *node)
void search_link_ops_for_declarations(GatherLinkSearchOpParams ¶ms, Span< SocketDeclaration * > declarations)
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)
BMesh const char void * data
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
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::bNodeType * typeinfo
void(*) draw_buttons(ui::Layout &, bContext *C, PointerRNA *ptr)
std::string ui_description
NodeGeometryExecFunction geometry_node_execute
void(*) initfunc(bNodeTree *ntree, bNode *node)
const char * enum_name_legacy
NodeGatherSocketLinkOperationsFunction gather_link_search_ops
NodeDeclareFunction declare
nodes::NodeDeclaration * static_declaration
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)