forked from bevyengine/bevy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prefer
UVec2
when working with texture dimensions (bevyengine#11698)
# Objective The physical width and height (pixels) of an image is always integers, but for `GpuImage` bevy currently stores them as `Vec2` (`f32`). Switching to `UVec2` makes this more consistent with the [underlying texture data](https://docs.rs/wgpu/latest/wgpu/struct.Extent3d.html). I'm not sure if this is worth the change in the surface level API. If not, feel free to close this PR. ## Solution - Replace uses of `Vec2` with `UVec2` when referring to texture dimensions. - Use integer types for the texture atlas dimensions and sections. [`Sprite::rect`](https://github.com/bevyengine/bevy/blob/a81a2d1da31cc2eebcd9d431ed2b73a678ce61e3/crates/bevy_sprite/src/sprite.rs#L29) remains unchanged, so manually specifying a sub-pixel region of an image is still possible. --- ## Changelog - `GpuImage` now stores its size as `UVec2` instead of `Vec2`. - Texture atlases store their size and sections as `UVec2` and `URect` respectively. - `UiImageSize` stores its size as `UVec2`. ## Migration Guide - Change floating point types (`Vec2`, `Rect`) to their respective unsigned integer versions (`UVec2`, `URect`) when using `GpuImage`, `TextureAtlasLayout`, `TextureAtlasBuilder`, `DynamicAtlasTextureBuilder` or `FontAtlas`.
- Loading branch information
Showing
18 changed files
with
89 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.