32 b.add_input(data_type,
"Grid"_ustr).hide_value().structure_type(StructureType::Grid);
33 auto &
x =
b.add_input<
decl::Int>(
"X"_ustr).structure_type(StructureType::Dynamic);
34 auto &
y =
b.add_input<
decl::Int>(
"Y"_ustr).structure_type(StructureType::Dynamic);
35 auto &
z =
b.add_input<
decl::Int>(
"Z"_ustr).structure_type(StructureType::Dynamic);
37 const std::array<int, 3> dynamic_inputs = {
x.index(),
y.index(),
z.index()};
38 b.add_output(data_type,
"Value"_ustr)
39 .propagate_references(dynamic_inputs)
40 .inferred_structure_type(dynamic_inputs);
45 switch (socket.
type) {
70 node.custom1 = *node_type;
92 node.custom1 = *node_type;
105class SampleGridIndexFunction :
public mf::MultiFunction {
106 bke::GVolumeGrid grid_;
107 mf::Signature signature_;
110 bke::VolumeTreeAccessToken tree_token_;
111 const openvdb::GridBase *grid_base_ =
nullptr;
114 SampleGridIndexFunction(bke::GVolumeGrid grid) : grid_(std::move(grid))
121 mf::SignatureBuilder builder{
"Sample Grid Index", signature_};
122 builder.single_input<
int>(
"X");
123 builder.single_input<
int>(
"Y");
124 builder.single_input<
int>(
"Z");
125 builder.single_output(
"Value", *cpp_type);
126 this->set_signature(&signature_);
128 grid_base_ = &grid_->grid(tree_token_);
129 grid_type_ = grid_->grid_type();
132 void call(
const IndexMask &
mask, mf::Params params, mf::Context )
const final
134 const VArraySpan<int>
x = params.readonly_single_input<
int>(0,
"X");
135 const VArraySpan<int>
y = params.readonly_single_input<
int>(1,
"Y");
136 const VArraySpan<int>
z = params.readonly_single_input<
int>(2,
"Z");
137 GMutableSpan dst = params.uninitialized_single_output(3,
"Value");
139 bke::volume_grid::sample_tree_indices(grid_type_, grid_base_->baseTree(),
x,
y,
z,
mask, dst);
148 bke::GVolumeGrid grid = params.
extract_input<bke::GVolumeGrid>(
"Grid"_ustr);
158 std::string error_message;
161 std::make_shared<SampleGridIndexFunction>(std::move(grid)),
172 params.
set_output(
"Value"_ustr, std::move(output_value));
188 "Node socket data type",
200 ntype.
ui_name =
"Sample Grid Index";
201 ntype.
ui_description =
"Retrieve volume grid values at specific voxels";
#define NODE_CLASS_GEOMETRY
#define GEO_NODE_SAMPLE_GRID_INDEX
#define NOD_REGISTER_NODE(REGISTER_FUNC)
#define NOD_inline_enum_accessors(member)
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
void add_item(std::string socket_name, SocketLinkOperation::LinkSocketFn fn, int weight=0)
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)
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
void node_register_type(bNodeType &ntype)
std::optional< eNodeSocketDatatype > grid_type_to_socket_type(VolumeGridType type)
const CPPType * socket_type_to_geo_nodes_base_cpp_type(eNodeSocketDatatype type)
static void node_init(bNodeTree *, bNode *node)
static void node_declare(NodeDeclarationBuilder &b)
static void node_geo_exec(GeoNodeExecParams params)
static void node_rna(StructRNA *srna)
static void node_layout(ui::Layout &layout, bContext *, PointerRNA *ptr)
static void node_gather_link_search_ops(GatherLinkSearchOpParams ¶ms)
static void node_register()
static std::optional< eNodeSocketDatatype > node_type_for_socket_type(const bNodeSocket &socket)
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)
const EnumPropertyItem * grid_socket_type_items_filter_fn(bContext *, PointerRNA *, PropertyRNA *, bool *r_free)
void node_geo_exec_with_missing_openvdb(GeoNodeExecParams ¶ms)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
const EnumPropertyItem rna_enum_node_socket_data_type_items[]
void geo_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
bke::bNodeTreeType * typeinfo
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(*) initfunc(bNodeTree *ntree, bNode *node)
const char * enum_name_legacy
NodeGatherSocketLinkOperationsFunction gather_link_search_ops
NodeDeclareFunction declare
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)