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);
90 grids.append(std::move(grid));
106 get_float_grids(
inputs, operands);
110 operands.
append(std::move(grid));
112 get_float_grids(
inputs, operands);
117 params.set_default_remaining_outputs();
121 bke::VolumeTreeAccessToken result_token;
122 openvdb::FloatGrid &result_grid = operands.
first().grid_for_write(result_token);
123 const openvdb::math::Transform &
transform = result_grid.transform();
126 bke::VolumeTreeAccessToken tree_token;
127 std::shared_ptr<openvdb::FloatGrid> resampled_storage;
128 openvdb::FloatGrid &grid = geometry::resample_sdf_grid_if_necessary(
129 volume_grid, tree_token,
transform, resampled_storage);
134 openvdb::tools::csgIntersection(result_grid, grid);
137 openvdb::tools::csgUnion(result_grid, grid);
140 openvdb::tools::csgDifference(result_grid, grid);
144 catch (
const openvdb::ValueError & ) {
146 params.set_default_remaining_outputs();
151 params.set_output(
"Grid", std::move(operands.
first()));
164 "Keep the part of the grids that is common between all operands"},
165 {int(
Operation::Union),
"UNION", 0,
"Union",
"Combine grids in an additive way"},
170 "Combine grids in a subtractive way"},
171 {0,
nullptr, 0,
nullptr,
nullptr},
187 ntype.
ui_name =
"SDF Grid Boolean";
188 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)
void append(const T &value)
MutableSpan< T > as_mutable_span()
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 search_link_ops_for_volume_grid_node(GatherLinkSearchOpParams ¶ms)
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)
static blender::bke::bNodeSocketTemplate inputs[]
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)
NodeGatherSocketLinkOperationsFunction gather_link_search_ops
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)