Skip to content

Commit

Permalink
fix: debug output, sub overflow gridnode and station overlap edge loc…
Browse files Browse the repository at this point in the history
…al_search
  • Loading branch information
CalliEve committed Nov 1, 2024
1 parent 56b244b commit 126b87d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/algorithm/local_search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,13 @@ pub fn try_station_pos(
}
}

occupied.insert(
station_pos,
target_station
.get_id()
.into(),
);

Ok(StationPos::new(
target_station,
edges_after,
Expand Down
6 changes: 3 additions & 3 deletions src/components/molecules/settings_modal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ where
on_input=move |b| {
map_state
.update(|state| state.update_algorithm_settings(|settings| {
if b {
settings.set_log_level(LogType::Debug);
if settings.log_level == LogType::Warn {
*settings = settings.set_log_level(LogType::Debug);
} else {
settings.set_log_level(LogType::Warn);
*settings = settings.set_log_level(LogType::Warn);
}
}));
}/>
Expand Down
1 change: 1 addition & 0 deletions src/components/state/canvas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ impl CanvasState {
}

/// Returns true if the given grid node is on the canvas.
#[inline]
pub fn is_on_canvas(&self, node: GridNode) -> bool {
self.x_limit
.0
Expand Down
4 changes: 4 additions & 0 deletions src/models/grid_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ impl GridNode {
/// Translate the [`GridNode`] to a canvas coordinate, given the state of
/// the canvas.
pub fn to_canvas_pos(self, state: CanvasState) -> (f64, f64) {
if !state.is_on_canvas(self) {
return (f64::MIN, f64::MIN);
}

let square_size = state.drawn_square_size();
(
f64::from(
Expand Down

0 comments on commit 126b87d

Please sign in to comment.