bevy/examples/2d
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
..
2d_shapes.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
2d_viewport_to_world.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
bloom_2d.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
bounding_2d.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
custom_gltf_vertex_attribute.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
mesh2d.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
mesh2d_manual.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
mesh2d_vertex_color_texture.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
move_sprite.rs Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
pixel_grid_snap.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
rotation.rs Update winit dependency to 0.29 (#10702) 2023-12-21 07:40:47 +00:00
sprite.rs Update color and naming for consistency (#10367) 2023-11-04 02:09:23 +00:00
sprite_flipping.rs Update color and naming for consistency (#10367) 2023-11-04 02:09:23 +00:00
sprite_sheet.rs Prefer UVec2 when working with texture dimensions (#11698) 2024-02-25 15:23:04 +00:00
sprite_slice.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
sprite_tile.rs Optional ImageScaleMode (#11780) 2024-02-09 20:36:32 +00:00
text2d.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
texture_atlas.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
transparency_2d.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00