bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Add bevy_picking sprite backend

Open jnhyatt opened this issue 1 year ago • 4 comments

Objective

Add bevy_picking sprite backend as part of the bevy_mod_picking upstreamening (#12365).

Solution

More or less a copy/paste from bevy_mod_picking, with the changes here. I'm putting that link here since those changes haven't yet made it through review, so should probably be reviewed on their own.

Testing

I couldn't find any sprite-backend-specific tests in bevy_mod_picking and unfortunately I'm not familiar enough with Bevy's testing patterns to write tests for code that relies on windowing and input. I'm willing to break the pointer hit system into testable blocks and add some more modular tests if that's deemed important enough to block, otherwise I can open an issue for adding tests as follow-up.

Follow-up work

  • More docs/tests
  • Ignore pick events on transparent sprite pixels with potential opt-out

jnhyatt avatar Aug 15 '24 16:08 jnhyatt

This doesn't test against alpha, which might be surprising in a first-party implementation. Would be nice to document on the plugin.

Additionally, it would be courteous to co-author the downstream contributors in a commit here.

aevyrie avatar Aug 17 '24 05:08 aevyrie

This doesn't test against alpha, which might be surprising in a first-party implementation. Would be nice to document on the plugin.

Not sure what you mean by "test against alpha". Could you elaborate? EDIT - By that, do you mean whether or not the sprite is visible due to alpha/invisible texels? I'll add docs for that.

Additionally, it would be courteous to co-author the downstream contributors in a commit here.

Absolutely! I thought I'd opened this in draft and I hadn't planned on it getting merged without crediting you. Since you're the original author, is there anyone else you'd like listed as co-author? I also have to say I've never added a co-author, so I might mess it up a couple times, haha

jnhyatt avatar Aug 19 '24 16:08 jnhyatt

The generated examples/README.md is out of sync with the example metadata in Cargo.toml or the example readme template. Please run cargo run -p build-templated-pages -- update examples to update it, and commit the file change.

github-actions[bot] avatar Aug 19 '24 19:08 github-actions[bot]

Not sure what you mean by "test against alpha". Could you elaborate? EDIT - By that, do you mean whether or not the sprite is visible due to alpha/invisible texels? I'll add docs for that.

Exactly. I think most users would expect fully transparent pixels to not be hittable. Might be something where the backend/component specifies a threshold, so any alpha below that value will be ignored. Doesn't need to be added right now, but would be nice to mention in the plugin docs.

is there anyone else you'd like listed as co-author?

There are a bunch of people who have contributed to this backend. I'd take a look at the commit history here - I'm not sure if there is an easier way to do this: https://github.com/aevyrie/bevy_mod_picking/commits/main/backends/bevy_picking_sprite/src/lib.rs

I also have to say I've never added a co-author, so I might mess it up a couple times, haha

No worries! I think git makes it pretty simple, you just need to add the names/emails separated by newlines in a commit.

aevyrie avatar Aug 19 '24 20:08 aevyrie