17#include "RNA_prototypes.hh"
36 b.use_custom_socket_order();
37 b.allow_any_socket_order();
38 b.add_default_layout();
48 b.add_input(data_type,
"Topology"_ustr).structure_type(StructureType::Grid);
58 b.add_input(data_type, name, input_identifier)
59 .structure_type(StructureType::Field)
61 b.add_output(data_type, name, output_identifier)
62 .structure_type(StructureType::Grid)
63 .align_with_previous()
64 .description(
"Output grid with evaluated field values");
68 .structure_type(StructureType::Field)
69 .custom_draw(socket_items::ui::draw_extend_socket_fn<FieldToGridItemsAccessor>());
71 .structure_type(StructureType::Grid)
72 .align_with_previous();
85 socket_items::ui::draw_items_list_with_operators<ItemsAccessor>(
C, panel, tree,
node);
86 socket_items::ui::draw_active_item_props<ItemsAccessor>(tree,
node, [&](
PointerRNA *item_ptr) {
87 panel->use_property_split_set(
true);
88 panel->use_property_decorate_set(
false);
89 panel->prop(item_ptr,
"data_type",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
96 switch (socket.
type) {
121 node_storage(
node).data_type = *data_type;
147 bke::GVolumeGrid topology_grid = params.
extract_input<bke::GVolumeGrid>(
"Topology"_ustr);
148 if (!topology_grid) {
154 bke::VolumeTreeAccessToken tree_token;
155 const openvdb::GridBase &topology_base = topology_grid->grid(tree_token);
156 const openvdb::math::Transform &
transform = topology_base.transform();
170 const int item_i = required_items[i];
175 openvdb::MaskTree mask_tree;
176 grid::to_typed_grid(topology_base,
177 [&](
const auto &grid) { mask_tree.topologyUnion(grid.tree()); });
180 evaluate_fields_to_grid(mask_tree,
transform, fields, output_grids);
183 const int item_i = required_items[i];
209 auto *dst_storage = MEM_new<GeometryNodeFieldToGrid>(__func__,
dna::shallow_copy(src_storage));
210 dst_node->
storage = dst_storage;
240 return node.input_by_identifier(output_socket.identifier_ustr());
248 ntype.
ui_name =
"Field to Grid";
250 "Create new grids by evaluating new values on an existing volume grid topology";
#define NODE_STORAGE_FUNCS(StorageT)
#define NODE_CLASS_GEOMETRY
#define NOD_REGISTER_NODE(REGISTER_FUNC)
constexpr IndexRange index_range() const
void append(const T &value)
IndexRange index_range() const
void reserve(const int64_t min_capacity)
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)
bool output_is_required(const UString identifier) 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)
void update_and_connect_available_socket_by_identifier(bNode &new_node, UString socket_identifier)
#define storage(slot, qualifiers)
void node_register_type(bNodeType &ntype)
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 std::optional< eNodeSocketDatatype > node_type_for_socket_type(const bNodeSocket &socket)
static void node_declare(NodeDeclarationBuilder &b)
static void node_operators()
static void node_gather_link_search_ops(GatherLinkSearchOpParams ¶ms)
static bool node_insert_link(bke::NodeInsertLinkParams ¶ms)
FieldToGridItemsAccessor ItemsAccessor
static void node_copy_storage(bNodeTree *, bNode *dst_node, const bNode *src_node)
static void node_blend_read(bNodeTree &, bNode &node, BlendDataReader &reader)
static void node_layout(ui::Layout &layout, bContext *, PointerRNA *ptr)
static void node_register()
static void node_geo_exec(GeoNodeExecParams params)
static void node_blend_write(const bNodeTree &, const bNode &node, BlendWriter &writer)
static void node_free_storage(bNode *node)
static void node_layout_ex(ui::Layout &layout, bContext *C, PointerRNA *ptr)
static void node_init(bNodeTree *, bNode *node)
static const bNodeSocket * node_internally_linked_input(const bNodeTree &, const bNode &node, const bNodeSocket &output_socket)
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 node_geo_exec_with_missing_openvdb(GeoNodeExecParams ¶ms)
BMesh const char void * data
void geo_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
void BLO_read_string(BlendDataReader *reader, char **ptr_p)
void write_string(const char *data)
eNodeSocketDatatype data_type
NodeInternallyLinkedInputFunction internally_linked_input
void(*) draw_buttons(ui::Layout &, bContext *C, PointerRNA *ptr)
NodeBlendWriteFunction blend_write_storage_content
void(*) register_operators()
std::string ui_description
NodeBlendDataReadFunction blend_data_read_storage_content
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 ignore_inferred_input_socket_visibility
bool(*) insert_link(NodeInsertLinkParams ¶ms)
static StructRNA ** item_srna
static std::string input_socket_identifier_for_item(const GeometryNodeFieldToGridItem &item)
static void blend_write_item(BlendWriter *writer, const ItemT &item)
static void blend_read_data_item(BlendDataReader *reader, ItemT &item)
GeometryNodeFieldToGridItem ItemT
static std::string output_socket_identifier_for_item(const GeometryNodeFieldToGridItem &item)
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)