Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/intern/gpu_buffers.c
| Show First 20 Lines • Show All 361 Lines • ▼ Show 20 Lines | void GPU_pbvh_mesh_buffers_update(GPU_PBVH_Buffers *buffers, | ||||
| const MLoopTri *lt = &buffers->looptri[buffers->face_indices[0]]; | const MLoopTri *lt = &buffers->looptri[buffers->face_indices[0]]; | ||||
| const MPoly *mp = &buffers->mpoly[lt->poly]; | const MPoly *mp = &buffers->mpoly[lt->poly]; | ||||
| buffers->material_index = mp->mat_nr; | buffers->material_index = mp->mat_nr; | ||||
| buffers->show_mask = !empty_mask; | buffers->show_mask = !empty_mask; | ||||
| buffers->mvert = mvert; | buffers->mvert = mvert; | ||||
| } | } | ||||
| static bool gpu_pbvh_is_looptri_visible(const MLoopTri *lt, | |||||
| const MVert *mvert, | |||||
| const MLoop *mloop, | |||||
| const int *sculpt_face_sets) | |||||
| { | |||||
| return (!paint_is_face_hidden(lt, mvert, mloop) && sculpt_face_sets && | |||||
| sculpt_face_sets[lt->poly] > 0); | |||||
| } | |||||
| /* Threaded - do not call any functions that use OpenGL calls! */ | /* Threaded - do not call any functions that use OpenGL calls! */ | ||||
| GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build(const int (*face_vert_indices)[3], | GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build(const int (*face_vert_indices)[3], | ||||
| const MPoly *mpoly, | const MPoly *mpoly, | ||||
| const MLoop *mloop, | const MLoop *mloop, | ||||
| const MLoopTri *looptri, | const MLoopTri *looptri, | ||||
| const MVert *mvert, | const MVert *mvert, | ||||
| const int *face_indices, | const int *face_indices, | ||||
| const int *sculpt_face_sets, | const int *sculpt_face_sets, | ||||
| Show All 9 Lines | GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build(const int (*face_vert_indices)[3], | ||||
| /* smooth or flat for all */ | /* smooth or flat for all */ | ||||
| buffers->smooth = mpoly[looptri[face_indices[0]].poly].flag & ME_SMOOTH; | buffers->smooth = mpoly[looptri[face_indices[0]].poly].flag & ME_SMOOTH; | ||||
| buffers->show_mask = false; | buffers->show_mask = false; | ||||
| /* Count the number of visible triangles */ | /* Count the number of visible triangles */ | ||||
| for (i = 0, tottri = 0; i < face_indices_len; i++) { | for (i = 0, tottri = 0; i < face_indices_len; i++) { | ||||
| const MLoopTri *lt = &looptri[face_indices[i]]; | const MLoopTri *lt = &looptri[face_indices[i]]; | ||||
| if (!paint_is_face_hidden(lt, mvert, mloop) && sculpt_face_sets && | if (gpu_pbvh_is_looptri_visible(lt, mvert, mloop, sculpt_face_sets)) { | ||||
| sculpt_face_sets[lt->poly] > 0) { | |||||
| int r_edges[3]; | int r_edges[3]; | ||||
| BKE_mesh_looptri_get_real_edges(mesh, lt, r_edges); | BKE_mesh_looptri_get_real_edges(mesh, lt, r_edges); | ||||
| for (int j = 0; j < 3; j++) { | for (int j = 0; j < 3; j++) { | ||||
| if (r_edges[j] != -1) { | if (r_edges[j] != -1) { | ||||
| tot_real_edges++; | tot_real_edges++; | ||||
| } | } | ||||
| } | } | ||||
| tottri++; | tottri++; | ||||
| Show All 20 Lines | if (buffers->smooth) { | ||||
| GPUIndexBufBuilder elb, elb_lines; | GPUIndexBufBuilder elb, elb_lines; | ||||
| GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, tottri, INT_MAX); | GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, tottri, INT_MAX); | ||||
| GPU_indexbuf_init(&elb_lines, GPU_PRIM_LINES, tot_real_edges, INT_MAX); | GPU_indexbuf_init(&elb_lines, GPU_PRIM_LINES, tot_real_edges, INT_MAX); | ||||
| for (i = 0; i < face_indices_len; i++) { | for (i = 0; i < face_indices_len; i++) { | ||||
| const MLoopTri *lt = &looptri[face_indices[i]]; | const MLoopTri *lt = &looptri[face_indices[i]]; | ||||
| /* Skip hidden faces */ | /* Skip hidden faces */ | ||||
| if (paint_is_face_hidden(lt, mvert, mloop)) { | if (!gpu_pbvh_is_looptri_visible(lt, mvert, mloop, sculpt_face_sets)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| GPU_indexbuf_add_tri_verts(&elb, UNPACK3(face_vert_indices[i])); | GPU_indexbuf_add_tri_verts(&elb, UNPACK3(face_vert_indices[i])); | ||||
| int r_edges[3]; | int r_edges[3]; | ||||
| BKE_mesh_looptri_get_real_edges(mesh, lt, r_edges); | BKE_mesh_looptri_get_real_edges(mesh, lt, r_edges); | ||||
| if (r_edges[0] != -1) { | if (r_edges[0] != -1) { | ||||
| Show All 14 Lines | else { | ||||
| GPUIndexBufBuilder elb_lines; | GPUIndexBufBuilder elb_lines; | ||||
| GPU_indexbuf_init(&elb_lines, GPU_PRIM_LINES, tot_real_edges, INT_MAX); | GPU_indexbuf_init(&elb_lines, GPU_PRIM_LINES, tot_real_edges, INT_MAX); | ||||
| int vert_idx = 0; | int vert_idx = 0; | ||||
| for (i = 0; i < face_indices_len; i++) { | for (i = 0; i < face_indices_len; i++) { | ||||
| const MLoopTri *lt = &looptri[face_indices[i]]; | const MLoopTri *lt = &looptri[face_indices[i]]; | ||||
| /* Skip hidden faces */ | /* Skip hidden faces */ | ||||
| if (paint_is_face_hidden(lt, mvert, mloop) || | if (!gpu_pbvh_is_looptri_visible(lt, mvert, mloop, sculpt_face_sets)) { | ||||
| (sculpt_face_sets && sculpt_face_sets[lt->poly] < 0)) { | |||||
| continue; | continue; | ||||
| } | } | ||||
| int r_edges[3]; | int r_edges[3]; | ||||
| BKE_mesh_looptri_get_real_edges(mesh, lt, r_edges); | BKE_mesh_looptri_get_real_edges(mesh, lt, r_edges); | ||||
| if (r_edges[0] != -1) { | if (r_edges[0] != -1) { | ||||
| GPU_indexbuf_add_line_verts(&elb_lines, vert_idx * 3 + 0, vert_idx * 3 + 1); | GPU_indexbuf_add_line_verts(&elb_lines, vert_idx * 3 + 0, vert_idx * 3 + 1); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 681 Lines • Show Last 20 Lines | |||||