Sculpt: Fix wireframe drawing
With this commit sculpt mode draws the real mesh wireframe instead of the triangulated version by ignoring non real edges when building the PBVH GPU buffers Reviewed By: brecht Differential Revision: https://developer.blender.org/D6032
This commit is contained in:
parent
e846852862
commit
d95bb087d0
|
@ -36,6 +36,7 @@ struct CustomData;
|
|||
struct DMFlagMat;
|
||||
struct GPU_PBVH_Buffers;
|
||||
struct IsectRayPrecalc;
|
||||
struct Mesh;
|
||||
struct MLoop;
|
||||
struct MLoopTri;
|
||||
struct MPoly;
|
||||
|
@ -89,6 +90,7 @@ typedef void (*BKE_pbvh_SearchNearestCallback)(PBVHNode *node, void *data, float
|
|||
|
||||
PBVH *BKE_pbvh_new(void);
|
||||
void BKE_pbvh_build_mesh(PBVH *bvh,
|
||||
const struct Mesh *mesh,
|
||||
const struct MPoly *mpoly,
|
||||
const struct MLoop *mloop,
|
||||
struct MVert *verts,
|
||||
|
|
|
@ -1489,6 +1489,7 @@ static PBVH *build_pbvh_from_regular_mesh(Object *ob, Mesh *me_eval_deform)
|
|||
BKE_mesh_recalc_looptri(me->mloop, me->mpoly, me->mvert, me->totloop, me->totpoly, looptri);
|
||||
|
||||
BKE_pbvh_build_mesh(pbvh,
|
||||
me,
|
||||
me->mpoly,
|
||||
me->mloop,
|
||||
me->mvert,
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "BLI_ghash.h"
|
||||
#include "BLI_task.h"
|
||||
|
||||
#include "DNA_mesh_types.h"
|
||||
#include "DNA_meshdata_types.h"
|
||||
|
||||
#include "BKE_pbvh.h"
|
||||
|
@ -533,6 +534,7 @@ static void pbvh_build(PBVH *bvh, BB *cb, BBC *prim_bbc, int totprim)
|
|||
* (which means it may rewrite it if needed, see #BKE_pbvh_vert_coords_apply().
|
||||
*/
|
||||
void BKE_pbvh_build_mesh(PBVH *bvh,
|
||||
const Mesh *mesh,
|
||||
const MPoly *mpoly,
|
||||
const MLoop *mloop,
|
||||
MVert *verts,
|
||||
|
@ -545,6 +547,7 @@ void BKE_pbvh_build_mesh(PBVH *bvh,
|
|||
BBC *prim_bbc = NULL;
|
||||
BB cb;
|
||||
|
||||
bvh->mesh = mesh;
|
||||
bvh->type = PBVH_FACES;
|
||||
bvh->mpoly = mpoly;
|
||||
bvh->mloop = mloop;
|
||||
|
@ -1222,7 +1225,8 @@ static void pbvh_update_draw_buffer_cb(void *__restrict userdata,
|
|||
bvh->looptri,
|
||||
bvh->verts,
|
||||
node->prim_indices,
|
||||
node->totprim);
|
||||
node->totprim,
|
||||
bvh->mesh);
|
||||
break;
|
||||
case PBVH_BMESH:
|
||||
node->draw_buffers = GPU_pbvh_bmesh_buffers_build(bvh->flags &
|
||||
|
|
|
@ -127,6 +127,7 @@ struct PBVH {
|
|||
int leaf_limit;
|
||||
|
||||
/* Mesh data */
|
||||
const struct Mesh *mesh;
|
||||
MVert *verts;
|
||||
const MPoly *mpoly;
|
||||
const MLoop *mloop;
|
||||
|
|
|
@ -31,6 +31,7 @@ struct CCGElem;
|
|||
struct CCGKey;
|
||||
struct DMFlagMat;
|
||||
struct GSet;
|
||||
struct Mesh;
|
||||
struct MLoop;
|
||||
struct MLoopCol;
|
||||
struct MLoopTri;
|
||||
|
@ -49,7 +50,8 @@ GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build(const int (*face_vert_indices)[3],
|
|||
const struct MLoopTri *looptri,
|
||||
const struct MVert *verts,
|
||||
const int *face_indices,
|
||||
const int face_indices_len);
|
||||
const int face_indices_len,
|
||||
const struct Mesh *mesh);
|
||||
|
||||
GPU_PBVH_Buffers *GPU_pbvh_grid_buffers_build(int totgrid, unsigned int **grid_hidden);
|
||||
|
||||
|
|
|
@ -316,10 +316,12 @@ GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build(const int (*face_vert_indices)[3],
|
|||
const MLoopTri *looptri,
|
||||
const MVert *mvert,
|
||||
const int *face_indices,
|
||||
const int face_indices_len)
|
||||
const int face_indices_len,
|
||||
const struct Mesh *mesh)
|
||||
{
|
||||
GPU_PBVH_Buffers *buffers;
|
||||
int i, tottri;
|
||||
int tot_real_edges = 0;
|
||||
|
||||
buffers = MEM_callocN(sizeof(GPU_PBVH_Buffers), "GPU_Buffers");
|
||||
|
||||
|
@ -332,6 +334,13 @@ GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build(const int (*face_vert_indices)[3],
|
|||
for (i = 0, tottri = 0; i < face_indices_len; i++) {
|
||||
const MLoopTri *lt = &looptri[face_indices[i]];
|
||||
if (!paint_is_face_hidden(lt, mvert, mloop)) {
|
||||
int r_edges[3];
|
||||
BKE_mesh_looptri_get_real_edges(mesh, lt, r_edges);
|
||||
for (int j = 0; j < 3; j++) {
|
||||
if (r_edges[j] != -1) {
|
||||
tot_real_edges++;
|
||||
}
|
||||
}
|
||||
tottri++;
|
||||
}
|
||||
}
|
||||
|
@ -355,7 +364,7 @@ GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build(const int (*face_vert_indices)[3],
|
|||
/* Fill the triangle and line buffers. */
|
||||
GPUIndexBufBuilder elb, elb_lines;
|
||||
GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, tottri, INT_MAX);
|
||||
GPU_indexbuf_init(&elb_lines, GPU_PRIM_LINES, tottri * 3, INT_MAX);
|
||||
GPU_indexbuf_init(&elb_lines, GPU_PRIM_LINES, tot_real_edges, INT_MAX);
|
||||
|
||||
for (i = 0; i < face_indices_len; i++) {
|
||||
const MLoopTri *lt = &looptri[face_indices[i]];
|
||||
|
@ -366,11 +375,18 @@ GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build(const int (*face_vert_indices)[3],
|
|||
}
|
||||
|
||||
GPU_indexbuf_add_tri_verts(&elb, UNPACK3(face_vert_indices[i]));
|
||||
int r_edges[3];
|
||||
BKE_mesh_looptri_get_real_edges(mesh, lt, r_edges);
|
||||
|
||||
/* TODO skip "non-real" edges. */
|
||||
GPU_indexbuf_add_line_verts(&elb_lines, face_vert_indices[i][0], face_vert_indices[i][1]);
|
||||
GPU_indexbuf_add_line_verts(&elb_lines, face_vert_indices[i][1], face_vert_indices[i][2]);
|
||||
GPU_indexbuf_add_line_verts(&elb_lines, face_vert_indices[i][2], face_vert_indices[i][0]);
|
||||
if (r_edges[0] != -1) {
|
||||
GPU_indexbuf_add_line_verts(&elb_lines, face_vert_indices[i][0], face_vert_indices[i][1]);
|
||||
}
|
||||
if (r_edges[1] != -1) {
|
||||
GPU_indexbuf_add_line_verts(&elb_lines, face_vert_indices[i][1], face_vert_indices[i][2]);
|
||||
}
|
||||
if (r_edges[2] != -1) {
|
||||
GPU_indexbuf_add_line_verts(&elb_lines, face_vert_indices[i][2], face_vert_indices[i][0]);
|
||||
}
|
||||
}
|
||||
buffers->index_buf = GPU_indexbuf_build(&elb);
|
||||
buffers->index_lines_buf = GPU_indexbuf_build(&elb_lines);
|
||||
|
@ -378,7 +394,7 @@ GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build(const int (*face_vert_indices)[3],
|
|||
else {
|
||||
/* Fill the only the line buffer. */
|
||||
GPUIndexBufBuilder elb_lines;
|
||||
GPU_indexbuf_init(&elb_lines, GPU_PRIM_LINES, tottri * 3, INT_MAX);
|
||||
GPU_indexbuf_init(&elb_lines, GPU_PRIM_LINES, tot_real_edges, INT_MAX);
|
||||
int vert_idx = 0;
|
||||
|
||||
for (i = 0; i < face_indices_len; i++) {
|
||||
|
@ -389,10 +405,18 @@ GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build(const int (*face_vert_indices)[3],
|
|||
continue;
|
||||
}
|
||||
|
||||
/* TODO skip "non-real" edges. */
|
||||
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 + 1, vert_idx * 3 + 2);
|
||||
GPU_indexbuf_add_line_verts(&elb_lines, vert_idx * 3 + 2, vert_idx * 3 + 0);
|
||||
int r_edges[3];
|
||||
BKE_mesh_looptri_get_real_edges(mesh, lt, r_edges);
|
||||
if (r_edges[0] != -1) {
|
||||
GPU_indexbuf_add_line_verts(&elb_lines, vert_idx * 3 + 0, vert_idx * 3 + 1);
|
||||
}
|
||||
if (r_edges[1] != -1) {
|
||||
GPU_indexbuf_add_line_verts(&elb_lines, vert_idx * 3 + 1, vert_idx * 3 + 2);
|
||||
}
|
||||
if (r_edges[2] != -1) {
|
||||
GPU_indexbuf_add_line_verts(&elb_lines, vert_idx * 3 + 2, vert_idx * 3 + 0);
|
||||
}
|
||||
|
||||
vert_idx++;
|
||||
}
|
||||
buffers->index_lines_buf = GPU_indexbuf_build(&elb_lines);
|
||||
|
|
Loading…
Reference in New Issue