22#include <fmt/format.h>
33 .
description(
"Base mesh to subtract geometry from");
35 if (
node !=
nullptr) {
48 .
description(
"Mesh that is subtracted from the first mesh");
56 auto &self_intersect =
57 b.add_input<
decl::Bool>(
"Self Intersection"_ustr).make_available(make_mesh_arr);
59 b.add_input<
decl::Bool>(
"Hole Tolerant"_ustr).make_available(make_mesh_arr);
61 auto &output_edges =
b.add_output<
decl::Bool>(
"Intersecting Edges"_ustr)
62 .anonymous_attribute_output()
65 if (
node !=
nullptr) {
69 output_edges.available(
77 first_geometry.available(
false);
115 bool use_self =
false;
116 bool hole_tolerant =
false;
118 use_self = params.
extract_input<
bool>(
"Self Intersection"_ustr);
119 hole_tolerant = params.
extract_input<
bool>(
"Hole Tolerant"_ustr);
136 if (mesh_in_a->totcol == 0) {
138 materials.
add(
nullptr);
141 materials.
add_multiple({mesh_in_a->mat, mesh_in_a->totcol});
143 material_remaps.
append({});
158 const Span<int> handles = instances->reference_handles();
159 const Span<float4x4> instance_transforms = instances->transforms();
162 switch (reference.
type()) {
168 transforms.
append(instance_transforms[i]);
176 transforms.
append(instance_transforms[i]);
191 material_remaps.
resize(0);
197 "Intersecting Edges"_ustr);
220 fmt::format(fmt::runtime(
TIP_(
"Input {} was not manifold")),
index));
229 TIP_(
"Boolean result is too big for solver to handle"));
233 TIP_(
"Boolean solver not available (compiled without it)"));
243 MEM_SAFE_DELETE(
result->mat);
254 selection.
span.fill(
false);
255 for (
const int i : intersecting_edges) {
256 selection.
span[i] =
true;
263 all_geometries.
append(set_a);
268 all_geometries, {}, std::make_optional(types_to_join));
275 params.
set_output(
"Mesh"_ustr, std::move(result_geometry));
285 "Keep the part of the mesh that is common between all operands"},
290 "Combine meshes in an additive way"},
295 "Combine meshes in a subtractive way"},
296 {0,
nullptr, 0,
nullptr,
nullptr},
303 "Slower solver with the best results for coplanar faces"},
308 "Simple solver with good performance, without support for overlapping geometry"},
313 "Fastest solver that works only on manifold meshes but gives better results"},
314 {0,
nullptr, 0,
nullptr,
nullptr},
321 rna_node_geometry_boolean_method_items,
329 rna_geometry_boolean_solver_items,
338 ntype.
ui_name =
"Mesh Boolean";
339 ntype.
ui_description =
"Cut, subtract, or join multiple mesh inputs";
#define NODE_CLASS_GEOMETRY
#define GEO_NODE_MESH_BOOLEAN
Object is a sort of wrapper for general info.
#define NOD_REGISTER_NODE(REGISTER_FUNC)
#define NOD_inline_enum_accessors(member)
constexpr IndexRange()=default
constexpr MutableSpan()=default
constexpr IndexRange index_range() const
int64_t index_of_or_add(const Key &key)
void add_multiple(Span< Key > keys)
void append(const T &value)
void resize(const int64_t new_size)
void extend(Span< T > array)
GeometrySet & geometry_set()
GSpanAttributeWriter lookup_or_add_for_write_only_span(StringRef name, AttrDomain domain, AttrType data_type)
void error_message_add(const NodeWarningType type, StringRef message) const
std::optional< std::string > get_output_anonymous_attribute_id_if_needed(const UString output_identifier, const bool force_create=false)
T extract_input(const UString identifier)
const bNode & node() const
void set_default_remaining_outputs()
void set_output(const UString identifier, T &&value)
void make_available(bNode &node) const
void node_register_type(bNodeType &ntype)
GeometrySet object_get_evaluated_geometry_set(const Object &object, bool apply_subdiv=true)
Mesh * mesh_boolean(Span< const Mesh * > meshes, Span< float4x4 > transforms, Span< Array< short > > material_remaps, BooleanOpParameters op_params, Solver solver, Vector< int > *r_intersecting_edges, BooleanError *r_error)
bke::GeometrySet join_geometries(Span< bke::GeometrySet > geometries, const bke::AttributeFilter &attribute_filter, const std::optional< Span< bke::GeometryComponent::Type > > &component_types_to_join=std::nullopt, bool allow_merging_instance_references=true)
void debug_randomize_mesh_order(Mesh *mesh)
static void node_init(bNodeTree *, bNode *node)
static Array< short > calc_mesh_material_map(const Mesh &mesh, VectorSet< Material * > &all_materials)
static void node_geo_exec(GeoNodeExecParams params)
static void node_register()
static void node_layout(ui::Layout &layout, bContext *, PointerRNA *ptr)
static void node_rna(StructRNA *srna)
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 * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
void geo_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
static MatBase identity()
void merge_bundle_from(const GeometrySet &other)
StringRefNull name() const
void set_name(std::string name)
const Mesh * get_mesh() const
void replace_mesh(Mesh *mesh, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
MutableVArraySpan< T > span
void(*) draw_buttons(ui::Layout &, bContext *C, PointerRNA *ptr)
std::string ui_description
NodeGeometryExecFunction geometry_node_execute
void(*) initfunc(bNodeTree *ntree, bNode *node)
const char * enum_name_legacy
NodeDeclareFunction declare
Vector< int > non_manifold_mesh_indices
bool no_self_intersections
bool no_nested_components
std::optional< std::string > intersecting_edges_id
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)