30 b.use_custom_socket_order();
31 b.allow_any_socket_order();
33 b.add_default_layout();
42 b.add_input(data_type,
"Grid"_ustr).hide_value().structure_type(StructureType::Grid);
43 b.add_output(data_type,
"Grid"_ustr)
44 .structure_type(StructureType::Grid)
45 .align_with_previous()
46 .propagate_references({1});
51 .structure_type(StructureType::Field);
63 switch (socket.
type) {
85 if (
ELEM(structure_type, StructureType::Grid, StructureType::Dynamic)) {
90 node.custom1 = *data_type;
103 if (
ELEM(structure_type, StructureType::Grid, StructureType::Dynamic)) {
108 node.custom1 = *data_type;
119 const openvdb::math::Transform &
transform,
120 const volume_grid::LeafNodeMask &leaf_node_mask,
121 const openvdb::CoordBBox &leaf_bbox,
122 const volume_grid::GetVoxelsFn get_voxels_fn,
123 openvdb::GridBase &output_grid)
131 [&](
const int64_t i) { return leaf_node_mask.isOn(i); },
134 const openvdb::Coord any_voxel_in_leaf = leaf_bbox.min();
137 get_voxels_fn(voxels);
139 bke::VoxelFieldContext field_context{
transform, voxels};
142 MutableSpan<bool> selection = scope.allocator().allocate_array<
bool>(
148 volume_grid::set_leaf_values_off(output_grid, any_voxel_in_leaf, selection);
151BLI_NOINLINE static void process_voxels(
const fn::Field<bool> &selection_field,
152 const openvdb::math::Transform &
transform,
153 const Span<openvdb::Coord> voxels,
154 openvdb::GridBase &output_grid)
157 AlignedBuffer<8192, 8> allocation_buffer;
158 ResourceScope scope(allocation_buffer);
160 bke::VoxelFieldContext field_context{
transform, voxels};
161 fn::FieldEvaluator evaluator{field_context, voxels_num};
163 MutableSpan<bool> selection = scope.allocator().allocate_array<
bool>(voxels_num);
165 evaluator.evaluate();
167 volume_grid::set_grid_values_off(output_grid, selection, voxels);
170BLI_NOINLINE static void process_tiles(
const fn::Field<bool> &selection_field,
171 const openvdb::math::Transform &
transform,
172 const Span<openvdb::CoordBBox>
tiles,
173 openvdb::GridBase &output_grid)
176 AlignedBuffer<8192, 8> allocation_buffer;
177 ResourceScope scope(allocation_buffer);
180 fn::FieldEvaluator evaluator{field_context, tiles_num};
182 MutableSpan<bool> selection;
183 selection = scope.allocator().allocate_array<
bool>(tiles_num);
184 evaluator.add_with_destination(selection_field, selection);
185 evaluator.evaluate();
187 volume_grid::set_tile_values_off(output_grid, selection,
tiles);
195 bke::GVolumeGrid grid = params.
extract_input<bke::GVolumeGrid>(
"Grid"_ustr);
202 bke::VolumeTreeAccessToken tree_token;
203 openvdb::GridBase &grid_base = grid.get_for_write().grid_for_write(tree_token);
214 const openvdb::math::Transform &
transform = grid_base.transform();
215 openvdb::MaskTree mask_tree;
216 volume_grid::to_typed_grid(grid_base,
217 [&](
const auto &grid) { mask_tree.topologyUnion(grid.tree()); });
219 volume_grid::parallel_grid_topology_tasks(
221 [&](
const volume_grid::LeafNodeMask &leaf_node_mask,
222 const openvdb::CoordBBox &leaf_bbox,
223 const volume_grid::GetVoxelsFn get_voxels_fn) {
225 selection_field,
transform, leaf_node_mask, leaf_bbox, get_voxels_fn, grid_base);
228 process_voxels(selection_field,
transform, voxels, grid_base);
235 params.
set_output(
"Grid"_ustr, std::move(grid));
251 "Node socket data type",
263 ntype.
ui_name =
"Deactivate Voxels";
#define NODE_CLASS_GEOMETRY
#define NOD_REGISTER_NODE(REGISTER_FUNC)
#define NOD_inline_enum_accessors(member)
SIMD_FORCE_INLINE btVector3 transform(const btVector3 &point) const
constexpr int64_t size() const
static IndexMask from_predicate(const IndexMask &universe, LinearAllocator<> &memory, Fn &&predicate, exec_mode::Mode mode=exec_mode::parallel)
constexpr IndexRange()=default
nodes::StructureType inferred_structure_type
int add_with_destination(GField field, GVMutableArray dst)
bool depends_on_input() const
int64_t min_array_size() const
void add_item(std::string socket_name, SocketLinkOperation::LinkSocketFn fn, int weight=0)
const bNodeTree & node_tree() const
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)
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 connect_available_socket(bNode &new_node, UString socket_name)
ccl_gpu_kernel_postfix ccl_global KernelWorkTile * tiles
void node_register_type(bNodeType &ntype)
void evaluate_constant_field(const GField &field, void *r_value)
static void node_rna(StructRNA *srna)
static void node_gather_link_search_ops(GatherLinkSearchOpParams ¶ms)
static void node_geo_exec(GeoNodeExecParams params)
static void node_layout(ui::Layout &layout, bContext *, PointerRNA *ptr)
static void node_register()
static void node_init(bNodeTree *, bNode *node)
static std::optional< eNodeSocketDatatype > node_type_for_socket_type(const bNodeSocket &socket)
static void node_declare(NodeDeclarationBuilder &b)
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)
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
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)
NodeGatherSocketLinkOperationsFunction gather_link_search_ops
NodeDeclareFunction declare
void use_property_decorate_set(bool is_decorate)
void use_property_split_set(bool is_sep)
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)