16#include "RNA_prototypes.hh"
21# include <openvdb/tools/Prune.h>
37 "Keep voxels and tiles that are active in all grids"},
42 "Add voxels or tiles that are active in any grid"},
47 "Keep active voxels and tiles of the primary grid that are not active in secondary grids"},
48 {0,
nullptr, 0,
nullptr,
nullptr},
53 b.use_custom_socket_order();
54 b.allow_any_socket_order();
62 b.add_default_layout();
69 b.add_input(data_type,
"Grid 1"_ustr).hide_value().structure_type(StructureType::Grid);
70 b.add_output(data_type,
"Grid"_ustr)
72 .structure_type(StructureType::Grid)
73 .align_with_previous();
75 b.add_input(data_type,
"Grid 2"_ustr)
78 .structure_type(StructureType::Grid);
91 "Node socket data type",
109 if (
auto grid = params.
extract_input<bke::GVolumeGrid>(
"Grid 1"_ustr)) {
110 operands.append(std::move(grid));
113 for (
const bke::GVolumeGrid &grid : grids.values) {
115 operands.append(grid);
119 if (operands.is_empty()) {
130 BKE_volume_grid_type_to_static_type(
131 *grid_type, [&]<std::derived_from<openvdb::GridBase> GridType>() {
132 if constexpr (std::is_same_v<GridType, openvdb::BoolGrid> ||
133 std::is_same_v<GridType, openvdb::FloatGrid> ||
134 std::is_same_v<GridType, openvdb::Int32Grid> ||
135 std::is_same_v<GridType, openvdb::Vec3fGrid>)
137 bke::VolumeTreeAccessToken result_token;
138 GridType &result_grid =
static_cast<GridType &
>(
139 operands.first().get_for_write().grid_for_write(result_token));
140 const openvdb::math::Transform &
transform = result_grid.transform();
142 for (bke::GVolumeGrid &
volume_grid : operands.as_mutable_span().drop_front(1)) {
143 bke::VolumeTreeAccessToken operand_token;
144 const GridType &operand_grid =
static_cast<const GridType &
>(
147 if (operand_grid.transform() !=
transform) {
149 TIP_(
"Mismatched grid operand transforms"));
155 result_grid.tree().topologyIntersection(operand_grid.tree());
156 openvdb::tools::pruneInactive(result_grid.tree());
159 result_grid.tree().topologyUnion(operand_grid.tree());
162 result_grid.tree().topologyDifference(operand_grid.tree());
163 openvdb::tools::pruneInactive(result_grid.tree());
167 catch (
const openvdb::ValueError & ) {
173 operands.first()->tag_tree_modified();
177 params.
set_output(
"Grid"_ustr, std::move(operands.first()));
188 ntype.
ui_name =
"Grid Topology Boolean";
#define NODE_CLASS_GEOMETRY
#define NOD_REGISTER_NODE(REGISTER_FUNC)
#define NOD_inline_enum_accessors(member)
DBVT_INLINE bool Intersect(const btDbvtAabbMm &a, const btDbvtAabbMm &b)
void error_message_add(const NodeWarningType type, StringRef message) const
T extract_input(const UString identifier)
const bNode & node() const
void set_default_remaining_outputs()
void set_output(const UString identifier, T &&value)
std::optional< VolumeGridType > socket_type_to_grid_type(eNodeSocketDatatype type)
void node_register_type(bNodeType &ntype)
static void node_layout(ui::Layout &layout, bContext *, PointerRNA *ptr)
static void node_declare(NodeDeclarationBuilder &b)
static void node_register()
static const EnumPropertyItem operation_items[]
static void node_geo_exec(GeoNodeExecParams params)
static void node_rna(StructRNA *srna)
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)
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)
static constexpr int _180
void(*) draw_buttons(ui::Layout &, bContext *C, PointerRNA *ptr)
std::string ui_description
NodeGeometryExecFunction geometry_node_execute
void(*) initfunc(bNodeTree *ntree, bNode *node)
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)