6# include <openvdb/openvdb.h>
7# include <openvdb/tools/Composite.h>
31 const bNode *node =
b.node_or_null();
37 static const auto make_available = [](
bNode &node) {
47 .structure_type(StructureType::Grid);
54 .structure_type(StructureType::Grid);
65 first_grid.available(
false);
68 first_grid.available(
true);
94 operands.extend(grids.values);
98 operands.append(std::move(grid));
100 operands.extend(grids.values);
104 if (operands.is_empty()) {
105 params.set_default_remaining_outputs();
109 bke::VolumeTreeAccessToken result_token;
110 openvdb::FloatGrid &result_grid = operands.first().grid_for_write(result_token);
111 const openvdb::math::Transform &
transform = result_grid.transform();
114 bke::VolumeTreeAccessToken tree_token;
115 std::shared_ptr<openvdb::FloatGrid> resampled_storage;
116 openvdb::FloatGrid &grid = geometry::resample_sdf_grid_if_necessary(
117 volume_grid, tree_token,
transform, resampled_storage);
122 openvdb::tools::csgIntersection(result_grid, grid);
125 openvdb::tools::csgUnion(result_grid, grid);
128 openvdb::tools::csgDifference(result_grid, grid);
132 catch (
const openvdb::ValueError & ) {
134 params.set_default_remaining_outputs();
138 operands.first()->tag_tree_modified();
140 params.set_output(
"Grid", std::move(operands.first()));
153 "Keep the part of the grids that is common between all operands"},
154 {int(
Operation::Union),
"UNION", 0,
"Union",
"Combine grids in an additive way"},
159 "Combine grids in a subtractive way"},
160 {0,
nullptr, 0,
nullptr,
nullptr},
176 ntype.
ui_name =
"SDF Grid Boolean";
177 ntype.
ui_description =
"Cut, subtract, or join multiple SDF volume grid inputs";
#define NODE_CLASS_GEOMETRY
#define GEO_NODE_SDF_GRID_BOOLEAN
#define NOD_REGISTER_NODE(REGISTER_FUNC)
#define NOD_inline_enum_accessors(member)
SIMD_FORCE_INLINE btVector3 transform(const btVector3 &point) const
DBVT_INLINE bool Intersect(const btDbvtAabbMm &a, const btDbvtAabbMm &b)
StructureType structure_type
void make_available(bNode &node) const
void node_register_type(bNodeType &ntype)
static void node_rna(StructRNA *srna)
static void node_init(bNodeTree *, bNode *node)
static void node_register()
static void node_geo_exec(GeoNodeExecParams params)
static void node_layout(uiLayout *layout, bContext *, PointerRNA *ptr)
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)
void node_geo_exec_with_missing_openvdb(GeoNodeExecParams ¶ms)
void geo_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
std::string ui_description
void(* initfunc)(bNodeTree *ntree, bNode *node)
NodeGeometryExecFunction geometry_node_execute
const char * enum_name_legacy
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
NodeDeclareFunction declare
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< blender::StringRef > name_opt, int icon, std::optional< blender::StringRef > placeholder=std::nullopt)