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 | |
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')
-rw-r--r-- | source/blender/draw/intern/DRW_render.h | 3 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_cache.c | 8 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_cache.h | 2 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_cache_impl.h | 2 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_cache_impl_mesh.c | 34 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_manager.c | 32 |
6 files changed, 75 insertions, 6 deletions
diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index 51145b15237..ee1e14f8898 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -356,7 +356,8 @@ void DRW_lamp_engine_data_free(struct LampEngineData *led); /* Settings */ bool DRW_object_is_renderable(struct Object *ob); -bool DRW_object_is_flat_normal(struct Object *ob); +bool DRW_object_is_flat_normal(const struct Object *ob); +int DRW_object_is_mode_shade(const struct Object *ob); /* Draw commands */ void DRW_draw_pass(DRWPass *pass); diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index b62559fdb0e..c0338de3d54 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -2287,6 +2287,14 @@ Gwn_Batch *DRW_cache_mesh_verts_weight_overlay_get(Object *ob) return DRW_mesh_batch_cache_get_weight_overlay_verts(me); } +void DRW_cache_mesh_sculpt_coords_ensure(Object *ob) +{ + BLI_assert(ob->type == OB_MESH); + + Mesh *me = ob->data; + DRW_mesh_cache_sculpt_coords_ensure(me); +} + /** \} */ /* -------------------------------------------------------------------- */ diff --git a/source/blender/draw/intern/draw_cache.h b/source/blender/draw/intern/draw_cache.h index 21fa652778b..ac7062b3cc8 100644 --- a/source/blender/draw/intern/draw_cache.h +++ b/source/blender/draw/intern/draw_cache.h @@ -125,6 +125,8 @@ struct Gwn_Batch **DRW_cache_mesh_surface_shaded_get( struct Gwn_Batch **DRW_cache_mesh_surface_texpaint_get(struct Object *ob); struct Gwn_Batch *DRW_cache_mesh_surface_texpaint_single_get(struct Object *ob); +void DRW_cache_mesh_sculpt_coords_ensure(struct Object *ob); + /* Curve */ struct Gwn_Batch *DRW_cache_curve_surface_get(struct Object *ob); struct Gwn_Batch *DRW_cache_curve_surface_verts_get(struct Object *ob); diff --git a/source/blender/draw/intern/draw_cache_impl.h b/source/blender/draw/intern/draw_cache_impl.h index 9328f6f6314..f8feeb37b82 100644 --- a/source/blender/draw/intern/draw_cache_impl.h +++ b/source/blender/draw/intern/draw_cache_impl.h @@ -96,6 +96,8 @@ struct Gwn_Batch *DRW_mesh_batch_cache_get_overlay_loose_edges_nor(struct Mesh * struct Gwn_Batch *DRW_mesh_batch_cache_get_overlay_loose_verts(struct Mesh *me); struct Gwn_Batch *DRW_mesh_batch_cache_get_overlay_facedots(struct Mesh *me); +void DRW_mesh_cache_sculpt_coords_ensure(struct Mesh *me); + /* Particles */ struct Gwn_Batch *DRW_particles_batch_cache_get_hair(struct ParticleSystem *psys, struct ModifierData *md); struct Gwn_Batch *DRW_particles_batch_cache_get_dots(struct ParticleSystem *psys); 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 diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 812280319e9..b93b7e21df2 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -2045,11 +2045,10 @@ bool DRW_object_is_renderable(Object *ob) return true; } - -bool DRW_object_is_flat_normal(Object *ob) +bool DRW_object_is_flat_normal(const Object *ob) { if (ob->type == OB_MESH) { - Mesh *me = ob->data; + const Mesh *me = ob->data; if (me->mpoly && me->mpoly[0].flag & ME_SMOOTH) { return false; } @@ -2057,6 +2056,26 @@ bool DRW_object_is_flat_normal(Object *ob) return true; } + +/** + * Return true if the object has its own draw mode. + * Caller must check this is active */ +int DRW_object_is_mode_shade(const Object *ob) +{ + BLI_assert(ob == DST.draw_ctx.obact); + if ((ob->mode & OB_MODE_EDIT) == 0) { + if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) { + if ((DST.draw_ctx.v3d->flag2 & V3D_SHOW_MODE_SHADE_OVERRIDE) == 0) { + return true; + } + else { + return false; + } + } + } + return -1; +} + /** \} */ @@ -2811,12 +2830,15 @@ static void DRW_engines_enable_external(void) static void DRW_engines_enable(const Scene *scene, SceneLayer *sl) { - const int mode = CTX_data_mode_enum_ex(scene->obedit, OBACT_NEW); + Object *obact = OBACT_NEW; + const int mode = CTX_data_mode_enum_ex(scene->obedit, obact); DRW_engines_enable_from_engine(scene); if (DRW_state_draw_support()) { DRW_engines_enable_from_object_mode(); - DRW_engines_enable_from_mode(mode); + if ((obact == NULL) || (DRW_object_is_mode_shade(obact) != false)) { + DRW_engines_enable_from_mode(mode); + } } } |