bevyengine / bevyengine/bevy

`Sprite` culling does not update `Aabb` when `Handle<Image>` changes

Open
#11,892 0 comments 1 reaction 0 assignees View on GitHub
A-Assets A-Rendering C-Bug
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## Bevy version

0.12

## What you did

I upgraded from Bevy 0.10 to 0.12 and noticed that sprites would disappear before they had completely left the camera view. I assume this is just because sprite culling was implemented (with bugs) after 0.10.

## What went wrong

Here's a video. Notice how the spinning cards will pop out when their **center** leaves the view.

https://github.com/bevyengine/bevy/assets/3229981/4d465de8-c593-4991-81e6-b64ac07a2c3c

## Additional information

I know what the root cause is. When `Sprite`s are spawned, for some reason they have a "placeholder" `Image` asset which is only 1x1 pixels. The function `calculate_bounds_2d` relies on the `Image` to calculate bounds when there is no `custom_size` set on the `Sprite`. However, the change detection on this query does not account for `Changed>`.

https://github.com/bevyengine/bevy/blob/fe777d5c3fba64bec250b8ced3a6ba98fbd07a64/crates/bevy_sprite/src/lib.rs#L130-L165

I believe the addition of `Changed>` is necessary but not sufficient to completely fix this issue, as we still need to fix https://github.com/bevyengine/bevy/issues/5069.

Related: https://github.com/bevyengine/bevy/issues/10587

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.