diff options
author | Jeroen Bakker <j.bakker@atmind.nl> | 2018-06-13 09:17:14 +0300 |
---|---|---|
committer | Jeroen Bakker <j.bakker@atmind.nl> | 2018-06-13 13:38:53 +0300 |
commit | 23c24cead582f8d766e87ba9adc0f612b16bceea (patch) | |
tree | 482d66e6a25fc9e7a4057fc6f3f55548844eb96f /source/blender/draw/modes/edit_mesh_mode.c | |
parent | c0926d536fb0495930799006d009819a58707c3e (diff) |
T55456: EditMode Drawing
- Hide facedots, except when in V3D_ZBUF_SELECT mode
`use_occluded_geometry`
- Different theme (wire_inactive) when not in edge selection mode
Diffstat (limited to 'source/blender/draw/modes/edit_mesh_mode.c')
-rw-r--r-- | source/blender/draw/modes/edit_mesh_mode.c | 116 |
1 files changed, 100 insertions, 16 deletions
diff --git a/source/blender/draw/modes/edit_mesh_mode.c b/source/blender/draw/modes/edit_mesh_mode.c index b50fb554a51..1a271fadd6b 100644 --- a/source/blender/draw/modes/edit_mesh_mode.c +++ b/source/blender/draw/modes/edit_mesh_mode.c @@ -91,12 +91,23 @@ typedef struct EDIT_MESH_Data { static struct { /* weight/vert-color */ GPUShader *vcolor_face_shader; + + /* Geometry */ GPUShader *overlay_tri_sh; GPUShader *overlay_tri_fast_sh; GPUShader *overlay_tri_vcol_sh; GPUShader *overlay_tri_vcol_fast_sh; - GPUShader *overlay_edge_sh; - GPUShader *overlay_edge_vcol_sh; + GPUShader *overlay_tri_edgesel_sh; + GPUShader *overlay_tri_edgesel_fast_sh; + GPUShader *overlay_tri_vcol_edgesel_sh; + GPUShader *overlay_tri_vcol_edgesel_fast_sh; + + /* Loose Edges */ + GPUShader *overlay_loose_edge_sh; + GPUShader *overlay_loose_edge_vcol_sh; + GPUShader *overlay_loose_edge_edgesel_sh; + GPUShader *overlay_loose_edge_vcol_edgesel_sh; + GPUShader *overlay_vert_sh; GPUShader *overlay_facedot_sh; GPUShader *overlay_mix_sh; @@ -195,22 +206,88 @@ static void EDIT_MESH_engine_init(void *vedata) "#define ANTI_ALIASING\n" "#define VERTEX_FACING\n"); } - if (!e_data.overlay_edge_sh) { - e_data.overlay_edge_sh = DRW_shader_create_with_lib( + + if (!e_data.overlay_tri_edgesel_sh) { + e_data.overlay_tri_edgesel_sh = DRW_shader_create_with_lib( + datatoc_edit_mesh_overlay_vert_glsl, + datatoc_edit_mesh_overlay_geom_tri_glsl, + datatoc_edit_mesh_overlay_frag_glsl, + datatoc_common_globals_lib_glsl, + "#define EDGE_FIX\n" + "#define EDGE_SELECTION\n" + "#define ANTI_ALIASING\n" + "#define VERTEX_FACING"); + } + if (!e_data.overlay_tri_edgesel_fast_sh) { + e_data.overlay_tri_edgesel_fast_sh = DRW_shader_create_with_lib( + datatoc_edit_mesh_overlay_vert_glsl, + datatoc_edit_mesh_overlay_geom_tri_glsl, + datatoc_edit_mesh_overlay_frag_glsl, + datatoc_common_globals_lib_glsl, + "#define ANTI_ALIASING\n" + "#define EDGE_SELECTION\n" + "#define VERTEX_FACING\n"); + } + if (!e_data.overlay_tri_vcol_edgesel_sh) { + e_data.overlay_tri_vcol_edgesel_sh = DRW_shader_create_with_lib( + datatoc_edit_mesh_overlay_vert_glsl, + datatoc_edit_mesh_overlay_geom_tri_glsl, + datatoc_edit_mesh_overlay_frag_glsl, + datatoc_common_globals_lib_glsl, + "#define EDGE_FIX\n" + "#define VERTEX_SELECTION\n" + "#define EDGE_SELECTION\n" + "#define ANTI_ALIASING\n" + "#define VERTEX_FACING\n"); + } + if (!e_data.overlay_tri_vcol_edgesel_fast_sh) { + e_data.overlay_tri_vcol_edgesel_fast_sh = DRW_shader_create_with_lib( + datatoc_edit_mesh_overlay_vert_glsl, + datatoc_edit_mesh_overlay_geom_tri_glsl, + datatoc_edit_mesh_overlay_frag_glsl, + datatoc_common_globals_lib_glsl, + "#define VERTEX_SELECTION\n" + "#define EDGE_SELECTION\n" + "#define ANTI_ALIASING\n" + "#define VERTEX_FACING\n"); + } + + if (!e_data.overlay_loose_edge_sh) { + e_data.overlay_loose_edge_sh = DRW_shader_create_with_lib( + datatoc_edit_mesh_overlay_vert_glsl, + datatoc_edit_mesh_overlay_geom_edge_glsl, + datatoc_edit_mesh_overlay_frag_glsl, + datatoc_common_globals_lib_glsl, + "#define ANTI_ALIASING\n" + "#define VERTEX_FACING\n"); + } + if (!e_data.overlay_loose_edge_vcol_sh) { + e_data.overlay_loose_edge_vcol_sh = DRW_shader_create_with_lib( + datatoc_edit_mesh_overlay_vert_glsl, + datatoc_edit_mesh_overlay_geom_edge_glsl, + datatoc_edit_mesh_overlay_frag_glsl, + datatoc_common_globals_lib_glsl, + "#define VERTEX_SELECTION\n" + "#define VERTEX_FACING\n"); + } + if (!e_data.overlay_loose_edge_edgesel_sh) { + e_data.overlay_loose_edge_edgesel_sh = DRW_shader_create_with_lib( datatoc_edit_mesh_overlay_vert_glsl, datatoc_edit_mesh_overlay_geom_edge_glsl, datatoc_edit_mesh_overlay_frag_glsl, datatoc_common_globals_lib_glsl, "#define ANTI_ALIASING\n" + "#define EDGE_SELECTION\n" "#define VERTEX_FACING\n"); } - if (!e_data.overlay_edge_vcol_sh) { - e_data.overlay_edge_vcol_sh = DRW_shader_create_with_lib( + if (!e_data.overlay_loose_edge_vcol_edgesel_sh) { + e_data.overlay_loose_edge_vcol_edgesel_sh = DRW_shader_create_with_lib( datatoc_edit_mesh_overlay_vert_glsl, datatoc_edit_mesh_overlay_geom_edge_glsl, datatoc_edit_mesh_overlay_frag_glsl, datatoc_common_globals_lib_glsl, "#define VERTEX_SELECTION\n" + "#define EDGE_SELECTION\n" "#define VERTEX_FACING\n"); } if (!e_data.overlay_vert_sh) { @@ -271,22 +348,23 @@ static DRWPass *edit_mesh_create_overlay_pass( RegionView3D *rv3d = draw_ctx->rv3d; Scene *scene = draw_ctx->scene; ToolSettings *tsettings = scene->toolsettings; + const bool in_edge_mode = (tsettings->selectmode & SCE_SELECT_EDGE) > 0; if ((tsettings->selectmode & SCE_SELECT_VERTEX) != 0) { - ledge_sh = e_data.overlay_edge_vcol_sh; + ledge_sh = in_edge_mode? e_data.overlay_loose_edge_vcol_edgesel_sh: e_data.overlay_loose_edge_vcol_sh; if ((rv3d->rflag & RV3D_NAVIGATING) != 0) - tri_sh = e_data.overlay_tri_vcol_fast_sh; + tri_sh = in_edge_mode? e_data.overlay_tri_vcol_edgesel_fast_sh: e_data.overlay_tri_vcol_fast_sh; else - tri_sh = e_data.overlay_tri_vcol_sh; + tri_sh = in_edge_mode? e_data.overlay_tri_vcol_edgesel_sh: e_data.overlay_tri_vcol_sh; } else { - ledge_sh = e_data.overlay_edge_sh; + ledge_sh = in_edge_mode? e_data.overlay_loose_edge_edgesel_sh: e_data.overlay_loose_edge_sh; if ((rv3d->rflag & RV3D_NAVIGATING) != 0) - tri_sh = e_data.overlay_tri_fast_sh; + tri_sh = in_edge_mode? e_data.overlay_tri_edgesel_fast_sh: e_data.overlay_tri_fast_sh; else - tri_sh = e_data.overlay_tri_sh; + tri_sh = in_edge_mode? e_data.overlay_tri_edgesel_sh: e_data.overlay_tri_sh; } DRWPass *pass = DRW_pass_create( @@ -435,7 +513,7 @@ static void edit_mesh_add_ob_to_pass( DRW_shgroup_call_add(lverts_shgrp, geo_ovl_lverts, ob->obmat); } - if ((tsettings->selectmode & SCE_SELECT_FACE) != 0) { + if (facedot_shgrp && (tsettings->selectmode & SCE_SELECT_FACE) != 0 ) { geo_ovl_fcenter = DRW_cache_face_centers_get(ob); DRW_shgroup_call_add(facedot_shgrp, geo_ovl_fcenter, ob->obmat); } @@ -505,7 +583,7 @@ static void EDIT_MESH_cache_populate(void *vedata, Object *ob) else { edit_mesh_add_ob_to_pass( scene, ob, stl->g_data->face_overlay_shgrp, stl->g_data->ledges_overlay_shgrp, - stl->g_data->lverts_overlay_shgrp, stl->g_data->facedot_overlay_shgrp, NULL); + stl->g_data->lverts_overlay_shgrp, NULL, NULL); } /* 3D text overlay */ @@ -561,8 +639,14 @@ static void EDIT_MESH_engine_free(void) DRW_SHADER_FREE_SAFE(e_data.overlay_tri_fast_sh); DRW_SHADER_FREE_SAFE(e_data.overlay_tri_vcol_sh); DRW_SHADER_FREE_SAFE(e_data.overlay_tri_vcol_fast_sh); - DRW_SHADER_FREE_SAFE(e_data.overlay_edge_sh); - DRW_SHADER_FREE_SAFE(e_data.overlay_edge_vcol_sh); + DRW_SHADER_FREE_SAFE(e_data.overlay_tri_edgesel_sh); + DRW_SHADER_FREE_SAFE(e_data.overlay_tri_edgesel_fast_sh); + DRW_SHADER_FREE_SAFE(e_data.overlay_tri_vcol_edgesel_sh); + DRW_SHADER_FREE_SAFE(e_data.overlay_tri_vcol_edgesel_fast_sh); + DRW_SHADER_FREE_SAFE(e_data.overlay_loose_edge_sh); + DRW_SHADER_FREE_SAFE(e_data.overlay_loose_edge_vcol_sh); + DRW_SHADER_FREE_SAFE(e_data.overlay_loose_edge_edgesel_sh); + DRW_SHADER_FREE_SAFE(e_data.overlay_loose_edge_vcol_edgesel_sh); DRW_SHADER_FREE_SAFE(e_data.overlay_vert_sh); DRW_SHADER_FREE_SAFE(e_data.overlay_facedot_sh); DRW_SHADER_FREE_SAFE(e_data.overlay_mix_sh); |