bevy/crates/bevy_render/src/texture
Alex a7be8a2655
Prefer UVec2 when working with texture dimensions (#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`](a81a2d1da3/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`.
2024-02-25 15:23:04 +00:00
..
basis.rs Bevy Asset V2 (#8624) 2023-09-07 02:07:27 +00:00
compressed_image_saver.rs RenderAssetPersistencePolicy → RenderAssetUsages (#11399) 2024-01-30 13:22:10 +00:00
dds.rs mipmap levels can be 0 and they should be interpreted as 1 (#11767) 2024-02-11 22:00:07 +00:00
exr_texture_loader.rs RenderAssetPersistencePolicy → RenderAssetUsages (#11399) 2024-01-30 13:22:10 +00:00
fallback_image.rs Prefer UVec2 when working with texture dimensions (#11698) 2024-02-25 15:23:04 +00:00
hdr_texture_loader.rs RenderAssetPersistencePolicy → RenderAssetUsages (#11399) 2024-01-30 13:22:10 +00:00
image_loader.rs mipmap levels can be 0 and they should be interpreted as 1 (#11767) 2024-02-11 22:00:07 +00:00
image_texture_conversion.rs RenderAssetPersistencePolicy → RenderAssetUsages (#11399) 2024-01-30 13:22:10 +00:00
image.rs Prefer UVec2 when working with texture dimensions (#11698) 2024-02-25 15:23:04 +00:00
ktx2.rs Update to wgpu 0.19 and raw-window-handle 0.6 (#11280) 2024-01-26 18:14:21 +00:00
mod.rs Keep track of when a texture is first cleared (#10325) 2023-12-31 00:37:37 +00:00
texture_attachment.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
texture_cache.rs Remove unnecessary path prefixes (#10749) 2023-11-28 23:43:40 +00:00