21# include "openvdb/tools/Filter.h"
28 b.use_custom_socket_order();
29 b.allow_any_socket_order();
30 b.add_default_layout();
36 b.add_input(data_type,
"Grid"_ustr).hide_value().structure_type(StructureType::Grid);
37 b.add_output(data_type,
"Grid"_ustr).structure_type(StructureType::Grid).align_with_previous();
44 .description(
"Filter kernel radius in voxels");
51 .description(
"Number of iterations to apply the filter");
61 switch (socket.
type) {
78 const bool is_grid = structure_type == StructureType::Grid;
79 const bool is_dynamic = structure_type == StructureType::Dynamic;
89 node.custom1 = *data_type;
96 node.custom1 = *data_type;
105 bke::GVolumeGrid grid = params.
extract_input<bke::GVolumeGrid>(
"Grid"_ustr);
112 const int iterations = params.
extract_input<
int>(
"Iterations"_ustr);
113 if (width <= 0 || iterations <= 0) {
114 params.
set_output(
"Grid"_ustr, std::move(grid));
118 bke::VolumeTreeAccessToken tree_token;
119 openvdb::GridBase &grid_base = grid.get_for_write().grid_for_write(tree_token);
121 bke::volume_grid::to_typed_grid(grid_base, [&](
auto &typed_grid) {
122 openvdb::tools::Filter
filter(typed_grid);
123 filter.median(width, iterations);
126 params.
set_output(
"Grid"_ustr, std::move(grid));
155 "Node socket data type",
169 "Apply median (box) filter smoothing to a voxel. The median value from surrounding "
170 "voxels in a box-shape defined by the radius replaces the voxel value.";
#define NODE_CLASS_GEOMETRY
#define NOD_REGISTER_NODE(REGISTER_FUNC)
#define NOD_inline_enum_accessors(member)
nodes::StructureType inferred_structure_type
void add_item(std::string socket_name, SocketLinkOperation::LinkSocketFn fn, int weight=0)
const bNodeSocket & other_socket() const
eNodeSocketInOut in_out() const
T extract_input(const UString identifier)
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)
StructureType structure_type
void node_register_type(bNodeType &ntype)
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)
void node_geo_exec_with_missing_openvdb(GeoNodeExecParams ¶ms)
bool socket_type_supports_grids(const eNodeSocketDatatype socket_type)
const EnumPropertyItem * enum_items_filter(const EnumPropertyItem *original_item_array, FunctionRef< bool(const EnumPropertyItem &item)> fn)
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::bNodeSocketRuntime * runtime
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)