mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-23 22:42:32 +03:00
Don't add invalid filters when cycling through possibilities for non-4-way intersections
This commit is contained in:
parent
966dd7955d
commit
8ff0312eec
@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
use abstutil::{deserialize_btreemap, serialize_btreemap};
|
||||
use geom::{Circle, Distance, Line};
|
||||
use map_model::{IntersectionID, Map, RoadID, RoutingParams, TurnID};
|
||||
use map_model::{IntersectionID, Map, PathConstraints, RoadID, RoutingParams, TurnID};
|
||||
use widgetry::mapspace::{DrawUnzoomedShapes, ToggleZoomed};
|
||||
use widgetry::{EventCtx, GeomBatch, GfxCtx};
|
||||
|
||||
@ -200,7 +200,7 @@ impl DiagonalFilter {
|
||||
/// The caller must call this in a `before_edit` / `after_edit` "transaction."
|
||||
pub fn cycle_through_alternatives(app: &mut App, i: IntersectionID) {
|
||||
let map = &app.map;
|
||||
let roads = map.get_i(i).get_roads_sorted_by_incoming_angle(map);
|
||||
let mut roads = map.get_i(i).get_roads_sorted_by_incoming_angle(map);
|
||||
|
||||
if roads.len() == 4 {
|
||||
// 4-way intersections are the only place where true diagonal filters can be placed
|
||||
@ -224,6 +224,16 @@ impl DiagonalFilter {
|
||||
} else if roads.len() > 1 {
|
||||
// Diagonal filters elsewhere don't really make sense. They're equivalent to filtering
|
||||
// one road. Just cycle through those.
|
||||
|
||||
// But skip roads that're aren't filterable
|
||||
roads.retain(|r| {
|
||||
let road = app.map.get_r(*r);
|
||||
// Include non-driveable roads in this check, since we haven't filtered those out yet
|
||||
road.oneway_for_driving().is_none()
|
||||
&& !road.is_deadend(&app.map)
|
||||
&& PathConstraints::Car.can_use_road(road, &app.map)
|
||||
});
|
||||
|
||||
let mut add_filter_to = None;
|
||||
if let Some(idx) = roads
|
||||
.iter()
|
||||
|
Loading…
Reference in New Issue
Block a user