37 const AttrDomain domain,
40 const int domain_size = attributes.domain_size(domain);
42 selection_evaluator.set_selection(selection_field);
43 selection_evaluator.evaluate();
44 const IndexMask selection = selection_evaluator.get_evaluated_selection_as_mask();
46 if (selection.size() != attributes.domain_size(domain)) {
58 if (new_index == -1) {
60 new_index = orig_materials_num;
78 bool no_faces_warning =
false;
79 bool point_selection_warning =
false;
80 bool volume_selection_warning =
false;
81 bool curves_selection_warning =
false;
83 geometry_set.modify_geometry_sets([&](
GeometrySet &geometry_set) {
84 if (
Mesh *mesh = geometry_set.get_mesh_for_write()) {
85 if (mesh->faces_num == 0) {
86 if (mesh->verts_num > 0) {
87 no_faces_warning =
true;
94 &mesh->id, field_context, selection_field, attributes, AttrDomain::Face, material);
97 if (
Volume *volume = geometry_set.get_volume_for_write()) {
99 if (selection_field.node().depends_on_input()) {
100 volume_selection_warning =
true;
103 if (
PointCloud *pointcloud = geometry_set.get_pointcloud_for_write()) {
105 if (selection_field.node().depends_on_input()) {
106 point_selection_warning =
true;
109 if (
Curves *curves = geometry_set.get_curves_for_write()) {
111 if (selection_field.node().depends_on_input()) {
112 curves_selection_warning =
true;
115 if (
GreasePencil *grease_pencil = geometry_set.get_grease_pencil_for_write()) {
117 Vector<Mesh *> mesh_by_layer(grease_pencil->layers().size(),
nullptr);
118 for (
const int layer_index : grease_pencil->layers().index_range()) {
119 Drawing *drawing = grease_pencil->get_eval_drawing(grease_pencil->layer(layer_index));
120 if (drawing ==
nullptr) {
124 if (curves.curves_num() == 0) {
129 *grease_pencil, AttrDomain::Curve, layer_index};
141 if (no_faces_warning) {
142 params.error_message_add(NodeWarningType::Info,
143 TIP_(
"Mesh has no faces for material assignment"));
145 if (volume_selection_warning) {
147 NodeWarningType::Info,
148 TIP_(
"Volumes only support a single material; selection input cannot be a field"));
150 if (point_selection_warning) {
152 NodeWarningType::Info,
153 TIP_(
"Point clouds only support a single material; selection input cannot be a field"));
155 if (curves_selection_warning) {
157 NodeWarningType::Info,
158 TIP_(
"Curves only support a single material; selection input cannot be a field"));
161 params.set_output(
"Geometry", std::move(geometry_set));