From 21d774cef3001d06dc72c5666fa54b3cf5a7daec Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Tue, 16 Mar 2021 21:55:35 -0400 Subject: Fixes and cleanup after merge --- source/blender/makesrna/intern/rna_nodetree.c | 1 - .../geometry/nodes/node_geo_mesh_primitive_cone.cc | 30 +++++++++++----------- .../nodes/node_geo_mesh_primitive_uv_sphere.cc | 16 ++++++------ 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index bf6fc08b3b8..04ff181d9b5 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -411,7 +411,6 @@ static EnumPropertyItem rna_node_geometry_mesh_circle_fill_type_items[] = { {GEO_NODE_MESH_CIRCLE_FILL_TRIANGLE_FAN, "TRIANGLE_FAN", 0, "Triangles", ""}, {0, NULL, 0, NULL, NULL}, }; - #endif #define ITEM_ATTRIBUTE \ diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc index ec96f9c1004..4b7177e2e0d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc @@ -282,8 +282,8 @@ Mesh *create_cylinder_or_cone_mesh(const float radius_top, const int verts_num, const GeometryNodeMeshCircleFillType fill_type) { - const bool top_is_point = radius_top != 0.0f; - const bool bottom_is_point = radius_bottom != 0.0f; + const bool top_is_point = radius_top == 0.0f; + const bool bottom_is_point = radius_bottom == 0.0f; /* Handle the case of a line / single point before everything else to avoid * the need to check for it later. */ if (top_is_point && bottom_is_point) { @@ -291,7 +291,7 @@ Mesh *create_cylinder_or_cone_mesh(const float radius_top, Mesh *mesh = BKE_mesh_new_nomain(single_vertex ? 1 : 2, single_vertex ? 0 : 1, 0, 0, 0); copy_v3_v3(mesh->mvert[0].co, float3(0.0f, 0.0f, depth)); if (single_vertex) { - short up[3] = {0, 0, SHRT_MAX}; + const short up[3] = {0, 0, SHRT_MAX}; copy_v3_v3_short(mesh->mvert[0].no, up); return mesh; } @@ -304,15 +304,15 @@ Mesh *create_cylinder_or_cone_mesh(const float radius_top, } Mesh *mesh = BKE_mesh_new_nomain( - vert_total(fill_type, verts_num, !top_is_point, !bottom_is_point), - edge_total(fill_type, verts_num, !top_is_point, !bottom_is_point), + vert_total(fill_type, verts_num, top_is_point, bottom_is_point), + edge_total(fill_type, verts_num, top_is_point, bottom_is_point), 0, - corner_total(fill_type, verts_num, !top_is_point, !bottom_is_point), - face_total(fill_type, verts_num, !top_is_point, !bottom_is_point)); - MutableSpan verts = MutableSpan(mesh->mvert, mesh->totvert); - MutableSpan edges = MutableSpan(mesh->medge, mesh->totedge); - MutableSpan loops = MutableSpan(mesh->mloop, mesh->totloop); - MutableSpan polys = MutableSpan(mesh->mpoly, mesh->totpoly); + corner_total(fill_type, verts_num, top_is_point, bottom_is_point), + face_total(fill_type, verts_num, top_is_point, bottom_is_point)); + MutableSpan verts{mesh->mvert, mesh->totvert}; + MutableSpan loops{mesh->mloop, mesh->totloop}; + MutableSpan edges{mesh->medge, mesh->totedge}; + MutableSpan polys{mesh->mpoly, mesh->totpoly}; /* Calculate vertex positions. */ const int top_verts_start = 0; @@ -331,16 +331,16 @@ Mesh *create_cylinder_or_cone_mesh(const float radius_top, } angle += angle_delta; } - if (!!top_is_point) { + if (top_is_point) { copy_v3_v3(verts[top_verts_start].co, float3(0.0f, 0.0f, depth)); } - if (!!bottom_is_point) { + if (bottom_is_point) { copy_v3_v3(verts[bottom_verts_start].co, float3(0.0f, 0.0f, -depth)); } /* Add center vertices for the triangle fans at the end. */ - const int top_center_vert_index = bottom_verts_start + (!bottom_is_point ? verts_num : 1); - const int bottom_center_vert_index = top_center_vert_index + (!top_is_point ? 1 : 0); + const int top_center_vert_index = bottom_verts_start + (bottom_is_point ? 1 : verts_num); + const int bottom_center_vert_index = top_center_vert_index + (top_is_point ? 0 : 1); if (fill_type == GEO_NODE_MESH_CIRCLE_FILL_TRIANGLE_FAN) { if (!top_is_point) { copy_v3_v3(verts[top_center_vert_index].co, float3(0.0f, 0.0f, depth)); diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc index ae7a338bfdb..da6c8ee0dd1 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc @@ -26,7 +26,7 @@ static bNodeSocketTemplate geo_node_mesh_primitive_uv_sphere_in[] = { {SOCK_INT, N_("Segments"), 32, 0.0f, 0.0f, 0.0f, 3, 1024}, - {SOCK_INT, N_("Rings"), 16, 0.0f, 0.0f, 0.0f, 3, 1024}, + {SOCK_INT, N_("Rings"), 16, 0.0f, 0.0f, 0.0f, 2, 1024}, {SOCK_FLOAT, N_("Radius"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX, PROP_DISTANCE}, {SOCK_VECTOR, N_("Location"), 0.0f, 0.0f, 0.0f, 1.0f, -FLT_MAX, FLT_MAX, PROP_TRANSLATION}, {SOCK_VECTOR, N_("Rotation"), 0.0f, 0.0f, 0.0f, 1.0f, -FLT_MAX, FLT_MAX, PROP_EULER}, @@ -81,8 +81,8 @@ static void calculate_sphere_vertex_data(MutableSpan verts, float phi = 0.0f; const float z = cosf(theta); for (const int UNUSED(segment) : IndexRange(segments)) { - const float x = sinf(theta) * cosf(phi); - const float y = sinf(theta) * sinf(phi); + const float x = std::sin(theta) * std::cos(phi); + const float y = std::sin(theta) * std::sin(phi); copy_v3_v3(verts[vert_index].co, float3(x, y, z) * radius); normal_float_to_short_v3(verts[vert_index].no, float3(x, y, z)); phi += delta_phi; @@ -263,10 +263,10 @@ static Mesh *create_uv_sphere_mesh(const float radius, const int segments, const 0, sphere_corner_total(segments, rings), sphere_face_total(segments, rings)); - MutableSpan verts = MutableSpan(mesh->mvert, mesh->totvert); - MutableSpan edges = MutableSpan(mesh->medge, mesh->totedge); - MutableSpan loops = MutableSpan(mesh->mloop, mesh->totloop); - MutableSpan polys = MutableSpan(mesh->mpoly, mesh->totpoly); + MutableSpan verts{mesh->mvert, mesh->totvert}; + MutableSpan loops{mesh->mloop, mesh->totloop}; + MutableSpan edges{mesh->medge, mesh->totedge}; + MutableSpan polys{mesh->mpoly, mesh->totpoly}; calculate_sphere_vertex_data(verts, radius, segments, rings); @@ -285,7 +285,7 @@ static void geo_node_mesh_primitive_uv_sphere_exec(GeoNodeExecParams params) { const int segments_num = params.extract_input("Segments"); const int rings_num = params.extract_input("Rings"); - if (segments_num < 3 || rings_num < 3) { + if (segments_num < 3 || rings_num < 2) { params.set_output("Geometry", GeometrySet()); return; } -- cgit v1.2.3