[Bf-blender-cvs] [fad8a753a9d] blender-v2.92-release: Add Object Tool: adjust cursor alpha when near view aligned

Campbell Barton noreply at git.blender.org
Wed Jan 20 08:56:17 CET 2021


Commit: fad8a753a9d7ff9c1acfd40d82bd1808b83f79e0
Author: Campbell Barton
Date:   Wed Jan 20 18:54:11 2021 +1100
Branches: blender-v2.92-release
https://developer.blender.org/rBfad8a753a9d7ff9c1acfd40d82bd1808b83f79e0

Add Object Tool: adjust cursor alpha when near view aligned

The cursor-plane was too dense/bright when approaching view alignment.

===================================================================

M	source/blender/editors/space_view3d/view3d_placement.c

===================================================================

diff --git a/source/blender/editors/space_view3d/view3d_placement.c b/source/blender/editors/space_view3d/view3d_placement.c
index 0700b47dbde..3ae09624f0c 100644
--- a/source/blender/editors/space_view3d/view3d_placement.c
+++ b/source/blender/editors/space_view3d/view3d_placement.c
@@ -1989,20 +1989,10 @@ static void cursor_plane_draw(bContext *C, int x, int y, void *customdata)
   /* Draw */
   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]);
@@ -2010,6 +2000,25 @@ static void cursor_plane_draw(bContext *C, int x, int y, void *customdata)
 
   if (pixel_size > FLT_EPSILON) {
 
+    /* Arbitrary, 1.0 is a little too strong though. */
+    float color_alpha = 0.75f;
+    if (rv3d->is_persp) {
+      /* 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);
+      }
+    }
+
+    {
+      /* Extra adjustment when it's near view-aligned as it seems overly bright. */
+      float view_vector[3];
+      ED_view3d_global_to_vector(rv3d, plc->matrix[3], view_vector);
+      float view_dot = fabsf(dot_v3v3(plc->matrix[plc->plane_axis], view_vector));
+      color_alpha *= max_ff(0.3f, 1.0f - square_f(square_f(1.0f - view_dot)));
+    }
+
     /* Setup viewport & matrix. */
     wmViewport(&region->winrct);
     GPU_matrix_push_projection();



More information about the Bf-blender-cvs mailing list