aevyrie / bevy_mod_picking

Picking and pointer events for Bevy.
https://crates.io/crates/bevy_mod_picking
Apache License 2.0
764 stars 170 forks source link

Bevy UI node with Display::None is always hit #320

Closed keis closed 2 months ago

keis commented 5 months ago

While porting over to bevy 0.13 I noticed an issue with the tooltips I have in my UI that I toggle between Display::Flex / Display::None where a hidden one would show up as hit even when the pointer was nowhere near.

I tracked this down to L161 of backends/bevy_picking_ui/src/lib.rs which does the following

            let relative_cursor_position = (*cursor_position - node_rect.min) / node_rect.size();

            if visible_rect
                .normalize(node_rect)
                .contains(relative_cursor_position)
            {

Which ends up with both the normalized rect and relative_cursor_position as -inf through division by zero

Filtering zero sized nodes out resolves the issue but there's probably a better way