bevy/crates/bevy_ui/src
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
..
layout Move EntityHash related types into bevy_ecs (#11498) 2024-02-12 15:02:24 +00:00
render Prefer UVec2 when working with texture dimensions (#11698) 2024-02-25 15:23:04 +00:00
widget Prefer UVec2 when working with texture dimensions (#11698) 2024-02-25 15:23:04 +00:00
accessibility.rs resolve all internal ambiguities (#10411) 2024-01-09 19:08:15 +00:00
focus.rs Use question mark operator when possible (#11865) 2024-02-14 18:44:33 +00:00
geometry.rs Made the remaining types from bevy_ui to reflect the Default trait if… (#11199) 2024-01-03 18:57:05 +00:00
lib.rs UI Texture 9 slice (#11600) 2024-02-07 20:07:53 +00:00
measurement.rs Change the default for the measure_func field of ContentSize to None. (#9346) 2023-08-07 23:06:40 +00:00
node_bundles.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
stack.rs Avoid unconditionally unwrapping the Result - UI Stack System (#11575) 2024-01-29 02:38:41 +00:00
texture_slice.rs Fixed Ui Image slicing (#12047) 2024-02-23 01:08:32 +00:00
ui_material.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
ui_node.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
update.rs Camera-driven UI (#10559) 2024-01-16 00:39:10 +00:00