MCPcopy Create free account
hub / github.com/donkeyteethUX/iced_plot / request_pick_hit

Method request_pick_hit

src/picking.rs:102–133  ·  view source on GitHub ↗
(
        &mut self,
        instance_id: u64,
        cursor: Vec2,
        hover_radius_px: f32,
        force_cpu: bool,
        points: &[Point],
        series: &[SeriesSpan],
        camera: &Ca

Source from the content-addressed store, hash-verified

100 /// Returns an immediate hit when using cache/CPU. For GPU, submits a request and returns None.
101 #[allow(clippy::too_many_arguments)]
102 pub(crate) fn request_pick_hit(
103 &mut self,
104 instance_id: u64,
105 cursor: Vec2,
106 hover_radius_px: f32,
107 force_cpu: bool,
108 points: &[Point],
109 series: &[SeriesSpan],
110 camera: &Camera,
111 bounds: &Rectangle,
112 valid_point_id: impl Fn(&PointId) -> bool,
113 ) -> Option<PointId> {
114 if let Some(point) = self.last_hover_cache
115 && valid_point_id(&point)
116 {
117 return Some(point);
118 }
119
120 if force_cpu || points.len() < CPU_PICK_THRESHOLD {
121 if let Some(point) =
122 cpu_pick_hit(points, series, camera, bounds, cursor, hover_radius_px)
123 && valid_point_id(&point)
124 {
125 return Some(point);
126 }
127 } else {
128 self.submit_gpu_request(instance_id, cursor, hover_radius_px);
129 // Mark this seq as a pick request.
130 self.pending_gpu_pick_seq = Some(self.pick_seq);
131 }
132 None
133 }
134
135 /// Consume and interpret a GPU pick result (if available).
136 pub(crate) fn consume_gpu_result(

Callers 1

pick_hitMethod · 0.80

Calls 2

cpu_pick_hitFunction · 0.85
submit_gpu_requestMethod · 0.80

Tested by

no test coverage detected