Differential D13337 Diff 45169 source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc
| Show All 21 Lines | |||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
| #include "UI_resources.h" | #include "UI_resources.h" | ||||
| #include "node_geometry_util.hh" | #include "node_geometry_util.hh" | ||||
| namespace blender::nodes::node_geo_mesh_primitive_uv_sphere_cc { | namespace blender::nodes::node_geo_mesh_primitive_uv_sphere_cc { | ||||
| static void geo_node_mesh_primitive_uv_shpere_declare(NodeDeclarationBuilder &b) | static void node_declare(NodeDeclarationBuilder &b) | ||||
| { | { | ||||
| b.add_input<decl::Int>(N_("Segments")) | b.add_input<decl::Int>(N_("Segments")) | ||||
| .default_value(32) | .default_value(32) | ||||
| .min(3) | .min(3) | ||||
| .max(1024) | .max(1024) | ||||
| .description(N_("Horizontal resolution of the sphere")); | .description(N_("Horizontal resolution of the sphere")); | ||||
| b.add_input<decl::Int>(N_("Rings")) | b.add_input<decl::Int>(N_("Rings")) | ||||
| .default_value(16) | .default_value(16) | ||||
| ▲ Show 20 Lines • Show All 248 Lines • ▼ Show 20 Lines | static Mesh *create_uv_sphere_mesh(const float radius, const int segments, const int rings) | ||||
| calculate_sphere_uvs(mesh, segments, rings); | calculate_sphere_uvs(mesh, segments, rings); | ||||
| BLI_assert(BKE_mesh_is_valid(mesh)); | BLI_assert(BKE_mesh_is_valid(mesh)); | ||||
| return mesh; | return mesh; | ||||
| } | } | ||||
| static void geo_node_mesh_primitive_uv_sphere_exec(GeoNodeExecParams params) | static void node_geo_exec(GeoNodeExecParams params) | ||||
| { | { | ||||
| const int segments_num = params.extract_input<int>("Segments"); | const int segments_num = params.extract_input<int>("Segments"); | ||||
| const int rings_num = params.extract_input<int>("Rings"); | const int rings_num = params.extract_input<int>("Rings"); | ||||
| if (segments_num < 3 || rings_num < 2) { | if (segments_num < 3 || rings_num < 2) { | ||||
| if (segments_num < 3) { | if (segments_num < 3) { | ||||
| params.error_message_add(NodeWarningType::Info, TIP_("Segments must be at least 3")); | params.error_message_add(NodeWarningType::Info, TIP_("Segments must be at least 3")); | ||||
| } | } | ||||
| if (rings_num < 3) { | if (rings_num < 3) { | ||||
| Show All 14 Lines | |||||
| void register_node_type_geo_mesh_primitive_uv_sphere() | void register_node_type_geo_mesh_primitive_uv_sphere() | ||||
| { | { | ||||
| namespace file_ns = blender::nodes::node_geo_mesh_primitive_uv_sphere_cc; | namespace file_ns = blender::nodes::node_geo_mesh_primitive_uv_sphere_cc; | ||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| geo_node_type_base( | geo_node_type_base( | ||||
| &ntype, GEO_NODE_MESH_PRIMITIVE_UV_SPHERE, "UV Sphere", NODE_CLASS_GEOMETRY, 0); | &ntype, GEO_NODE_MESH_PRIMITIVE_UV_SPHERE, "UV Sphere", NODE_CLASS_GEOMETRY, 0); | ||||
| ntype.declare = file_ns::geo_node_mesh_primitive_uv_shpere_declare; | ntype.declare = file_ns::node_declare; | ||||
| ntype.geometry_node_execute = file_ns::geo_node_mesh_primitive_uv_sphere_exec; | ntype.geometry_node_execute = file_ns::node_geo_exec; | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||