Differential D16858 Diff 58905 source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_ico_sphere.cc
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_ico_sphere.cc
| Show All 19 Lines | b.add_input<decl::Float>(N_("Radius")) | ||||
| .subtype(PROP_DISTANCE) | .subtype(PROP_DISTANCE) | ||||
| .description(N_("Distance from the generated points to the origin")); | .description(N_("Distance from the generated points to the origin")); | ||||
| b.add_input<decl::Int>(N_("Subdivisions")) | b.add_input<decl::Int>(N_("Subdivisions")) | ||||
| .default_value(1) | .default_value(1) | ||||
| .min(1) | .min(1) | ||||
| .max(7) | .max(7) | ||||
| .description(N_("Number of subdivisions on top of the basic icosahedron")); | .description(N_("Number of subdivisions on top of the basic icosahedron")); | ||||
| 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_auto(); | ||||
| } | } | ||||
| static Mesh *create_ico_sphere_mesh(const int subdivisions, | static Mesh *create_ico_sphere_mesh(const int subdivisions, | ||||
| const float radius, | const float radius, | ||||
| const AttributeIDRef &uv_map_id) | const AttributeIDRef &uv_map_id) | ||||
| { | { | ||||
| const float4x4 transform = float4x4::identity(); | const float4x4 transform = float4x4::identity(); | ||||
| Show All 35 Lines | static Mesh *create_ico_sphere_mesh(const int subdivisions, | ||||
| return mesh; | return mesh; | ||||
| } | } | ||||
| static void node_geo_exec(GeoNodeExecParams params) | static void node_geo_exec(GeoNodeExecParams params) | ||||
| { | { | ||||
| const int subdivisions = std::min(params.extract_input<int>("Subdivisions"), 10); | const int subdivisions = std::min(params.extract_input<int>("Subdivisions"), 10); | ||||
| const float radius = params.extract_input<float>("Radius"); | const float radius = params.extract_input<float>("Radius"); | ||||
| 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_ico_sphere_mesh(subdivisions, radius, uv_map_id.get()); | Mesh *mesh = create_ico_sphere_mesh(subdivisions, radius, 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>( | ||||
| std::move(uv_map_id), params.attribute_producer_name())); | std::move(uv_map_id), params.attribute_producer_name())); | ||||
| Show All 17 Lines | |||||