mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-24 23:15:24 +03:00
debugging turn-making funkiness
This commit is contained in:
parent
d22d955dbb
commit
ab986a3a8a
@ -59,7 +59,7 @@ impl WarpState {
|
||||
fn warp(line: String, map: &Map, canvas: &mut Canvas, selection_state: &mut SelectionState) {
|
||||
let pt = match usize::from_str_radix(&line[1..line.len()], 10) {
|
||||
Ok(idx) => match line.chars().next().unwrap() {
|
||||
'r' => {
|
||||
'l' => {
|
||||
let id = LaneID(idx);
|
||||
*selection_state = SelectionState::SelectedLane(id, None);
|
||||
map.get_l(id).first_pt()
|
||||
@ -79,12 +79,12 @@ fn warp(line: String, map: &Map, canvas: &mut Canvas, selection_state: &mut Sele
|
||||
geometry::center(&map.get_p(id).points)
|
||||
}
|
||||
_ => {
|
||||
println!("{} isn't a valid ID; Should be [ribp][0-9]+", line);
|
||||
println!("{} isn't a valid ID; Should be [libp][0-9]+", line);
|
||||
return;
|
||||
}
|
||||
},
|
||||
Err(_) => {
|
||||
println!("{} isn't a valid ID; Should be [ribp][0-9]+", line);
|
||||
println!("{} isn't a valid ID; Should be [libp][0-9]+", line);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
@ -173,6 +173,8 @@ impl Map {
|
||||
pub fn edit_lane_type(&mut self, lane: LaneID, new_type: LaneType) {
|
||||
assert_ne!(self.get_l(lane).lane_type, new_type);
|
||||
self.lanes[lane.0].lane_type = new_type;
|
||||
let parent = self.get_l(lane).parent;
|
||||
self.roads[parent.0].edit_lane_type(lane, new_type);
|
||||
|
||||
// Recalculate all of the turns at the two connected intersections.
|
||||
let intersections = self.get_l(lane).intersections();
|
||||
|
@ -36,6 +36,15 @@ impl PartialEq for Road {
|
||||
}
|
||||
|
||||
impl Road {
|
||||
pub fn edit_lane_type(&mut self, lane: LaneID, new_type: LaneType) {
|
||||
let (dir, offset) = self.dir_and_offset(lane);
|
||||
if dir {
|
||||
self.children_forwards[offset] = (lane, new_type);
|
||||
} else {
|
||||
self.children_backwards[offset] = (lane, new_type);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_lane_types(&self) -> (Vec<LaneType>, Vec<LaneType>) {
|
||||
(
|
||||
self.children_forwards.iter().map(|pair| pair.1).collect(),
|
||||
|
Loading…
Reference in New Issue
Block a user