20# include <openvdb/tools/Clip.h>
32 b.use_custom_socket_order();
33 b.allow_any_socket_order();
34 b.add_default_layout();
37 b.add_input(data_type,
"Grid"_ustr).hide_value().structure_type(StructureType::Grid);
38 b.add_output(data_type,
"Grid"_ustr).structure_type(StructureType::Grid).align_with_previous();
43 .description(
"Minimum X index of the clipping bounding box");
47 .description(
"Minimum Y index of the clipping bounding box");
51 .description(
"Minimum Z index of the clipping bounding box");
55 .description(
"Maximum X index of the clipping bounding box");
59 .description(
"Maximum Y index of the clipping bounding box");
63 .description(
"Maximum Z index of the clipping bounding box");
73 switch (socket.
type) {
96 bNode &
node = params.add_node(
"GeometryNodeGridClip"_ustr);
97 node.custom1 = *data_type;
98 params.update_and_connect_available_socket(
node,
"Grid"_ustr);
105 bke::GVolumeGrid grid = params.
extract_input<bke::GVolumeGrid>(
"Grid"_ustr);
118 bke::VolumeTreeAccessToken tree_token;
119 openvdb::GridBase &grid_base = grid.get_for_write().grid_for_write(tree_token);
121 const openvdb::CoordBBox coord_bbox(openvdb::Coord(min_index.x, min_index.y, min_index.z),
122 openvdb::Coord(max_index.x, max_index.y, max_index.z));
124 bke::volume_grid::to_typed_grid(grid_base, [&](
auto &typed_grid) {
125 auto active_bbox = typed_grid.evalActiveVoxelBoundingBox();
126 if (active_bbox.empty()) {
129 active_bbox.intersect(coord_bbox);
130 typed_grid.clip(active_bbox);
133 params.
set_output(
"Grid"_ustr, std::move(grid));
149 "Node socket data type",
162 "Deactivate grid voxels outside minimum and maximum coordinates, setting them to the "
#define NODE_CLASS_GEOMETRY
#define NOD_REGISTER_NODE(REGISTER_FUNC)
#define NOD_inline_enum_accessors(member)
void add_item(std::string socket_name, SocketLinkOperation::LinkSocketFn fn, int weight=0)
const bNodeSocket & other_socket() const
T extract_input(const UString identifier)
void set_default_remaining_outputs()
void set_output(const UString identifier, T &&value)
StructureType structure_type
void node_register_type(bNodeType &ntype)
static void node_geo_exec(GeoNodeExecParams params)
static void node_register()
static void node_rna(StructRNA *srna)
static void node_layout(ui::Layout &layout, bContext *, PointerRNA *ptr)
static void node_declare(NodeDeclarationBuilder &b)
static std::optional< eNodeSocketDatatype > node_type_for_socket_type(const bNodeSocket &socket)
static void node_gather_link_search_ops(GatherLinkSearchOpParams ¶ms)
static void node_init(bNodeTree *, bNode *node)
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)
const EnumPropertyItem * grid_socket_type_items_filter_fn(bContext *, PointerRNA *, PropertyRNA *, bool *r_free)
void node_geo_exec_with_missing_openvdb(GeoNodeExecParams ¶ms)
VecBase< int32_t, 3 > int3
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)
void(*) draw_buttons(ui::Layout &, bContext *C, PointerRNA *ptr)
std::string ui_description
NodeGeometryExecFunction geometry_node_execute
void(*) initfunc(bNodeTree *ntree, bNode *node)
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)