deadcast2 / UltraEd

A WIP level editor/game engine for the Nintendo 64.
MIT License
132 stars 13 forks source link

Scale Gizmo Dimensions individually to prevent weird morphing #149

Closed Byterset closed 2 years ago

Byterset commented 2 years ago

Scaling the Gizmos individually in each direction based on the view distance in the particular direction. This will reduce the existing issues of weird gizmo scaling when you for example position the editor view in front of an object with active gizmos and move only to the left or right.

deadcast2 commented 2 years ago

Hi Byterset! I tried out your change but it removes the ease of being able to select the gizmo from far away for an actor. When I zoom far out the gizmo is now very tiny unlike before it would maintain a decent size for selection. So I'd like to keep the gizmo always easy to select from any distance. Do you have an example of the weird morphing you're experiencing with the gizmo currently?

Byterset commented 2 years ago

Heya, yeah you are right it is also nice to have the gizmo at a constant scale no matter the distance. Example: let's say you are in the editor in the example scene and you have aligned your view roughly with that of the camera looking straight at the pumpkin and select it so the gizmos are visible. Now if you move back the gizmo scales fine and keeps its size like you intend to. If you move horizontally only the distance to the gizmo increases anyway and it will scale up and look weird and unnatural. So this happens especially if the object moves closer to the edge of the viewport.

If you look at the unity editor for example I think they have a very nice implementation. There the gizmos scale with distance to always keep the same size on the screen but they don't have the unusual growth when moving in the directions of the view plane.

I hope this explains what I mean in an understandable way :)

Byterset commented 2 years ago

I have realized that my approach was far to simplistic, I changed the code to resemble the way other Editors are handling gizmo scaling. This will preserve your intention of always keeping the gizmos at a convenient constant size but will also take care of the disproportunate scaling when the object is not in the center of the view as i described in the comment before.

deadcast2 commented 2 years ago

Ok cool I like it. The gizmo now always keeps a good size and never gets too small. Also the weird scaling you were talking about is gone. Neat little formula for scaling! I'll merge and then I think I'll pull your code into a new method along with the code below it. Whenever I see my own comments describing some following block of code I like to try and extract it into a well named function. I think this is a good place to do so. I actually haven't looked much at the gizmo code in a while lol. Thanks for helping improve the gizmo!