UI: Color Axes in 3D/2D Cursor
Since 2.80, the 3D Cursor is actually 3D, but it is still not clear which way it points. To improve this, the following style tweaks were done: - Use theme axes colors for the 3D Cursor lines, a bit desaturated. - Draw the negative axes a little darker, to tell at a glance its direction. - Replace the red/white lines with black/white for improved contrast and to not conflict with X axis colors. - Make it over all smaller in size, since it's already prominent by its colors. See PR for details and screenshots. Pull Request: https://projects.blender.org/blender/blender/pulls/146927
This commit is contained in:
committed by
Pablo Vazquez
parent
598aa5f4b7
commit
5c8fb20f2d
@@ -88,7 +88,7 @@ class Cursor : Overlay {
|
||||
pass.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA);
|
||||
pass.shader_set(GPU_shader_get_builtin_shader(GPU_SHADER_3D_POLYLINE_FLAT_COLOR));
|
||||
pass.push_constant("viewportSize", float2(state.region->winx, state.region->winy));
|
||||
pass.push_constant("lineWidth", U.pixelsize);
|
||||
pass.push_constant("lineWidth", U.pixelsize * 1.5f);
|
||||
pass.push_constant("lineSmooth", true);
|
||||
/* WORKAROUND: This is normally set by the GPUBatch or IMM API but we don't use them here.
|
||||
* So make sure it is set otherwise it can be in undefined state (see #136911). */
|
||||
@@ -108,13 +108,12 @@ class Cursor : Overlay {
|
||||
float4x4 mvp_lines = float4x4(state.rv3d->winmat) * float4x4(state.rv3d->viewmat) *
|
||||
cursor_mat;
|
||||
|
||||
/* Render line first to avoid Z fighting. */
|
||||
pass.push_constant("ModelViewProjectionMatrix", mvp_lines);
|
||||
pass.push_constant("gpu_vert_stride_count_offset", vert_stride_count_line);
|
||||
pass.draw_expand(res.shapes.cursor_lines.get(), GPU_PRIM_TRIS, 2, 1);
|
||||
pass.push_constant("ModelViewProjectionMatrix", mvp);
|
||||
pass.push_constant("gpu_vert_stride_count_offset", vert_stride_count_circle);
|
||||
pass.draw_expand(res.shapes.cursor_circle.get(), GPU_PRIM_TRIS, 2, 1);
|
||||
pass.push_constant("ModelViewProjectionMatrix", mvp_lines);
|
||||
pass.push_constant("gpu_vert_stride_count_offset", vert_stride_count_line);
|
||||
pass.draw_expand(res.shapes.cursor_lines.get(), GPU_PRIM_TRIS, 2, 1);
|
||||
}
|
||||
else {
|
||||
pass.push_constant("ModelViewProjectionMatrix", mvp);
|
||||
|
||||
@@ -1329,16 +1329,17 @@ ShapeCache::ShapeCache()
|
||||
}
|
||||
/* cursor circle */
|
||||
{
|
||||
const int segments = 16;
|
||||
|
||||
const float red[3] = {1.0f, 0.0f, 0.0f};
|
||||
const float white[3] = {1.0f, 1.0f, 1.0f};
|
||||
const int segments = 12;
|
||||
const float radius = 0.38f;
|
||||
const float color_dark[3] = {0.4f, 0.4f, 0.4f};
|
||||
const float color_light[3] = {0.8f, 0.8f, 0.8f};
|
||||
|
||||
Vector<VertexWithColor> verts;
|
||||
|
||||
for (int i = 0; i < segments + 1; i++) {
|
||||
float angle = float(2 * M_PI) * (float(i) / float(segments));
|
||||
verts.append({0.5f * float3(cosf(angle), sinf(angle), 0.0f), (i % 2 == 0) ? red : white});
|
||||
verts.append({radius * float3(cosf(angle), sinf(angle), 0.0f),
|
||||
(i % 2 == 0) ? color_dark : color_light});
|
||||
}
|
||||
|
||||
cursor_circle = BatchPtr(GPU_batch_create_ex(
|
||||
@@ -1346,20 +1347,25 @@ ShapeCache::ShapeCache()
|
||||
}
|
||||
/* cursor lines */
|
||||
{
|
||||
const float f5 = 0.25f;
|
||||
const float f20 = 1.0f;
|
||||
const float f5 = 0.78f;
|
||||
const float f20 = 0.43f;
|
||||
const std::array<int, 3> axis_theme = {TH_AXIS_X, TH_AXIS_Y, TH_AXIS_Z};
|
||||
|
||||
float crosshair_color[3];
|
||||
UI_GetThemeColor3fv(TH_VIEW_OVERLAY, crosshair_color);
|
||||
|
||||
Vector<VertexWithColor> verts;
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
float3 axis(0.0f);
|
||||
axis[i] = 1.0f;
|
||||
/* Draw the axes a little darker and desaturated. */
|
||||
UI_GetThemeColorBlendShade3fv(axis_theme[i], TH_WHITE, .25f, -20, crosshair_color);
|
||||
verts.append({f5 * axis, crosshair_color});
|
||||
verts.append({f20 * axis, crosshair_color});
|
||||
|
||||
/* Draw the negative axis even darker. */
|
||||
axis[i] = -1.0f;
|
||||
UI_GetThemeColorBlendShade3fv(axis_theme[i], TH_WHITE, .33f, -90, crosshair_color);
|
||||
verts.append({f5 * axis, crosshair_color});
|
||||
verts.append({f20 * axis, crosshair_color});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user