godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.16k stars 97 forks source link

Improve 2D editor zoom handling for pixel art #588

Closed nodj closed 4 years ago

nodj commented 4 years ago

Describe the project you are working on: Very early prototype of 2D sidescroller. Interesting part: pixel art, I use the 2D editor with high level of zoom

Describe the problem or limitation you are having in your project: Zoom with mouse wheel doesn't hit "nice" zoom values. For instance, values goes from 194.8 to 205.1 in a single step, so pixel art is never nicely shown at 2 pixels per scene texel. This leads to uneven texel size: image

With the new step, we hit precisely 200%, which looks like: image

Describe the feature / enhancement and how it helps to overcome the problem or limitation: I'd like to choose an increment step that allows hitting those "nice" values. The step that works quite well is 2**(1/12) (aka. the twelveth root of two) because every 12 steps, the cumulated factor is 2, so starting from 100%, we hit 200% in 12 steps (or 50%, depending on the direction) For now, I don't see any drawback with this change.

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams: \editor\plugins\canvas_item_editor_plugin.cpp is modified to change the step from 5% to Math::pow(2, 1.0 / 12) (which is close to 6%)

If this enhancement will not be used often, can it be worked around with a few lines of script?: I don't think, but I'm not enough versed into editor scripting to be sure.

Is there a reason why this should be core and not an add-on in the asset library?: I think it will improve quality of life of 2D users, with no drawback that I can think of. Also, this is a fix of an internal value, I don't think it should be an add-on

nodj commented 4 years ago

Th PR that implements the new stepping values: https://github.com/godotengine/godot/pull/37073

akien-mga commented 4 years ago

Fixed by godotengine/godot#37073.