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 | |
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
12 files changed, 140 insertions, 21 deletions
diff --git a/source/blender/draw/intern/draw_common.c b/source/blender/draw/intern/draw_common.c index fb8833f40c3..61bbb7be1c1 100644 --- a/source/blender/draw/intern/draw_common.c +++ b/source/blender/draw/intern/draw_common.c @@ -50,6 +50,7 @@ struct GPUTexture *globals_ramp = NULL; void DRW_globals_update(void) { UI_GetThemeColor4fv(TH_WIRE, ts.colorWire); + UI_GetThemeColor4fv(TH_WIRE_INACTIVE, ts.colorWireInactive); UI_GetThemeColor4fv(TH_WIRE_EDIT, ts.colorWireEdit); UI_GetThemeColor4fv(TH_ACTIVE, ts.colorActive); UI_GetThemeColor4fv(TH_SELECT, ts.colorSelect); @@ -64,6 +65,7 @@ void DRW_globals_update(void) UI_GetThemeColor4fv(TH_VERTEX_SELECT, ts.colorVertexSelect); UI_GetThemeColor4fv(TH_EDITMESH_ACTIVE, ts.colorEditMeshActive); UI_GetThemeColor4fv(TH_EDGE_SELECT, ts.colorEdgeSelect); + UI_GetThemeColor4fv(TH_EDGE_SEAM, ts.colorEdgeSeam); UI_GetThemeColor4fv(TH_EDGE_SHARP, ts.colorEdgeSharp); UI_GetThemeColor4fv(TH_EDGE_CREASE, ts.colorEdgeCrease); diff --git a/source/blender/draw/intern/draw_common.h b/source/blender/draw/intern/draw_common.h index 6227130fb05..5e29831624b 100644 --- a/source/blender/draw/intern/draw_common.h +++ b/source/blender/draw/intern/draw_common.h @@ -41,6 +41,7 @@ struct PTCacheEdit; typedef struct GlobalsUboStorage { /* UBOs data needs to be 16 byte aligned (size of vec4) */ float colorWire[4]; + float colorWireInactive[4]; float colorWireEdit[4]; float colorActive[4]; float colorSelect[4]; 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); diff --git a/source/blender/draw/modes/shaders/common_globals_lib.glsl b/source/blender/draw/modes/shaders/common_globals_lib.glsl index c55457bb6d2..f8a8f3b9203 100644 --- a/source/blender/draw/modes/shaders/common_globals_lib.glsl +++ b/source/blender/draw/modes/shaders/common_globals_lib.glsl @@ -2,6 +2,7 @@ /* keep in sync with GlobalsUboStorage */ layout(std140) uniform globalsBlock { vec4 colorWire; + vec4 colorWireInactive; vec4 colorWireEdit; vec4 colorActive; vec4 colorSelect; diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_facedot_frag.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_facedot_frag.glsl index 07b36079884..71cc1ccde8d 100644 --- a/source/blender/draw/modes/shaders/edit_mesh_overlay_facedot_frag.glsl +++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_facedot_frag.glsl @@ -11,7 +11,7 @@ void main() if (isSelected != 0) FragColor = colorFaceDot; else - FragColor = colorWireEdit; + FragColor = colorVertex; #ifdef VERTEX_FACING FragColor.a *= 1.0 - abs(facing) * 0.4; diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl index cf1051b70b3..4bf5f348c27 100644 --- a/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl +++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl @@ -10,7 +10,6 @@ * TODO Refine the range to only affect GPUs. */ uniform float faceAlphaMod; - flat in vec3 edgesCrease; flat in vec3 edgesBweight; flat in vec4 faceColor; @@ -181,10 +180,13 @@ void main() #ifdef VERTEX_SELECTION colorDistEdge(vec4(vertexColor, 1.0), innerEdge); #else +# ifdef EDGE_SELECTION vec4 inner_edge_color = colorWireEdit; inner_edge_color = ((flag[v] & EDGE_SELECTED) != 0) ? colorEdgeSelect : inner_edge_color; inner_edge_color = ((flag[v] & EDGE_ACTIVE) != 0) ? vec4(colorEditMeshActive.xyz, 1.0) : inner_edge_color; - +# else + vec4 inner_edge_color = colorWireInactive; +# endif colorDistEdge(inner_edge_color, innerEdge); #endif } diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_geom_edge.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_geom_edge.glsl index 77bc8a25695..6702722e61f 100644 --- a/source/blender/draw/modes/shaders/edit_mesh_overlay_geom_edge.glsl +++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_geom_edge.glsl @@ -76,7 +76,11 @@ vec3 getVertexColor(int v) if ((vData[v].x & (VERTEX_ACTIVE | VERTEX_SELECTED)) != 0) return colorEdgeSelect.rgb; else +#ifdef EDGE_SELECTION return colorWireEdit.rgb; +#else + return colorWireInactive.rgb; +#endif } void doVertex(int v, vec4 pos) diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_geom_tri.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_geom_tri.glsl index d9c902697b6..a22cc56c74f 100644 --- a/source/blender/draw/modes/shaders/edit_mesh_overlay_geom_tri.glsl +++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_geom_tri.glsl @@ -95,7 +95,11 @@ vec3 getVertexColor(int v) if ((vData[v].x & (VERTEX_ACTIVE | VERTEX_SELECTED)) != 0) return colorEdgeSelect.rgb; else +#ifdef EDGE_SELECTION return colorWireEdit.rgb; +#else + return colorWireInactive.rgb; +#endif } vec4 getClipData(vec2 pos[3], ivec2 vidx) diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h index cab0fa8645d..48afea6bbf0 100644 --- a/source/blender/editors/include/UI_resources.h +++ b/source/blender/editors/include/UI_resources.h @@ -90,6 +90,7 @@ typedef enum ThemeColorID { TH_WIRE, TH_WIRE_INNER, TH_WIRE_EDIT, + TH_WIRE_INACTIVE, TH_SELECT, TH_ACTIVE, TH_GROUP, diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 2a61be21589..ebf900c1cff 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -298,6 +298,8 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo cp = ts->syntaxr; break; case TH_WIRE_EDIT: cp = ts->wire_edit; break; + case TH_WIRE_INACTIVE: + cp = ts->wire_inactive; break; case TH_LAMP: cp = ts->lamp; break; case TH_SPEAKER: @@ -934,6 +936,7 @@ void ui_theme_init_default(void) rgba_char_args_set(btheme->tv3d.view_overlay, 0, 0, 0, 255); rgba_char_args_set(btheme->tv3d.wire, 0x0, 0x0, 0x0, 255); rgba_char_args_set(btheme->tv3d.wire_edit, 0x0, 0x0, 0x0, 255); + rgba_char_args_set(btheme->tv3d.wire_inactive, 128, 128, 128, 255); rgba_char_args_set(btheme->tv3d.lamp, 0, 0, 0, 40); rgba_char_args_set(btheme->tv3d.speaker, 0, 0, 0, 255); rgba_char_args_set(btheme->tv3d.camera, 0, 0, 0, 255); @@ -3046,6 +3049,17 @@ void init_userdef_do_versions(Main *bmain) } } + for (bTheme *btheme = U.themes.first; btheme; btheme = btheme->next) { + ThemeSpace *ts; + + for (ts = UI_THEMESPACE_START(btheme); ts != UI_THEMESPACE_END(btheme); ts++) { + if (btheme->tv3d.wire_inactive[3] == 0) { + rgba_char_args_set(btheme->tv3d.wire_inactive, 128, 128, 128, 255); + } + } + } + + if (U.pixelsize == 0.0f) U.pixelsize = 1.0f; diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 17f520fdfa9..7315c84070c 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -253,7 +253,7 @@ typedef struct ThemeSpace { char view_overlay[4]; - char wire[4], wire_edit[4], select[4]; + char wire[4], wire_edit[4], wire_inactive[4], select[4]; char lamp[4], speaker[4], empty[4], camera[4]; char active[4], group[4], group_active[4], transform[4]; char vertex[4], vertex_select[4], vertex_bevel[4], vertex_unreferenced[4]; @@ -361,6 +361,7 @@ typedef struct ThemeSpace { char metadatabg[4]; char metadatatext[4]; + int pad; } ThemeSpace; diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 0d05d03e3a9..844ab3301fa 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -1746,9 +1746,14 @@ static void rna_def_userdef_theme_space_view3d(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Wire", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); + prop = RNA_def_property(srna, "wire_inactive", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Wire Inactive", "Color for wireframe when in edit mode, but edge selection is not active"); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + prop = RNA_def_property(srna, "wire_edit", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Wire Edit", ""); + RNA_def_property_ui_text(prop, "Wire Edit", "Color for wireframe when in edit mode, but edge selection is active"); RNA_def_property_update(prop, 0, "rna_userdef_update"); |