// Tries to find a squid/squid-limb underneath a point to select
Tries to find a squid/squid-limb underneath a point to select
Tries to find a squid / squid - limb underneath a point to select
pub fn try_select(&mut self, underneath: glm::Vec2, camera: &Camera, existing_selections: &[Selection]) -> TrySelectResult {
        let highest_squids: Vec<SquidRef> = self.get_squids_highest().collect();
        let world_mouse = camera.apply_reverse(&underneath);
        for self_reference in highest_squids {
            if let Some(squid) = self.get_mut(self_reference) {
                let already_selected = selection_contains(existing_selections, self_reference);
                // If the squid is already selected, and we are trying to select over on-top of one
                // of its handles, then return to just preserve the existing selection
                if already_selected {
                    for region in &squid.get_opaque_handles() {
                        if glm::distance(region, &world_mouse) < 2.0 * squid::HANDLE_RADIUS {
                            return TrySelectResult::Preserve;
                        }
                    }
                }
                if let Some(result) = squid.try_select(underneath, camera, self_reference) {
                    return if !already_selected {
                        // Found selection to append-to/replace existing ones
                        TrySelectResult::New(result)
                    } else {
                        // Not new selection found, but preserve existing selection(s)
                        TrySelectResult::Preserve
                    };
                }
            }
        }
        // No new selection found, and don't preserve existing selection(s)
        TrySelectResult::Discard
    }
pub fn try_select ( & mut self , underneath : glm :: Vec2 , camera : & Camera , existing_selections : & [ Selection ] ) -> TrySelectResult { let highest_squids : Vec < SquidRef > = self . get_squids_highest ( ) . collect ( ) ; let world_mouse = camera . apply_reverse ( & underneath ) ; for self_reference in highest_squids { if let Some ( squid ) = self . get_mut ( self_reference ) { let already_selected = selection_contains ( existing_selections , self_reference ) ; // If the squid is already selected, and we are trying to select over on-top of one // of its handles, then return to just preserve the existing selection if already_selected { for region in & squid . get_opaque_handles ( ) { if glm :: distance ( region , & world_mouse ) < 2.0 * squid :: HANDLE_RADIUS { return TrySelectResult :: Preserve ; } } } if let Some ( result ) = squid . try_select ( underneath , camera , self_reference ) { return if ! already_selected { // Found selection to append-to/replace existing ones TrySelectResult :: New ( result ) } else { // Not new selection found, but preserve existing selection(s) TrySelectResult :: Preserve } ; } } } // No new selection found, and don't preserve existing selection(s) TrySelectResult :: Discard }
Tries to find a squid/squid-limb underneath a point to select
Tries to find a squid / squid - limb underneath a point to select
&mut self
underneath
glm::Vec2
camera
&Camera
existing_selections
&[Selection]