From 3eef3acb3434626ffa33cfb85b979c5eab0ff90a Mon Sep 17 00:00:00 2001 From: KOKI Date: Fri, 26 Aug 2022 14:27:42 +0900 Subject: [PATCH] fix ConstantOnly bug of port snapping --- egui_node_graph/src/editor_ui.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/egui_node_graph/src/editor_ui.rs b/egui_node_graph/src/editor_ui.rs index d573e48..5ecfc60 100644 --- a/egui_node_graph/src/editor_ui.rs +++ b/egui_node_graph/src/editor_ui.rs @@ -186,12 +186,13 @@ where ports .iter() .find_map(|(port_id, _)| { - let port_pos = port_locations[&port_id.into()]; - if port_pos.distance(cursor_pos) < DISTANCE_TO_CONNECT { - Some(port_pos) - } else { - None - } + port_locations.get(&port_id.into()).and_then(|port_pos| { + if port_pos.distance(cursor_pos) < DISTANCE_TO_CONNECT { + Some(*port_pos) + } else { + None + } + }) }) .unwrap_or(cursor_pos) }