Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cube.cc
| Show All 29 Lines | b.add_input<decl::Int>(N_("Vertices Y")) | ||||
| .max(1000) | .max(1000) | ||||
| .description(N_("Number of vertices for the Y side of the shape")); | .description(N_("Number of vertices for the Y side of the shape")); | ||||
| b.add_input<decl::Int>(N_("Vertices Z")) | b.add_input<decl::Int>(N_("Vertices Z")) | ||||
| .default_value(2) | .default_value(2) | ||||
| .min(2) | .min(2) | ||||
| .max(1000) | .max(1000) | ||||
| .description(N_("Number of vertices for the Z side of the shape")); | .description(N_("Number of vertices for the Z side of the shape")); | ||||
| 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 Mesh *create_cuboid_mesh(const float3 &size, | static Mesh *create_cuboid_mesh(const float3 &size, | ||||
| const int verts_x, | const int verts_x, | ||||
| const int verts_y, | const int verts_y, | ||||
| const int verts_z, | const int verts_z, | ||||
| const AttributeIDRef &uv_map_id) | const AttributeIDRef &uv_map_id) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | static void node_geo_exec(GeoNodeExecParams params) | ||||
| const int verts_y = params.extract_input<int>("Vertices Y"); | const int verts_y = params.extract_input<int>("Vertices Y"); | ||||
| const int verts_z = params.extract_input<int>("Vertices Z"); | const int verts_z = params.extract_input<int>("Vertices Z"); | ||||
| if (verts_x < 1 || verts_y < 1 || verts_z < 1) { | if (verts_x < 1 || verts_y < 1 || verts_z < 1) { | ||||
| params.error_message_add(NodeWarningType::Info, TIP_("Vertices must be at least 1")); | params.error_message_add(NodeWarningType::Info, TIP_("Vertices must be at least 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_cube_mesh(size, verts_x, verts_y, verts_z, uv_map_id.get()); | Mesh *mesh = create_cube_mesh(size, verts_x, verts_y, verts_z, uv_map_id.get()); | ||||
| 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", | ||||
| AnonymousAttributeFieldInput::Create<float3>( | AnonymousAttributeFieldInput::Create<float3>( | ||||
| Show All 17 Lines | |||||