bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
36.4k stars 3.59k forks source link

Separate Image asset from its metadata #16355

Open s-puig opened 1 week ago

s-puig commented 1 week ago

What problem does this solve or what need does it fill?

Using texture size can be a common operation in 2d. For instance, it is used by 9-slicing, dynamically placing sprites of arbitrary size or calculating Y-sorting (since it uses the anchor point which uses relative coordinates). Unfortunately, this forces RenderAssetUsages to be in main world even if you don't use the rest of the data.

What solution would you like?

Image metadata to stay accessible in main world. Image data uses RenderAssetUsages like now.

Something like:

struct Image {
  data: Handle<ImageData>,
  // metadata and render asset usages fields
}