mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-28 03:35:51 +03:00
improve turn markings on lanes
This commit is contained in:
parent
3364cd1d0c
commit
669fd886d5
@ -32,6 +32,9 @@
|
||||
- yellow and white lines intersect cars and turn icons and such
|
||||
- who should own drawing them?
|
||||
|
||||
- arrows
|
||||
- sometimes head is separated from body. I314 montlake ped turn arrows
|
||||
|
||||
## More data
|
||||
|
||||
- lanes: https://data-seattlecitygis.opendata.arcgis.com/datasets/49d417979fec452981a068ca078e7070_3
|
||||
|
@ -5,7 +5,7 @@ use abstutil::Timer;
|
||||
use ezgui::{Color, Drawable, GfxCtx, Prerender};
|
||||
use geom::{Circle, Distance, Line, PolyLine, Polygon};
|
||||
use map_model::{
|
||||
IntersectionType, Lane, LaneID, LaneType, Map, Road, Turn, LANE_THICKNESS, PARKING_SPOT_LENGTH,
|
||||
IntersectionType, Lane, LaneID, LaneType, Map, Road, LANE_THICKNESS, PARKING_SPOT_LENGTH,
|
||||
};
|
||||
|
||||
pub struct DrawLane {
|
||||
@ -255,44 +255,33 @@ fn calculate_turn_markings(
|
||||
{
|
||||
return results;
|
||||
}
|
||||
|
||||
for turn in map.get_turns_from_lane(lane.id) {
|
||||
results.extend(turn_markings(turn, map, cs, timer));
|
||||
if lane.length() < Distance::meters(7.0) {
|
||||
return results;
|
||||
}
|
||||
results
|
||||
}
|
||||
|
||||
fn turn_markings(
|
||||
turn: &Turn,
|
||||
map: &Map,
|
||||
cs: &ColorScheme,
|
||||
timer: &mut Timer,
|
||||
) -> Vec<(Color, Polygon)> {
|
||||
let lane = map.get_l(turn.id.src);
|
||||
let len = lane.length();
|
||||
if len < Distance::meters(7.0) {
|
||||
return Vec::new();
|
||||
}
|
||||
|
||||
let common_base = lane
|
||||
.lane_center_pts
|
||||
.exact_slice(len - Distance::meters(7.0), len - Distance::meters(5.0));
|
||||
let base_polygon = common_base.make_polygons(Distance::meters(0.1));
|
||||
let turn_line = PolyLine::new(vec![
|
||||
common_base.last_pt(),
|
||||
common_base
|
||||
.last_pt()
|
||||
.project_away(LANE_THICKNESS / 2.0, turn.angle()),
|
||||
]);
|
||||
|
||||
let color = cs.get_def("turn restrictions on lane", Color::WHITE);
|
||||
let mut result = vec![(color, base_polygon)];
|
||||
result.extend(
|
||||
turn_line
|
||||
.make_arrow(Distance::meters(0.05))
|
||||
let thickness = Distance::meters(0.2);
|
||||
|
||||
let common_base = lane.lane_center_pts.exact_slice(
|
||||
lane.length() - Distance::meters(7.0),
|
||||
lane.length() - Distance::meters(5.0),
|
||||
);
|
||||
results.push((color, common_base.make_polygons(thickness)));
|
||||
|
||||
// TODO Maybe draw arrows per target road, not lane
|
||||
for turn in map.get_turns_from_lane(lane.id) {
|
||||
results.extend(
|
||||
PolyLine::new(vec![
|
||||
common_base.last_pt(),
|
||||
common_base
|
||||
.last_pt()
|
||||
.project_away(LANE_THICKNESS / 2.0, turn.angle()),
|
||||
])
|
||||
.make_arrow(thickness)
|
||||
.with_context(timer, format!("turn_markings for {}", turn.id))
|
||||
.into_iter()
|
||||
.map(|p| (color, p)),
|
||||
);
|
||||
result
|
||||
);
|
||||
}
|
||||
results
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ impl DrawPedestrian {
|
||||
cs: &ColorScheme,
|
||||
) -> DrawPedestrian {
|
||||
let turn_arrow = if let Some(t) = input.waiting_for_turn {
|
||||
// TODO this isn't quite right, but good enough for now
|
||||
let angle = map.get_t(t).angle();
|
||||
Some(
|
||||
PolyLine::new(vec![
|
||||
|
@ -376,8 +376,9 @@ impl PolyLine {
|
||||
|
||||
// TODO One polygon, please :)
|
||||
pub fn make_arrow(&self, thickness: Distance) -> Warn<Vec<Polygon>> {
|
||||
// TODO Remove overlap between the triangle and last line segment
|
||||
let head_size = thickness * 2.0;
|
||||
// triangle_height is wrong. Sometimes there's overlap, sometimes there's a gap. But the
|
||||
// trig seems so simple...
|
||||
let triangle_height = (head_size / 2.0).sqrt();
|
||||
if self.last_line().length() < triangle_height {
|
||||
return Warn::warn(
|
||||
|
Loading…
Reference in New Issue
Block a user