Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional transparency passthrough for sprite backend with bevy_picking #16388

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

vandie
Copy link

@vandie vandie commented Nov 14, 2024

Objective

Solution

Testing

  • Ran Sprite Picking example to check it was working both with transparency enabled and disabled
  • ModPicking version is currently in use in my own isometric game where this has been an extremely noticeable issue

Showcase

Sprite Picking Text

Copy link
Contributor

Welcome, new contributor!

Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨

Copy link
Contributor

@mgi388 mgi388 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m excited for this change. I did a quick visual code review but haven’t tested it yet.

/// Off by default for backwards compatibility. This setting is provided to give you fine-grained
/// control over if transparency on sprites is ignored.
pub passthrough_transparency: bool,
/// How Opaque does part of a sprite need to be in order count as none-transparent (defaults to 10)
Copy link
Contributor

@mgi388 mgi388 Nov 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate in the docs what the units are? 10 what? What is a valid range I could use, as a user?

#[reflect(Resource, Default)]
pub struct SpriteBackendSettings {
/// When set to `true` picking will ignore any part of a sprite which is transparent
/// Off by default for backwards compatibility. This setting is provided to give you fine-grained
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is mainly off by default for performance?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest with you, I didn't want it to change the default behaviour in a way that would break existing use cases. I tend to favour opt in than opt out.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just saw/remembered per the linked issue @alice-i-cecile seems to suggest it is on by default with a way to turn off. As a user, I want this OOTB myself so on by default makes sense to me, for what it’s worth. To avoid churn feel free to wait for other reviews before changing your code.

impl Default for SpriteBackendSettings {
fn default() -> Self {
Self {
passthrough_transparency: false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mix of transparency as a prefix and suffix feels like this should have a different name, but I don’t have any good suggestions right now.

Also, worth checking if transparency is the right term compared to alpha. No strong opinions but it stood out to me as a question.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're right. Alpha is absolutely a better term. Updating.

@mgi388
Copy link
Contributor

mgi388 commented Nov 14, 2024

@vandie also see #14929 I think your PR fixes it.

@vandie
Copy link
Author

vandie commented Nov 14, 2024

@vandie also see #14929 I think your PR fixes it.

I think it does yeah.

@mgi388
Copy link
Contributor

mgi388 commented Nov 14, 2024

@vandie also see #14929 I think your PR fixes it.

I think it does yeah.

You can put “Fixes #{id}” in your PR description so merging this PR closes the issue as fixed. 😌

@kristoff3r kristoff3r added S-Needs-Review Needs reviewer attention (from anyone!) to move forward A-Picking Pointing at and selecting objects of all sorts D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes labels Nov 14, 2024
@alice-i-cecile alice-i-cecile added this to the 0.16 milestone Nov 14, 2024
@alice-i-cecile alice-i-cecile added the M-Needs-Release-Note Work that should be called out in the blog due to impact label Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Picking Pointing at and selecting objects of all sorts D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes M-Needs-Release-Note Work that should be called out in the blog due to impact S-Needs-Review Needs reviewer attention (from anyone!) to move forward
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for alpha-testing in sprite picking backend
5 participants