Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve viewport rotation gizmo drawing #93639

Merged
merged 1 commit into from
Jun 27, 2024

Conversation

passivestar
Copy link
Contributor

  • More accurate text placement, using Vector2 to avoid loss of precision
  • Don't draw lines under the circles
  • Enable antialiasing
  • Use slightly smaller font size so letters don't get too close to the edge
  • Limit text alpha to avoid pitch black
  • Use brighter axis color on hover instead of pure white
  • Use remap for alpha calculation so that foreground axes stay opaque longer
  • Slightly reduce minimum possible alpha for better depth separation
  • Thicker lines
Before After
b1 a1
b2 a2

@passivestar
Copy link
Contributor Author

Added a little bit of space below the gizmo too:

Before After
1 2

@fire
Copy link
Member

fire commented Jun 27, 2024

Is it difficult for you to make a side by side video? It might help the nontechnical to provide comments.

Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally, it works as expected. Code looks good to me.

Great work!

Preview with Inter as the editor font:

gizmo_new.mp4

200% editor scale with the default font:

gizmo_new_2x.mp4

The only issue I can notice is that with certain custom fonts (as shown above), the X/Y/Z labels can be slightly off-center. I'm not sure if much can be done about this. (For reference, this issue was already present before your PR.)

@passivestar
Copy link
Contributor Author

passivestar commented Jun 27, 2024

Is it difficult for you to make a side by side video? It might help the nontechnical to provide comments

If you mean to show the alpha behavior - it's very subtle and I'm not sure a lot of people would necessarily notice the difference in motion. The reason I did that alpha change is for cleaner ortho views, I wanted the perpendicular axes in ortho views to stay opaque. Before, if you look at the ortho picture on top you can notice that while Z is opaque, X and Y are half transparent, and with this PR axes only start getting transparent once they get past the 0 dot product point

The only issue I can notice is that with certain custom fonts (as shown above), the X/Y/Z labels can be slightly off-center. I'm not sure if much can be done about this. (For reference, this issue was already present before your PR.)

I noticed that too while testing at lower res (doesn't seem to be a problem at high dpi). I'm thinking it might be a problem with either imprecise char size calculation or how chars are rasterized or smth like that but I haven't dug that deep into the engine, only did what I could in the gizmo code

To give an example this is how "Y" is rasterized. As you can see it matches with the opaque pixels but on the left there are some transparent pixels that when viewed from the distance may make the char look unaligned. This is 200%, may get worse at 100%. I'm not sure if there's anything I can do about this. Whether it'll be perfectly centered or 1px to the left/right seems to be a matter of chance :D

image

@akien-mga
Copy link
Member

The only issue I can notice is that with certain custom fonts (as shown above), the X/Y/Z labels can be slightly off-center. I'm not sure if much can be done about this. (For reference, this issue was already present before your PR.)

I noticed that too while testing at lower res (doesn't seem to be a problem at high dpi). I'm thinking it might be a problem with either imprecise char size calculation or how chars are rasterized or smth like that but I haven't dug that deep into the engine, only did what I could in the gizmo code

One option could be to replace the manual draw labels in editor font with a custom SVG for X, Y, Z well centered in the circle. There might still be issues depending on the scale used in the editor for scaling up/down the SVG, but at least we can ensure it's using the same font and metrics won't mess it up.

Alternatively, we could draw these labels with the default editor font regardless of custom fonts defined by the user.

@akien-mga akien-mga modified the milestones: 4.x, 4.3 Jun 27, 2024
Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. This is pretty low risk so should be fine to include in 4.3 despite the feature freeze.

@akien-mga akien-mga merged commit e018b17 into godotengine:master Jun 27, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

@passivestar passivestar deleted the rotation-gizmo branch June 27, 2024 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants