19 b.add_output<
decl::Bool>(
"Selection"_ustr).structure_type(StructureType::Field);
28 const int domain_size = attributes.
domain_size(domain);
31 if (materials[slot_i] == material) {
40 "material_index", domain, 0);
41 if (
const std::optional<int> single = material_indices.
get_if_single()) {
48 [&](
const int domain_index) {
49 const int slot_i = material_indices_span[domain_index];
50 domain_selection[domain_index] = slots.
contains(slot_i);
69 switch (context.type()) {
76 const IndexMask domain_mask = (domain == AttrDomain::Face) ?
mask :
80 {
mesh->mat,
mesh->totcol}, material_, attributes, AttrDomain::Face, domain_mask);
81 return attributes.
adapt_domain<
bool>(std::move(selection), AttrDomain::Face, domain);
89 const IndexMask domain_mask = (domain == AttrDomain::Curve) ?
94 "material_index", AttrDomain::Curve, 0);
102 return attributes.
adapt_domain<
bool>(std::move(selection), AttrDomain::Curve, domain);
105 const Curves *curves_id = context.curves_id();
114 const IndexMask domain_mask = (domain == AttrDomain::Curve) ?
119 "material_index", AttrDomain::Curve, 0);
125 return attributes.
adapt_domain<
bool>(std::move(selection), AttrDomain::Curve, domain);
134 static constexpr int8_t id = 0;
142 return AttrDomain::Face;
162 ntype.
ui_name =
"Material Selection";
163 ntype.
ui_description =
"Provide a selection of faces that use the specified material";
Low-level operations for curves.
Low-level operations for grease pencil.
#define NODE_CLASS_GEOMETRY
#define GEO_NODE_MATERIAL_SELECTION
#define NOD_REGISTER_NODE(REGISTER_FUNC)
constexpr IndexRange index_range() const
std::optional< T > get_if_single() const
static VArray from_single(T value, const int64_t size)
static VArray from_container(ContainerT container)
bool contains(const T &value) const
void append(const T &value)
GAttributeReader lookup_or_default(StringRef name, AttrDomain domain, AttrType data_type, const void *default_value=nullptr) const
GVArray adapt_domain(const GVArray &varray, const AttrDomain from_domain, const AttrDomain to_domain) const
int domain_size(const AttrDomain domain) const
void foreach_index_optimized(Fn &&fn, Mode mode=exec_mode::serial) const
int64_t min_array_size() const
static Field from_input(Args &&...args)
T extract_input(const UString identifier)
void set_output(const UString identifier, T &&value)
void node_register_type(bNodeType &ntype)
constexpr ParallelGrainSize grain_size(int grain_size)
static VArray< bool > select_by_material(const Span< Material * > materials, const Material *material, const AttributeAccessor &attributes, const AttrDomain domain, const IndexMask &domain_mask)
static void node_geo_exec(GeoNodeExecParams params)
static void node_register()
static void node_declare(NodeDeclarationBuilder &b)
void geo_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
std::string ui_description
NodeGeometryExecFunction geometry_node_execute
const char * enum_name_legacy
NodeDeclareFunction declare