fix camera viewport size on scaled target #90
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
On scaled target, calculations based on the camera viewport's size were off, due to taking into account the scaling factor. Scaling factor should be taken into account when rendering UI elements, not when placing them into the world, since the world uses logical units.
Example of the bug:
The systems defines a scaling factor of 2. This means that when rendering at 1000x500, the camera is going to upscale that to 2000x1000. If we place a UiLayout that is of size Rl(100.), it's going to take viewport's physical size: 2000x1000. When rendering, it's going to be upscaled by the scale factor, so it'll end up taking 4000x2000.
The fix is to use the camera's viewport logical size, to use world's coordinates.
I'm new to this stuff, the fix might have side effects that I'm not aware of.