diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-08-17 00:13:02 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-08-17 00:13:02 +0300 |
commit | 4b6c482d69cd35b9527dfe0d0ad7c73dfa8fb1ff (patch) | |
tree | 669057ab2a9b21501a603aea8e5a8a1c98eec862 /source | |
parent | 7c96f613e4d05f67f5cd9bf0cec29ca7ce51a3e4 (diff) |
DwM: use batch select for vertex paint mode
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/draw/intern/draw_cache_impl_mesh.c | 21 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawobject.c | 37 |
2 files changed, 53 insertions, 5 deletions
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c index eddf2dc2fa4..f77411c91e8 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.c +++ b/source/blender/draw/intern/draw_cache_impl_mesh.c @@ -2202,8 +2202,13 @@ static Gwn_VertBuf *mesh_batch_cache_get_verts_visible( } } else { - /* not yet done! */ - BLI_assert(0); + for (int i = 0; i < vbo_len_capacity; i++) { + const MVert *mv = &rdata->mvert[i]; + if (!(mv->flag & ME_HIDE)) { + GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx, mv->co); + vidx += 1; + } + } } const uint vbo_len_used = vidx; if (vbo_len_used != vbo_len_capacity) { @@ -2350,8 +2355,16 @@ static Gwn_VertBuf *mesh_create_verts_select_id( } } else { - /* not yet done! */ - BLI_assert(0); + for (int i = 0; i < vbo_len_capacity; i++) { + const MVert *mv = &rdata->mvert[i]; + if (!(mv->flag & ME_HIDE)) { + int select_id; + GPU_select_index_get(select_index, &select_id); + GWN_vertbuf_attr_set(vbo, attr_id.col, vidx, &select_id); + vidx += 1; + } + select_index += 1; + } } const int vbo_len_used = vidx; if (vbo_len_used != vbo_len_capacity) { diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 5698b2fe08a..ce206e9de0c 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -9371,7 +9371,7 @@ void draw_object_select( /* ***************** BACKBUF SEL (BBS) ********* */ - +#ifdef USE_MESH_DM_SELECT static void bbs_obmode_mesh_verts__mapFunc(void *userData, int index, const float co[3], const float UNUSED(no_f[3]), const short UNUSED(no_s[3])) { @@ -9412,6 +9412,15 @@ static void bbs_obmode_mesh_verts(Object *ob, DerivedMesh *dm, int offset) immUnbindProgram(); } +#else +static void bbs_obmode_mesh_verts(Object *ob, DerivedMesh *UNUSED(dm), int offset) +{ + Mesh *me = ob->data; + Gwn_Batch *batch = DRW_mesh_batch_cache_get_verts_with_select_id(me, offset); + GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32); + GWN_batch_draw(batch); +} +#endif #ifdef USE_MESH_DM_SELECT static void bbs_mesh_verts__mapFunc(void *userData, int index, const float co[3], @@ -9659,6 +9668,7 @@ static DMDrawOption bbs_mesh_solid_hide__setDrawOpts(void *userData, int index) } } +#ifdef USE_MESH_DM_SELECT /* must have called GPU_framebuffer_index_set beforehand */ static DMDrawOption bbs_mesh_solid_hide2__setDrawOpts(void *userData, int index) { @@ -9691,6 +9701,31 @@ static void bbs_mesh_solid_verts(const EvaluationContext *eval_ctx, Scene *scene bm_vertoffs = me->totvert + 1; dm->release(dm); } +#else +static void bbs_mesh_solid_verts(const EvaluationContext *UNUSED(eval_ctx), Scene *UNUSED(scene), Object *ob) +{ + Mesh *me = ob->data; + + /* Only draw faces to mask out verts, we don't want their selection ID's. */ + const int G_f_orig = G.f; + G.f &= ~G_BACKBUFSEL; + + { + int selcol; + Gwn_Batch *batch; + GPU_select_index_get(0, &selcol); + batch = DRW_mesh_batch_cache_get_triangles_with_select_mask(me, true); + GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR_U32); + GWN_batch_uniform_1i(batch, "color", selcol); + GWN_batch_draw(batch); + } + + G.f |= (G_f_orig & G_BACKBUFSEL); + + bbs_obmode_mesh_verts(ob, NULL, 1); + bm_vertoffs = me->totvert + 1; +} +#endif static void bbs_mesh_solid_faces(Scene *scene, Object *ob) { |