Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc
| Show First 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | nodeSetSocketAvailability(count_socket, | ||||
| mode == GEO_NODE_MESH_LINE_MODE_OFFSET || | mode == GEO_NODE_MESH_LINE_MODE_OFFSET || | ||||
| count_mode == GEO_NODE_MESH_LINE_COUNT_TOTAL); | count_mode == GEO_NODE_MESH_LINE_COUNT_TOTAL); | ||||
| } | } | ||||
| namespace blender::nodes { | namespace blender::nodes { | ||||
| static void fill_edge_data(MutableSpan<MEdge> edges) | static void fill_edge_data(MutableSpan<MEdge> edges) | ||||
| { | { | ||||
| for (const int i : edges.index_range()) { | for (const int i : iter_indices(edges)) { | ||||
| edges[i].v1 = i; | edges[i].v1 = i; | ||||
| edges[i].v2 = i + 1; | edges[i].v2 = i + 1; | ||||
| edges[i].flag |= ME_LOOSEEDGE; | edges[i].flag |= ME_LOOSEEDGE; | ||||
| } | } | ||||
| } | } | ||||
| static Mesh *create_line_mesh(const float3 start, const float3 delta, const int count) | static Mesh *create_line_mesh(const float3 start, const float3 delta, const int count) | ||||
| { | { | ||||
| if (count < 1) { | if (count < 1) { | ||||
| return nullptr; | return nullptr; | ||||
| } | } | ||||
| Mesh *mesh = BKE_mesh_new_nomain(count, count - 1, 0, 0, 0); | Mesh *mesh = BKE_mesh_new_nomain(count, count - 1, 0, 0, 0); | ||||
| MutableSpan<MVert> verts{mesh->mvert, mesh->totvert}; | MutableSpan<MVert> verts{mesh->mvert, mesh->totvert}; | ||||
| MutableSpan<MEdge> edges{mesh->medge, mesh->totedge}; | MutableSpan<MEdge> edges{mesh->medge, mesh->totedge}; | ||||
| short normal[3]; | short normal[3]; | ||||
| normal_float_to_short_v3(normal, delta.normalized()); | normal_float_to_short_v3(normal, delta.normalized()); | ||||
| float3 co = start; | float3 co = start; | ||||
| for (const int i : verts.index_range()) { | for (const int i : iter_indices(verts)) { | ||||
| copy_v3_v3(verts[i].co, co); | copy_v3_v3(verts[i].co, co); | ||||
| copy_v3_v3_short(verts[i].no, normal); | copy_v3_v3_short(verts[i].no, normal); | ||||
| co += delta; | co += delta; | ||||
| } | } | ||||
| fill_edge_data(edges); | fill_edge_data(edges); | ||||
| return mesh; | return mesh; | ||||
| ▲ Show 20 Lines • Show All 57 Lines • Show Last 20 Lines | |||||