diff options
author | Jeroen Bakker <j.bakker@atmind.nl> | 2019-04-16 15:00:16 +0300 |
---|---|---|
committer | Jeroen Bakker <j.bakker@atmind.nl> | 2019-04-23 13:05:33 +0300 |
commit | ee701baff8caf6d184fa245e170c1e67981e2608 (patch) | |
tree | 0e84a0829141682cedfdf9770e755a3e9f833282 /source/blender/blenkernel/intern | |
parent | c9ed39925a51fc421a734027c2ef386157392f3b (diff) |
Workbench: Support Active Vertex Color
Currently it is not possible to view the vertex colors of an object. To
optimize the workflow, workbench will need to support Vertex Colors.
The Vertex Colors is a new option in `shading->color_type`. When objects
do not have vertex color, the objects will be rendered with the
`V3D_SHADING_OBJECT_COLOR`.
In order to support vertex colors in workbench the current texture/solid
shading structure is migrated to a primary shaders and fallback shaders.
Fix: T57000
Reviewers: brecht, fclem
Differential Revision: https://developer.blender.org/D4694
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/cdderivedmesh.c | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/paint.c | 11 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/pbvh.c | 13 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/pbvh_intern.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/subsurf_ccg.c | 1 |
5 files changed, 21 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index e41f7335afb..ea3834be68a 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -296,6 +296,7 @@ static PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm) me->mvert, me->totvert, &me->vdata, + &me->ldata, looptri, looptris_num); diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index 00b3c86e144..7e8e724cfcc 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -1379,8 +1379,15 @@ 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->mpoly, me->mloop, me->mvert, me->totvert, &me->vdata, looptri, looptris_num); + BKE_pbvh_build_mesh(pbvh, + me->mpoly, + me->mloop, + me->mvert, + me->totvert, + &me->vdata, + &me->ldata, + looptri, + looptris_num); pbvh_show_diffuse_color_set(pbvh, ob->sculpt->show_diffuse_color); pbvh_show_mask_set(pbvh, ob->sculpt->show_mask); diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c index d0591b3c7e4..0a82d086862 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -542,6 +542,7 @@ void BKE_pbvh_build_mesh(PBVH *bvh, MVert *verts, int totvert, struct CustomData *vdata, + struct CustomData *ldata, const MLoopTri *looptri, int looptri_num) { @@ -557,6 +558,7 @@ void BKE_pbvh_build_mesh(PBVH *bvh, bvh->totvert = totvert; bvh->leaf_limit = LEAF_LIMIT; bvh->vdata = vdata; + bvh->ldata = ldata; BB_reset(&cb); @@ -1162,14 +1164,15 @@ void pbvh_update_BB_redraw(PBVH *bvh, PBVHNode **nodes, int totnode, int flag) BLI_task_parallel_range(0, totnode, &data, pbvh_update_BB_redraw_task_cb, &settings); } -static int pbvh_get_buffers_update_flags(PBVH *bvh) +static int pbvh_get_buffers_update_flags(PBVH *bvh, bool show_vcol) { int update_flags = 0; update_flags |= bvh->show_mask ? GPU_PBVH_BUFFERS_SHOW_MASK : 0; + update_flags |= show_vcol ? GPU_PBVH_BUFFERS_SHOW_VCOL : 0; return update_flags; } -static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode) +static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode, bool show_vcol) { /* can't be done in parallel with OpenGL */ for (int n = 0; n < totnode; n++) { @@ -1200,7 +1203,7 @@ static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode) } if (node->flag & PBVH_UpdateDrawBuffers) { - const int update_flags = pbvh_get_buffers_update_flags(bvh); + const int update_flags = pbvh_get_buffers_update_flags(bvh, show_vcol); switch (bvh->type) { case PBVH_GRIDS: GPU_pbvh_grid_buffers_update(node->draw_buffers, @@ -1217,6 +1220,7 @@ static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode) node->vert_indices, node->uniq_verts + node->face_verts, CustomData_get_layer(bvh->vdata, CD_PAINT_MASK), + CustomData_get_layer(bvh->ldata, CD_MLOOPCOL), node->face_vert_indices, update_flags); break; @@ -2229,6 +2233,7 @@ void BKE_pbvh_draw_cb(PBVH *bvh, bool fast, bool wires, bool only_mask, + bool show_vcol, void (*draw_fn)(void *user_data, GPUBatch *batch), void *user_data) { @@ -2249,7 +2254,7 @@ void BKE_pbvh_draw_cb(PBVH *bvh, &totnode); pbvh_update_normals(bvh, nodes, totnode, fnors); - pbvh_update_draw_buffers(bvh, nodes, totnode); + pbvh_update_draw_buffers(bvh, nodes, totnode, show_vcol); if (nodes) { MEM_freeN(nodes); diff --git a/source/blender/blenkernel/intern/pbvh_intern.h b/source/blender/blenkernel/intern/pbvh_intern.h index 5fc41c560b2..74d7312e6a7 100644 --- a/source/blender/blenkernel/intern/pbvh_intern.h +++ b/source/blender/blenkernel/intern/pbvh_intern.h @@ -132,6 +132,7 @@ struct PBVH { const MLoop *mloop; const MLoopTri *looptri; CustomData *vdata; + CustomData *ldata; /* Grid Data */ CCGKey gridkey; diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 35acbbfda3d..a58d1eaff3e 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -2361,6 +2361,7 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm) me->mvert, me->totvert, &me->vdata, + &me->ldata, looptri, looptris_num); |