Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_grid.cc
| Show First 20 Lines • Show All 174 Lines • ▼ Show 20 Lines | b.add_input<decl::Int>(N_("Vertices X")) | ||||
| .max(1000) | .max(1000) | ||||
| .description(N_("Number of vertices in the X direction")); | .description(N_("Number of vertices in the X direction")); | ||||
| b.add_input<decl::Int>(N_("Vertices Y")) | b.add_input<decl::Int>(N_("Vertices Y")) | ||||
| .default_value(3) | .default_value(3) | ||||
| .min(2) | .min(2) | ||||
| .max(1000) | .max(1000) | ||||
| .description(N_("Number of vertices in the Y direction")); | .description(N_("Number of vertices in the Y direction")); | ||||
| b.add_output<decl::Geometry>(N_("Mesh")); | b.add_output<decl::Geometry>(N_("Mesh")); | ||||
| b.add_output<decl::Vector>(N_("UV Map")).field_source(); | b.add_output<decl::Vector>(N_("UV Map")).field_on_all(); | ||||
| } | } | ||||
| static void node_geo_exec(GeoNodeExecParams params) | static void node_geo_exec(GeoNodeExecParams params) | ||||
| { | { | ||||
| const float size_x = params.extract_input<float>("Size X"); | const float size_x = params.extract_input<float>("Size X"); | ||||
| const float size_y = params.extract_input<float>("Size Y"); | const float size_y = params.extract_input<float>("Size Y"); | ||||
| const int verts_x = params.extract_input<int>("Vertices X"); | const int verts_x = params.extract_input<int>("Vertices X"); | ||||
| const int verts_y = params.extract_input<int>("Vertices Y"); | const int verts_y = params.extract_input<int>("Vertices Y"); | ||||
| if (verts_x < 1 || verts_y < 1) { | if (verts_x < 1 || verts_y < 1) { | ||||
| params.set_default_remaining_outputs(); | params.set_default_remaining_outputs(); | ||||
| return; | return; | ||||
| } | } | ||||
| StrongAnonymousAttributeID uv_map_id; | AutoAnonymousAttributeID uv_map_id = params.get_output_anonymous_attribute_id_if_needed( | ||||
| if (params.output_is_required("UV Map")) { | "UV Map"); | ||||
| uv_map_id = StrongAnonymousAttributeID("uv_map"); | |||||
| } | |||||
| Mesh *mesh = create_grid_mesh(verts_x, verts_y, size_x, size_y, uv_map_id.get()); | Mesh *mesh = create_grid_mesh(verts_x, verts_y, size_x, size_y, uv_map_id.get()); | ||||
| BKE_id_material_eval_ensure_default_slot(&mesh->id); | BKE_id_material_eval_ensure_default_slot(&mesh->id); | ||||
| params.set_output("Mesh", GeometrySet::create_with_mesh(mesh)); | params.set_output("Mesh", GeometrySet::create_with_mesh(mesh)); | ||||
| if (uv_map_id) { | if (uv_map_id) { | ||||
| params.set_output("UV Map", | params.set_output("UV Map", | ||||
| Show All 18 Lines | |||||