diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-01-17 13:40:07 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-01-17 13:40:07 +0300 |
commit | ced673c8336daabcc5805e6090d696d3799fc1d5 (patch) | |
tree | 29c3403fb7d42b38a3b03afa475f9e087877c8ae | |
parent | 9fb755fe4cd8690317ff5fe5bbbe6010a6b2e55b (diff) | |
parent | 06da6e2eaf76d475ea0743960b308d6c034eb8bf (diff) |
Merge branch 'blender-v2.92-release'
-rw-r--r-- | source/blender/editors/space_view3d/view3d_placement.c | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/source/blender/editors/space_view3d/view3d_placement.c b/source/blender/editors/space_view3d/view3d_placement.c index 7f0a7272ebd..31032eab547 100644 --- a/source/blender/editors/space_view3d/view3d_placement.c +++ b/source/blender/editors/space_view3d/view3d_placement.c @@ -1978,7 +1978,27 @@ static void cursor_plane_draw(bContext *C, int x, int y, void *customdata) } /* Draw */ - const float pixel_size = ED_view3d_pixel_size(rv3d, plc->matrix[3]); + float pixel_size; + + /* Arbitrary, 1.0 is a little too strong though. */ + float color_alpha = 0.75f; + + if (rv3d->is_persp) { + float center[3]; + negate_v3_v3(center, rv3d->ofs); + pixel_size = ED_view3d_pixel_size(rv3d, center); + + /* Scale down the alpha when this is drawn very small, + * since the add shader causes the small size to show too dense & bright. */ + const float relative_pixel_scale = pixel_size / ED_view3d_pixel_size(rv3d, plc->matrix[3]); + if (relative_pixel_scale < 1.0f) { + color_alpha *= max_ff(square_f(relative_pixel_scale), 0.3f); + } + } + else { + pixel_size = ED_view3d_pixel_size(rv3d, plc->matrix[3]); + } + if (pixel_size > FLT_EPSILON) { /* Setup viewport & matrix. */ @@ -1988,7 +2008,7 @@ static void cursor_plane_draw(bContext *C, int x, int y, void *customdata) GPU_matrix_projection_set(rv3d->winmat); GPU_matrix_set(rv3d->viewmat); - const float scale_mod = U.gizmo_size * U.dpi_fac; + const float scale_mod = U.gizmo_size * 2 * U.dpi_fac; float final_scale = (scale_mod * pixel_size); @@ -2000,13 +2020,18 @@ static void cursor_plane_draw(bContext *C, int x, int y, void *customdata) float fac = final_scale_fade / final_scale; - float color[4] = {1, 1, 1, 1}; - color[3] = square_f(1.0f - fac); - gizmo_plane_draw_grid( - lines * lines_subdiv, final_scale, final_scale_fade, plc->matrix, plc->plane_axis, color); + float color[4] = {1, 1, 1, color_alpha}; + color[3] *= square_f(1.0f - fac); + if (color[3] > 0.0f) { + gizmo_plane_draw_grid(lines * lines_subdiv, + final_scale, + final_scale_fade, + plc->matrix, + plc->plane_axis, + color); + } - /* Arbitrary, 1.0 is a little too strong though. */ - color[3] = 0.75f; + color[3] = color_alpha; /* When the grid is large, we only need the 2x lines in the middle. */ if (fac < 0.2f) { lines = 1; |