bevy/crates/bevy_sprite/src
James Lucas 0f1eebed38
Fixing sprite pixel space point computation for sprites with zero custom_size (#19907)
# Objective

Current implementation of `Sprite::compute_pixel_space_point` always
returns the sprite centre as an `Ok` point when the `custom_size` is set
to `Vec2::ZERO`. This leads to unexpected behaviour. For example, it
causes these sprites to block all interactions with other sprites in the
picking backend (under default settings). This small PR:

- Fixes sprite pixel space point computation for sprites with zero
custom_size
- Resolves issue #19880.

## Solution

We handle the zero custom_size case explicitly and return
`Err(point_relative_to_sprite_center)` instead of
`Ok(point_relative_to_texture)`.

## Testing

Implemented a new test for zero custom_size sprites within the
`bevy_sprite::sprite` module. Also verified that the example from issue
#19880 is behaving as expected.

No further testing is required.

- How can other people (reviewers) test your changes? Is there anything
specific they need to know?

Can run the simple application example from the linked issue. Or
evaluate the implemented test.

---------

Co-authored-by: James Lucas <jalucas@nvidia.com>
2025-07-03 17:43:32 +00:00
..
mesh2d Make render and compute pipeline descriptors defaultable. (#19903) 2025-07-02 18:47:27 +00:00
render Make render and compute pipeline descriptors defaultable. (#19903) 2025-07-02 18:47:27 +00:00
texture_slice Fix Anchor component inconsistancies (#18393) 2025-05-21 15:32:04 +00:00
tilemap_chunk use wgpu TextureDataOrder (#19829) 2025-06-27 06:57:29 +00:00
lib.rs Add TilemapChunk rendering (#18866) 2025-06-23 23:55:10 +00:00
picking_backend.rs Fix sprite picking viewport (#19747) 2025-06-30 22:46:44 +00:00
sprite.rs Fixing sprite pixel space point computation for sprites with zero custom_size (#19907) 2025-07-03 17:43:32 +00:00