19 b.add_output<
decl::Bool>(
"Selection").field_source();
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 slot_i = material_indices_span[domain_index];
49 domain_selection[domain_index] = slots.
contains(slot_i);
59 :
bke::GeometryFieldInput(
CPPType::get<bool>(),
"Material Selection node"),
68 switch (context.type()) {
69 case GeometryComponent::Type::Mesh: {
70 const Mesh *mesh = context.mesh();
75 const IndexMask domain_mask = (domain == AttrDomain::Face) ?
mask :
79 {mesh->
mat, mesh->
totcol}, material_, attributes, AttrDomain::Face, domain_mask);
80 return attributes.
adapt_domain<
bool>(std::move(selection), AttrDomain::Face, domain);
82 case GeometryComponent::Type::GreasePencil: {
88 const IndexMask domain_mask = (domain == AttrDomain::Curve) ?
93 "material_index", AttrDomain::Curve, 0);
94 const GreasePencil &grease_pencil = *context.grease_pencil();
96 {grease_pencil.material_array, grease_pencil.material_array_num},
101 return attributes.
adapt_domain<
bool>(std::move(selection), AttrDomain::Curve, domain);
103 case GeometryComponent::Type::Curve: {
104 const Curves *curves_id = context.curves_id();
113 const IndexMask domain_mask = (domain == AttrDomain::Curve) ?
118 "material_index", AttrDomain::Curve, 0);
124 return attributes.
adapt_domain<
bool>(std::move(selection), AttrDomain::Curve, domain);
141 return material_ == other_material_selection->material_;
149 return AttrDomain::Face;
156 Field<bool> material_field{std::make_shared<MaterialSelectionFieldInput>(material)};
157 params.set_output(
"Selection", std::move(material_field));
165 ntype.
ui_name =
"Material Selection";
166 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)
unsigned long long int uint64_t
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 attribute_id, 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
AttributeAccessor attributes() const
void foreach_index_optimized(Fn &&fn) const
int64_t min_array_size() const
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
void node_register_type(bNodeType &ntype)
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)
uint64_t get_default_hash(const T &v, const Args &...args)
void geo_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
std::string ui_description
NodeGeometryExecFunction geometry_node_execute
const char * enum_name_legacy
NodeDeclareFunction declare