Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_set_material.cc
| Show All 22 Lines | |||||
| #include "DNA_meshdata_types.h" | #include "DNA_meshdata_types.h" | ||||
| #include "BKE_material.h" | #include "BKE_material.h" | ||||
| namespace blender::nodes { | namespace blender::nodes { | ||||
| static void geo_node_set_material_declare(NodeDeclarationBuilder &b) | static void geo_node_set_material_declare(NodeDeclarationBuilder &b) | ||||
| { | { | ||||
| b.add_input<decl::Geometry>("Geometry").supported_type(GEO_COMPONENT_TYPE_MESH); | b.add_input<decl::Geometry>(N_("Geometry")).supported_type(GEO_COMPONENT_TYPE_MESH); | ||||
| b.add_input<decl::Bool>("Selection").default_value(true).hide_value().supports_field(); | b.add_input<decl::Bool>(N_("Selection")).default_value(true).hide_value().supports_field(); | ||||
| b.add_input<decl::Material>("Material").hide_label(); | b.add_input<decl::Material>(N_("Material")).hide_label(); | ||||
| b.add_output<decl::Geometry>("Geometry"); | b.add_output<decl::Geometry>(N_("Geometry")); | ||||
| } | } | ||||
| static void assign_material_to_faces(Mesh &mesh, const IndexMask selection, Material *material) | static void assign_material_to_faces(Mesh &mesh, const IndexMask selection, Material *material) | ||||
| { | { | ||||
| int new_material_index = -1; | int new_material_index = -1; | ||||
| for (const int i : IndexRange(mesh.totcol)) { | for (const int i : IndexRange(mesh.totcol)) { | ||||
| Material *other_material = mesh.mat[i]; | Material *other_material = mesh.mat[i]; | ||||
| if (other_material == material) { | if (other_material == material) { | ||||
| ▲ Show 20 Lines • Show All 55 Lines • Show Last 20 Lines | |||||