Page MenuHome

Fix T76150: Viewport Axes not toggling correctly when 'Floor' and 'Grid' are turned off
ClosedPublic

Authored by Ankit Meel (ankitm) on Apr 29 2020, 4:40 PM.

Details

Summary

Fix T76150
While comparing with the deleted file [1] in the commit [2], saw this
little addition which most probably was added for optimisation.
Removing it fixes the behaviour too.

To test:

  • In Viewport Overlays > Guides, uncheck both Grid & Floor.
  • Try toggling all three axes individually.
  • Z just sticks. X cannot be shown without Y enabled.

[1] https://developer.blender.org/diffusion/B/change/master/source/blender/draw/modes/object_mode.c;9516921c05bd9fee5c94942eb8e38f47ba7e4351
[2] rB9516921c05bd: Overlay Engine: Refactor & Cleanup

Diff Detail

Repository
rB Blender

Event Timeline

Ankit Meel (ankitm) requested review of this revision.Apr 29 2020, 4:40 PM
Ankit Meel (ankitm) edited the summary of this revision. (Show Details)Apr 29 2020, 4:42 PM

Add show_axis_x to the test and keep the optimization?

Ankit Meel (ankitm) added a comment.EditedApr 29 2020, 5:37 PM

From my shallow understanding of the logic, won't it become just like the if-else chain in lines under [1] ? (imagining all the possible combinations of grid, floor, overlay, x,y,z. )

if (pd->hide_overlays || !(show_axis_x || show_axis_y || show_axis_z || show_floor || show_ortho_grid))

doesn't help though.

[1] https://developer.blender.org/diffusion/B/browse/master/source/blender/draw/engines/overlay/overlay_grid.c$76

Ankit Meel (ankitm) added a comment.EditedApr 29 2020, 5:40 PM

Just tested all combos: problematic one is: (grid, floor, x,y )all off. Turn on Z, it sticks despite toggling it off.
(testing some variations now. )

  • Keeping the optimisation.
Ankit Meel (ankitm) edited the summary of this revision. (Show Details)Apr 29 2020, 6:07 PM
source/blender/draw/engines/overlay/overlay_grid.c
67

This line is not clear and perhaps not complete or the issue is elsewhere. Think we should dive deeper in the issue.

source/blender/draw/engines/overlay/overlay_grid.c
67

Oh right. The return statement is never being used..
Z axis is causing some trouble. Checking.
Will abandon if can't get it to work.

  • make format
  • Verified that it saves some steps in some conditions.

Note this code in OVERLAY_grid_cache_init:

if ((shd->grid_flag == 0 && shd->zpos_flag == 0) || !DRW_state_is_fbo()) {
  return;
}

I think what's missing is always clearing shd->zpos_flag and shd->zneg_flag at the start of OVERLAY_grid_init along with shd->grid_flag.

Ankit Meel (ankitm) updated this revision to Diff 24344.EditedMay 3 2020, 3:25 PM

Reverted previous changes and added flags for Z. Added axis_x otherwise
it won't show up when all other boxes are off.
Verified that return is used.

Ankit Meel (ankitm) marked an inline comment as done.May 3 2020, 3:26 PM
Clément Foucault (fclem) requested changes to this revision.May 13 2020, 3:45 PM
Clément Foucault (fclem) added inline comments.
source/blender/draw/engines/overlay/overlay_grid.c
67

At this point I think checking for pd->v3d_gridflag == 0 is better and less error prone.

This revision now requires changes to proceed.May 13 2020, 3:45 PM
Ankit Meel (ankitm) marked an inline comment as done.May 13 2020, 5:04 PM
This revision is now accepted and ready to land.May 13 2020, 5:19 PM

Polite reminder for committing this.