mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-11 08:15:34 +03:00
Handle editing just the width of one lane
This commit is contained in:
parent
188bfc6329
commit
18589cb083
@ -148,7 +148,7 @@ impl SimpleState<App> for LaneEditor {
|
|||||||
app,
|
app,
|
||||||
app.primary.map.get_l(self.l).parent,
|
app.primary.map.get_l(self.l).parent,
|
||||||
)),
|
)),
|
||||||
"Modify entire road" => Transition::Push(crate::edit::roads::RoadEditor::new(
|
"Modify entire road" => Transition::Replace(crate::edit::roads::RoadEditor::new(
|
||||||
ctx,
|
ctx,
|
||||||
app,
|
app,
|
||||||
app.primary.map.get_l(self.l).parent,
|
app.primary.map.get_l(self.l).parent,
|
||||||
|
@ -448,11 +448,16 @@ fn recalculate_turns(id: IntersectionID, map: &mut Map, effects: &mut EditEffect
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn modify_lanes(map: &mut Map, r: RoadID, lanes_ltr: Vec<LaneSpec>, effects: &mut EditEffects) {
|
fn modify_lanes(map: &mut Map, r: RoadID, lanes_ltr: Vec<LaneSpec>, effects: &mut EditEffects) {
|
||||||
|
let new_width = lanes_ltr
|
||||||
|
.iter()
|
||||||
|
.fold(Distance::ZERO, |sum, x| sum + x.width);
|
||||||
|
let old_width = map.get_r(r).get_half_width(map);
|
||||||
|
|
||||||
let road = &mut map.roads[r.0];
|
let road = &mut map.roads[r.0];
|
||||||
|
|
||||||
// TODO Widening roads is still experimental. If we're just modifying lane types, preserve
|
// TODO Widening roads is still experimental. If we're just modifying lane types, preserve
|
||||||
// LaneIDs.
|
// LaneIDs.
|
||||||
if road.lanes_ltr.len() == lanes_ltr.len() {
|
if road.lanes_ltr.len() == lanes_ltr.len() && old_width == new_width {
|
||||||
for (idx, spec) in lanes_ltr.into_iter().enumerate() {
|
for (idx, spec) in lanes_ltr.into_iter().enumerate() {
|
||||||
let lane = map.lanes.get_mut(&road.lanes_ltr[idx].0).unwrap();
|
let lane = map.lanes.get_mut(&road.lanes_ltr[idx].0).unwrap();
|
||||||
road.lanes_ltr[idx].2 = spec.lt;
|
road.lanes_ltr[idx].2 = spec.lt;
|
||||||
@ -465,9 +470,6 @@ fn modify_lanes(map: &mut Map, r: RoadID, lanes_ltr: Vec<LaneSpec>, effects: &mu
|
|||||||
lane.lane_center_pts = lane.lane_center_pts.reversed();
|
lane.lane_center_pts = lane.lane_center_pts.reversed();
|
||||||
lane.dir = spec.dir;
|
lane.dir = spec.dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO If width is changing and the number of lanes isn't, we'll ignore the width
|
|
||||||
// change. Don't use this old code-path for that!
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user