diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-07-12 17:27:06 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-07-12 18:59:44 +0300 |
commit | b4988d01cbe9c850a365604967bd3a5e03fc9a72 (patch) | |
tree | 147a8bb95d09b9c1fd0efef6c4d09d34df85783e /source/blender/draw/intern/draw_cache_impl_mesh.c | |
parent | 95a7a0a06ebc7c88bc56c90bb4edfeef302694b7 (diff) |
DwM: Option to use final material over mode shading
Support using full material shading in sculpt & paint modes mode.
Access 'Full Shading' from the display panel when in paint modes.
Diffstat (limited to 'source/blender/draw/intern/draw_cache_impl_mesh.c')
-rw-r--r-- | source/blender/draw/intern/draw_cache_impl_mesh.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c index ae0e62809bb..f48d739f11b 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.c +++ b/source/blender/draw/intern/draw_cache_impl_mesh.c @@ -1494,6 +1494,9 @@ typedef struct MeshBatchCache { int vert_len; int mat_len; bool is_editmode; + + /* XXX, only keep for as long as sculpt mode uses shaded drawing. */ + bool is_sculpt_points_tag; } MeshBatchCache; /* Gwn_Batch cache management. */ @@ -1603,6 +1606,9 @@ void DRW_mesh_batch_cache_dirty(Mesh *me, int mode) * and not free the entire cache. */ cache->is_really_dirty = true; break; + case BKE_MESH_BATCH_DIRTY_SCULPT_COORDS: + cache->is_sculpt_points_tag = true; + break; default: BLI_assert(0); } @@ -3433,6 +3439,34 @@ Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_verts(Mesh *me) return cache->overlay_weight_verts; } +/** + * Needed for when we draw with shaded data. + */ +void DRW_mesh_cache_sculpt_coords_ensure(Mesh *me) +{ + if (me->batch_cache) { + MeshBatchCache *cache = mesh_batch_cache_get(me); + if (cache && cache->pos_with_normals && cache->is_sculpt_points_tag) { + + const int datatype = MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY; + MeshRenderData *rdata = mesh_render_data_create(me, datatype); + + Gwn_VertBuf *pos_with_normals = cache->pos_with_normals; + cache->pos_with_normals = NULL; + GWN_vertbuf_clear(pos_with_normals); + Gwn_VertBuf *vbo = mesh_batch_cache_get_tri_pos_and_normals(rdata, cache); + *pos_with_normals = *vbo; + GWN_vertformat_copy(&pos_with_normals->format, &vbo->format); + + free(vbo); + cache->pos_with_normals = pos_with_normals; + + mesh_render_data_free(rdata); + } + cache->is_sculpt_points_tag = false; + } +} + /** \} */ #undef MESH_RENDER_FUNCTION |