diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2019-03-04 21:15:18 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2019-03-04 21:18:12 +0300 |
commit | 89db684d82f77d41f24335a7e90a9db320d1dfe0 (patch) | |
tree | 370ee3021cbf02d48cc84220e16c80b1f3b071ab /source/blender | |
parent | 81ae7773e74a2f393b0ecf1818335c2b46668e4a (diff) |
Preferences: Add option to disable edit-mode wire Antialiasing
Requested by some users who prefer old wireframe precision.
Smooth wires are still enabled by defaults as they don't have a noticeable
perf impact.
Application restart is needed for changes to take effects.
Diffstat (limited to 'source/blender')
8 files changed, 24 insertions, 7 deletions
diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h index 84d05c6b23c..a49081c5caa 100644 --- a/source/blender/blenkernel/BKE_blender_version.h +++ b/source/blender/blenkernel/BKE_blender_version.h @@ -24,7 +24,7 @@ * and keep comment above the defines. * Use STRINGIFY() rather than defining with quotes */ #define BLENDER_VERSION 280 -#define BLENDER_SUBVERSION 45 +#define BLENDER_SUBVERSION 46 /* Several breakages with 280, e.g. collections vs layers */ #define BLENDER_MINVERSION 280 #define BLENDER_MINSUBVERSION 0 diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 51f7da4f31a..1179149bf90 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -2799,9 +2799,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } } - { - /* Versioning code until next subversion bump goes here. */ - + if (!MAIN_VERSION_ATLEAST(bmain, 280, 46)) { /* Add wireframe color. */ if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "char", "wire_color_type")) { for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) { @@ -2826,4 +2824,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } } } + + { + /* Versioning code until next subversion bump goes here. */ + } } diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c index 4366fb959c7..ef0cd7bc7d5 100644 --- a/source/blender/blenloader/intern/versioning_userdef.c +++ b/source/blender/blenloader/intern/versioning_userdef.c @@ -476,6 +476,10 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef) GP_PAINT_DEPRECATED_0); } + if (!USER_VERSION_ATLEAST(280, 46)) { + userdef->uiflag2 |= USER_EDIT_MODE_SMOOTH_WIRE; + } + /** * Include next version bump. */ diff --git a/source/blender/draw/modes/edit_mesh_mode.c b/source/blender/draw/modes/edit_mesh_mode.c index d599e390ca7..9afb9ce40a0 100644 --- a/source/blender/draw/modes/edit_mesh_mode.c +++ b/source/blender/draw/modes/edit_mesh_mode.c @@ -197,6 +197,7 @@ static void EDIT_MESH_engine_init(void *vedata) geom_sh_code[0] = NULL; } const char *use_geom_def = use_geom_shader ? "#define USE_GEOM_SHADER\n" : ""; + const char *use_smooth_def = (U.uiflag2 & USER_EDIT_MODE_SMOOTH_WIRE) ? "#define USE_SMOOTH_WIRE\n" : ""; sh_data->overlay_face = GPU_shader_create_from_arrays({ .vert = (const char *[]){lib, datatoc_edit_mesh_overlay_vert_glsl, NULL}, .frag = (const char *[]){datatoc_gpu_shader_3D_smooth_color_frag_glsl, NULL}, @@ -205,13 +206,13 @@ static void EDIT_MESH_engine_init(void *vedata) sh_data->overlay_edge = GPU_shader_create_from_arrays({ .vert = (const char *[]){lib, datatoc_edit_mesh_overlay_vert_glsl, NULL}, .frag = (const char *[]){lib, datatoc_edit_mesh_overlay_frag_glsl, NULL}, - .defs = (const char *[]){sh_cfg_data->def, use_geom_def, "#define EDGE\n", NULL}, + .defs = (const char *[]){sh_cfg_data->def, use_geom_def, use_smooth_def, "#define EDGE\n", NULL}, .geom = (use_geom_shader) ? geom_sh_code : NULL, }); sh_data->overlay_edge_flat = GPU_shader_create_from_arrays({ .vert = (const char *[]){lib, datatoc_edit_mesh_overlay_vert_glsl, NULL}, .frag = (const char *[]){lib, datatoc_edit_mesh_overlay_frag_glsl, NULL}, - .defs = (const char *[]){sh_cfg_data->def, use_geom_def, "#define EDGE\n", "#define FLAT\n", NULL}, + .defs = (const char *[]){sh_cfg_data->def, use_geom_def, use_smooth_def, "#define EDGE\n", "#define FLAT\n", NULL}, .geom = (use_geom_shader) ? geom_sh_code : NULL, }); sh_data->overlay_vert = GPU_shader_create_from_arrays({ 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 d48c5158872..dbad525c281 100644 --- a/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl +++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl @@ -24,7 +24,7 @@ void main() { float dist = abs(edgeCoord_f) - max(sizeEdge * edgeScale - 0.5, 0.0); float dist_outer = dist - max(sizeEdge * edgeScale, 1.0); -#if 1 +#ifdef USE_SMOOTH_WIRE float mix_w = smoothstep(GRID_LINE_SMOOTH_START, GRID_LINE_SMOOTH_END, dist); float mix_w_outer = smoothstep(GRID_LINE_SMOOTH_START, GRID_LINE_SMOOTH_END, dist_outer); #else diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_geom.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_geom.glsl index b36c1ff869f..9a0bda3b81d 100644 --- a/source/blender/draw/modes/shaders/edit_mesh_overlay_geom.glsl +++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_geom.glsl @@ -40,8 +40,11 @@ void main() float half_size = sizeEdge * edgeScale; /* Enlarge edge for flag display. */ half_size += (finalColorOuter_f.a > 0.0) ? max(sizeEdge * edgeScale, 1.0) : 0.0; + +#ifdef USE_SMOOTH_WIRE /* Add 1 px for AA */ half_size += 0.5; +#endif vec3 edge_ofs = half_size * viewportSizeInv.xyy * vec3(1.0, 1.0, 0.0); diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 932377fa718..048b7e60d57 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -899,6 +899,7 @@ typedef enum eUserpref_UI_Flag2 { USER_UIFLAG2_DEPRECATED_0 = (1 << 0), USER_REGION_OVERLAP = (1 << 1), USER_TRACKPAD_NATURAL = (1 << 2), + USER_EDIT_MODE_SMOOTH_WIRE = (1 << 3), } eUserpref_UI_Flag2; /** #UserDef.tablet_api */ diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index cf79e4eec4b..9571fe9a4b3 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -4408,6 +4408,12 @@ static void rna_def_userdef_system(BlenderRNA *brna) "Enable OpenGL multi-sampling, only for systems that support it, requires restart"); RNA_def_property_update(prop, 0, "rna_userdef_dpi_update"); + prop = RNA_def_property(srna, "use_edit_mode_smooth_wire", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "uiflag2", USER_EDIT_MODE_SMOOTH_WIRE); + RNA_def_property_ui_text(prop, "Edit-Mode Smooth Wires", + "Enable Edit-Mode edge smoothing, reducing aliasing, requires restart"); + RNA_def_property_update(prop, 0, "rna_userdef_dpi_update"); + /* grease pencil anti-aliasing */ prop = RNA_def_property(srna, "gpencil_multi_sample", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "gpencil_multisamples"); |