Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/draw_pbvh.cc
| Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | |||||
| foreach_faces([&](int /*buffer_i*/, int /*tri_i*/, int vertex_i, const MLoopTri *tri) { | foreach_faces([&](int /*buffer_i*/, int /*tri_i*/, int vertex_i, const MLoopTri *tri) { | ||||
| const MPoly *mp = args->mpoly + tri->poly; | const MPoly *mp = args->mpoly + tri->poly; | ||||
| if (tri->poly != last_poly) { | if (tri->poly != last_poly) { | ||||
| last_poly = tri->poly; | last_poly = tri->poly; | ||||
| if (!(mp->flag & ME_SMOOTH)) { | if (!(mp->flag & ME_SMOOTH)) { | ||||
| smooth = true; | smooth = true; | ||||
| BKE_mesh_calc_poly_normal(mp, args->mloop + mp->loopstart, args->vert_positions, fno); | BKE_mesh_calc_poly_normal( | ||||
| mp, &args->corner_verts[mp->loopstart], args->vert_positions, fno); | |||||
| normal_float_to_short_v3(no, fno); | normal_float_to_short_v3(no, fno); | ||||
| } | } | ||||
| else { | else { | ||||
| smooth = false; | smooth = false; | ||||
| } | } | ||||
| } | } | ||||
| if (!smooth) { | if (!smooth) { | ||||
| ▲ Show 20 Lines • Show All 184 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| } | } | ||||
| void fill_vbo_faces(PBVHVbo &vbo, PBVH_GPU_Args *args) | void fill_vbo_faces(PBVHVbo &vbo, PBVH_GPU_Args *args) | ||||
| { | { | ||||
| auto foreach_faces = | auto foreach_faces = | ||||
| [&](std::function<void(int buffer_i, int tri_i, int vertex_i, const MLoopTri *tri)> func) { | [&](std::function<void(int buffer_i, int tri_i, int vertex_i, const MLoopTri *tri)> func) { | ||||
| int buffer_i = 0; | int buffer_i = 0; | ||||
| const MLoop *mloop = args->mloop; | const int *corner_verts = args->corner_verts; | ||||
| for (int i : IndexRange(args->totprim)) { | for (int i : IndexRange(args->totprim)) { | ||||
| int face_index = args->mlooptri[args->prim_indices[i]].poly; | int face_index = args->mlooptri[args->prim_indices[i]].poly; | ||||
| if (args->hide_poly && args->hide_poly[face_index]) { | if (args->hide_poly && args->hide_poly[face_index]) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| const MLoopTri *tri = args->mlooptri + args->prim_indices[i]; | const MLoopTri *tri = args->mlooptri + args->prim_indices[i]; | ||||
| for (int j : IndexRange(3)) { | for (int j : IndexRange(3)) { | ||||
| func(buffer_i, j, mloop[tri->tri[j]].v, tri); | func(buffer_i, j, corner_verts[tri->tri[j]], tri); | ||||
| buffer_i++; | buffer_i++; | ||||
| } | } | ||||
| } | } | ||||
| }; | }; | ||||
| int totvert = 0; | int totvert = 0; | ||||
| foreach_faces([&totvert](int, int, int, const MLoopTri *) { totvert++; }); | foreach_faces([&totvert](int, int, int, const MLoopTri *) { totvert++; }); | ||||
| ▲ Show 20 Lines • Show All 184 Lines • ▼ Show 20 Lines | |||||
| for (int i = 0; i < args->totprim; i++) { | for (int i = 0; i < args->totprim; i++) { | ||||
| const MLoopTri *lt = args->mlooptri + args->prim_indices[i]; | const MLoopTri *lt = args->mlooptri + args->prim_indices[i]; | ||||
| if (args->hide_poly && args->hide_poly[lt->poly]) { | if (args->hide_poly && args->hide_poly[lt->poly]) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| int r_edges[3]; | int r_edges[3]; | ||||
| BKE_mesh_looptri_get_real_edges(edges.data(), args->mloop, lt, r_edges); | BKE_mesh_looptri_get_real_edges( | ||||
| edges.data(), args->corner_verts, args->corner_edges, lt, r_edges); | |||||
| if (r_edges[0] != -1) { | if (r_edges[0] != -1) { | ||||
| edge_count++; | edge_count++; | ||||
| } | } | ||||
| if (r_edges[1] != -1) { | if (r_edges[1] != -1) { | ||||
| edge_count++; | edge_count++; | ||||
| } | } | ||||
| if (r_edges[2] != -1) { | if (r_edges[2] != -1) { | ||||
| edge_count++; | edge_count++; | ||||
| } | } | ||||
| } | } | ||||
| GPUIndexBufBuilder elb_lines; | GPUIndexBufBuilder elb_lines; | ||||
| GPU_indexbuf_init(&elb_lines, GPU_PRIM_LINES, edge_count * 2, INT_MAX); | GPU_indexbuf_init(&elb_lines, GPU_PRIM_LINES, edge_count * 2, INT_MAX); | ||||
| int vertex_i = 0; | int vertex_i = 0; | ||||
| for (int i = 0; i < args->totprim; i++) { | for (int i = 0; i < args->totprim; i++) { | ||||
| const MLoopTri *lt = args->mlooptri + args->prim_indices[i]; | const MLoopTri *lt = args->mlooptri + args->prim_indices[i]; | ||||
| if (args->hide_poly && args->hide_poly[lt->poly]) { | if (args->hide_poly && args->hide_poly[lt->poly]) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| int r_edges[3]; | int r_edges[3]; | ||||
| BKE_mesh_looptri_get_real_edges(edges.data(), args->mloop, lt, r_edges); | BKE_mesh_looptri_get_real_edges( | ||||
| edges.data(), args->corner_verts, args->corner_edges, lt, r_edges); | |||||
| if (r_edges[0] != -1) { | if (r_edges[0] != -1) { | ||||
| GPU_indexbuf_add_line_verts(&elb_lines, vertex_i, vertex_i + 1); | GPU_indexbuf_add_line_verts(&elb_lines, vertex_i, vertex_i + 1); | ||||
| } | } | ||||
| if (r_edges[1] != -1) { | if (r_edges[1] != -1) { | ||||
| GPU_indexbuf_add_line_verts(&elb_lines, vertex_i + 1, vertex_i + 2); | GPU_indexbuf_add_line_verts(&elb_lines, vertex_i + 1, vertex_i + 2); | ||||
| } | } | ||||
| if (r_edges[2] != -1) { | if (r_edges[2] != -1) { | ||||
| ▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines | |||||