2
0
Fork 0
mirror of https://github.com/bevyengine/bevy synced 2025-01-09 11:48:56 +00:00
bevy/crates/bevy_text/src
Alex a7be8a2655
Prefer UVec2 when working with texture dimensions ()
# 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
..
error.rs Remove TextError::ExceedMaxTextAtlases(usize) variant () 2022-12-05 23:23:16 +00:00
FiraMono-subset.ttf add a default font () 2023-04-21 22:30:18 +00:00
font.rs RenderAssetPersistencePolicy → RenderAssetUsages () 2024-01-30 13:22:10 +00:00
font_atlas.rs Prefer UVec2 when working with texture dimensions () 2024-02-25 15:23:04 +00:00
font_atlas_set.rs Prefer UVec2 when working with texture dimensions () 2024-02-25 15:23:04 +00:00
font_loader.rs Removed anyhow () 2023-10-06 07:20:13 +00:00
glyph_brush.rs Prefer UVec2 when working with texture dimensions () 2024-02-25 15:23:04 +00:00
lib.rs Use warn_once where relevant instead of manually implementing a single warn check () 2024-02-05 21:05:43 +00:00
pipeline.rs Use warn_once where relevant instead of manually implementing a single warn check () 2024-02-05 21:05:43 +00:00
text.rs Rename bevy_render::Color to LegacyColor () 2024-02-24 21:35:32 +00:00
text2d.rs Prefer UVec2 when working with texture dimensions () 2024-02-25 15:23:04 +00:00