Differential D15982 Diff 57482 source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_circle.cc
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_circle.cc
| Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | |||||
| const GeometryNodeMeshCircleFillType fill_type) | const GeometryNodeMeshCircleFillType fill_type) | ||||
| { | { | ||||
| Mesh *mesh = BKE_mesh_new_nomain(circle_vert_total(fill_type, verts_num), | Mesh *mesh = BKE_mesh_new_nomain(circle_vert_total(fill_type, verts_num), | ||||
| circle_edge_total(fill_type, verts_num), | circle_edge_total(fill_type, verts_num), | ||||
| 0, | 0, | ||||
| circle_corner_total(fill_type, verts_num), | circle_corner_total(fill_type, verts_num), | ||||
| circle_face_total(fill_type, verts_num)); | circle_face_total(fill_type, verts_num)); | ||||
| BKE_id_material_eval_ensure_default_slot(&mesh->id); | BKE_id_material_eval_ensure_default_slot(&mesh->id); | ||||
| MutableSpan<MVert> verts = mesh->verts_for_write(); | MutableSpan<float3> positions = mesh->positions_for_write(); | ||||
| MutableSpan<MEdge> edges = mesh->edges_for_write(); | MutableSpan<MEdge> edges = mesh->edges_for_write(); | ||||
| MutableSpan<MPoly> polys = mesh->polys_for_write(); | MutableSpan<MPoly> polys = mesh->polys_for_write(); | ||||
| MutableSpan<MLoop> loops = mesh->loops_for_write(); | MutableSpan<MLoop> loops = mesh->loops_for_write(); | ||||
| /* Assign vertex coordinates. */ | /* Assign vertex coordinates. */ | ||||
| const float angle_delta = 2.0f * (M_PI / float(verts_num)); | const float angle_delta = 2.0f * (M_PI / float(verts_num)); | ||||
| for (const int i : IndexRange(verts_num)) { | for (const int i : IndexRange(verts_num)) { | ||||
| const float angle = i * angle_delta; | const float angle = i * angle_delta; | ||||
| copy_v3_v3(verts[i].co, float3(std::cos(angle) * radius, std::sin(angle) * radius, 0.0f)); | positions[i] = float3(std::cos(angle) * radius, std::sin(angle) * radius, 0.0f); | ||||
| } | } | ||||
| if (fill_type == GEO_NODE_MESH_CIRCLE_FILL_TRIANGLE_FAN) { | if (fill_type == GEO_NODE_MESH_CIRCLE_FILL_TRIANGLE_FAN) { | ||||
| copy_v3_v3(verts.last().co, float3(0)); | positions.last() = float3(0); | ||||
| } | } | ||||
| /* Create outer edges. */ | /* Create outer edges. */ | ||||
| const short edge_flag = (fill_type == GEO_NODE_MESH_CIRCLE_FILL_NONE) ? | const short edge_flag = (fill_type == GEO_NODE_MESH_CIRCLE_FILL_NONE) ? | ||||
| ME_LOOSEEDGE : | ME_LOOSEEDGE : | ||||
| ME_EDGEDRAW; /* NGON or TRIANGLE_FAN */ | ME_EDGEDRAW; /* NGON or TRIANGLE_FAN */ | ||||
| for (const int i : IndexRange(verts_num)) { | for (const int i : IndexRange(verts_num)) { | ||||
| MEdge &edge = edges[i]; | MEdge &edge = edges[i]; | ||||
| ▲ Show 20 Lines • Show All 83 Lines • Show Last 20 Lines | |||||