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

Per Entity sprite picking (and maybe friends) opt-out #17108

Open
Phoqinu opened this issue Jan 3, 2025 · 2 comments
Open

Per Entity sprite picking (and maybe friends) opt-out #17108

Phoqinu opened this issue Jan 3, 2025 · 2 comments
Labels
A-Picking Pointing at and selecting objects of all sorts C-Performance A change motivated by improving speed, memory usage or compile times D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Needs-Design This issue requires design work to think about how it would best be accomplished

Comments

@Phoqinu
Copy link
Contributor

Phoqinu commented Jan 3, 2025

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

Currently sprite_picking is relatively expensive, I did some light testing with tracy and 200k sprites with like only 2k of them being in camera view can result in the sprite_picking taking 500µs. Which is not much but frame time was 2.66ms so it took "only" almost 20% of frame time.

I don't need picking for my sprites and in debug mode - without any bevy optimizations - the performace penalty is so big that you can reach single digit fps.

My specific use-case aside I can imagine that some people would want picking only for some sprites and they might want to turn off picking for the rest.

What solution would you like?

For sprite_picking a simple component:

#[derive(Debug, Component)]
pub struct NoSpritePicking;

then in the sprite_picking system sprite query could be modified from:

sprite_query: Query<(
        Entity,
        &Sprite,
        &GlobalTransform,
        Option<&PickingBehavior>,
        &ViewVisibility,
    )>,

to

sprite_query: Query<(
        Entity,
        &Sprite,
        &GlobalTransform,
        Option<&PickingBehavior>,
        &ViewVisibility,
    ), Without<NoSpritePicking>>,

Then users if they don't want picking for their sprites they can just add NoSpritePicking component to sprite entity.

What alternative(s) have you considered?

I tried adding PickingBehavior::IGNORE to my sprites but that did not bring any speed-up.

Maybe it could result in some weird behavior with PickingBehavior ? idk

I think it would be nice to have similar marking ignore components for other backends.
Maybe even global NoPicking component or something ?

Faster and better sprite_picking system ?- It's currently doing filtering, sorting and filtering on all sprites...

Picking being opt-in ?

Additional context

Red - current default system with/out PickingBehavior
Yellow - my proposed feature with NoSpritePicking on my sprites and modified system
200k sprites (2k on camera, rest off-camera), release mode

(This is for my use-case, ofc different apps won't probably see similar speed-up)
Image

@Phoqinu Phoqinu added C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Jan 3, 2025
@alice-i-cecile alice-i-cecile added C-Performance A change motivated by improving speed, memory usage or compile times S-Needs-Design This issue requires design work to think about how it would best be accomplished A-Picking Pointing at and selecting objects of all sorts and removed C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Jan 3, 2025
@alice-i-cecile
Copy link
Member

alice-i-cecile commented Jan 3, 2025

We should consider making sprite picking opt-in instead. Unlike UI elements, most sprites shouldn't be pickable.

@BenjaminBrienen BenjaminBrienen added the D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes label Jan 3, 2025
@rparrett
Copy link
Contributor

rparrett commented Jan 5, 2025

Related #16903

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 C-Performance A change motivated by improving speed, memory usage or compile times D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Needs-Design This issue requires design work to think about how it would best be accomplished
Projects
None yet
Development

No branches or pull requests

4 participants