diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-09-01 16:52:03 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-09-01 17:08:50 +0300 |
commit | 7e3967ed37b9ac35813a9641f9940de7c5f06394 (patch) | |
tree | 00b233072ede222de4bbbd528a3fee788760b47d /source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c | |
parent | 998b680e5bc745721737f321fc1fad95875ca7bb (diff) |
Gizmo: Navigate: Make use of UI_draw_roundbox_4fv
This improves circles AntiAliasing, and line antialiasing.
This keeps the old drawing method (3d spheres) for the selection pipeline.
This was suggested by @harley on devtalk.
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c b/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c index 2259884f25c..d3294e4e5a9 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c @@ -241,6 +241,8 @@ static void axis_geom_draw(const wmGizmo *gz, const float axis_depth_bias = 0.01f; const float sphere_scale = 1.15f; + /* TODO(fclem) Is there a way to get the widget radius? */ + const float widget_pix_size = 40.0f * U.dpi_fac; #ifdef USE_AXIS_FONT struct { @@ -277,10 +279,22 @@ static void axis_geom_draw(const wmGizmo *gz, GPU_matrix_ortho_set_z(-clip_range, clip_range); } + UI_draw_roundbox_corner_set(UI_CNR_ALL); + GPU_polygon_smooth(false); + /* Circle defining active area. */ if (is_active) { - immUniformColor4fv(color); - imm_draw_circle_fill_3d(pos_id, 0, 0, 1.0f, DIAL_RESOLUTION); + immUnbindProgram(); + + float rad = widget_pix_size; + GPU_matrix_push(); + GPU_matrix_scale_1f(1.0f / rad); + + UI_draw_roundbox_4fv(true, -rad, -rad, rad, rad, rad, color); + + GPU_matrix_pop(); + + immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); } GPU_matrix_push(); @@ -343,6 +357,8 @@ static void axis_geom_draw(const wmGizmo *gz, float v_start[3]; immUnbindProgram(); + GPU_blend(GPU_BLEND_ALPHA); + immBindBuiltinProgram(GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR); immUniform2fv("viewportSize", &viewport[2]); immUniform1f("lineWidth", 2.0f * U.pixelsize); @@ -370,6 +386,34 @@ static void axis_geom_draw(const wmGizmo *gz, } /* Axis Ball. */ +#ifdef USE_AXIS_FONT + if (select == false) { + immUnbindProgram(); + + GPU_matrix_push(); + GPU_matrix_translate_3fv(v_final); + GPU_matrix_mul(font.matrix); + + float rad = widget_pix_size * (is_pos ? AXIS_HANDLE_SIZE_FG : AXIS_HANDLE_SIZE_BG); + + /* Black outlines for negative axis balls, otherwise they can be hard to see since + * they use a faded color which can be similar to the circle backdrop in tone. */ + if (is_active && !is_highlight && !is_pos && !select && !(axis_align == axis)) { + static const float axis_black_faded[4] = {0.0f, 0.0f, 0.0f, 0.2f}; + float outline = rad * sphere_scale; + UI_draw_roundbox_4fv( + true, -outline, -outline, outline, outline, outline, axis_black_faded); + } + + const float *col = is_pos_color ? color_current : color_current_fade; + UI_draw_roundbox_4fv(true, -rad, -rad, rad, rad, rad, col); + + GPU_matrix_pop(); + + immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); + } + else +#endif { GPU_matrix_push(); GPU_matrix_translate_3fv(v_final); |