mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-24 17:37:22 +03:00
drawing border nodes differently
This commit is contained in:
parent
8c2db6de82
commit
f243048c45
@ -282,3 +282,5 @@ can begin or end.
|
||||
- manually marking them?
|
||||
- draw the FSM for cars/peds
|
||||
- trips starting/ending at border nodes short-circuit some steps
|
||||
|
||||
What about border nodes where the sidewalk can cross over, but the driving lane leads nowhere?
|
||||
|
@ -19,6 +19,7 @@ pub struct DrawIntersection {
|
||||
sidewalk_corners: Vec<Polygon>,
|
||||
center: Pt2D,
|
||||
has_traffic_signal: bool,
|
||||
is_border: bool,
|
||||
should_draw_stop_sign: bool,
|
||||
}
|
||||
|
||||
@ -36,6 +37,7 @@ impl DrawIntersection {
|
||||
crosswalks: calculate_crosswalks(inter.id, map),
|
||||
sidewalk_corners: calculate_corners(inter.id, map),
|
||||
has_traffic_signal: inter.has_traffic_signal,
|
||||
is_border: inter.is_border(map),
|
||||
should_draw_stop_sign: !inter.has_traffic_signal && !inter.is_degenerate(),
|
||||
}
|
||||
}
|
||||
@ -85,6 +87,10 @@ impl Renderable for DrawIntersection {
|
||||
|
||||
fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, ctx: Ctx) {
|
||||
let color = opts.color.unwrap_or_else(|| {
|
||||
if self.is_border {
|
||||
return ctx.cs.get("border intersection", Color::rgb(50, 205, 50));
|
||||
}
|
||||
|
||||
let changed = if let Some(s) = ctx.control_map.traffic_signals.get(&self.id) {
|
||||
s.is_changed()
|
||||
} else if let Some(s) = ctx.control_map.stop_signs.get(&self.id) {
|
||||
|
@ -5,7 +5,7 @@ use dimensioned::si;
|
||||
use geom::Pt2D;
|
||||
use std::collections::BTreeSet;
|
||||
use std::fmt;
|
||||
use {LaneID, RoadID, TurnID};
|
||||
use {LaneID, Map, RoadID, TurnID};
|
||||
|
||||
// TODO reconsider pub usize. maybe outside world shouldnt know.
|
||||
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord, Serialize, Deserialize)]
|
||||
@ -51,6 +51,16 @@ impl Intersection {
|
||||
self.roads.len() == 2
|
||||
}
|
||||
|
||||
pub fn is_border(&self, map: &Map) -> bool {
|
||||
// Bias for driving
|
||||
if !self.is_dead_end() {
|
||||
return false;
|
||||
}
|
||||
let has_driving_in = self.incoming_lanes.iter().find(|l| map.get_l(**l).is_driving()).is_some();
|
||||
let has_driving_out = self.outgoing_lanes.iter().find(|l| map.get_l(**l).is_driving()).is_some();
|
||||
has_driving_in != has_driving_out
|
||||
}
|
||||
|
||||
pub fn dump_debug(&self) {
|
||||
println!("{}", abstutil::to_json(self));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user