was overthinking turn-making... going back to something simple

This commit is contained in:
Dustin Carlino 2018-11-06 08:56:39 -08:00
parent 74b5e2e31e
commit dc70d4eb9a
3 changed files with 19 additions and 20 deletions

View File

@ -105,6 +105,7 @@ Two types of things to render
What're the desired turns?
- the crosswalks shouldn't go to the other_side; they should be N<->S
- 3 ways are different
- the shared corners are... obvious
- both of these should be bidirectional

View File

@ -145,12 +145,15 @@ fn calculate_crosswalks(i: IntersectionID, map: &Map) -> Vec<Vec<Line>> {
let available_length = turn.line.length() - (2.0 * boundary);
if available_length > 0.0 * si::M {
let num_markings = (available_length / tile_every).floor() as usize;
// Shift away so the markings stay fully inside the intersection. Lane center points don't
// line up with the boundary.
let line = turn.line.shift(LANE_THICKNESS / 2.0);
let mut dist_along =
boundary + (available_length - tile_every * (num_markings as f64)) / 2.0;
// TODO Seems to be an off-by-one sometimes
// TODO Seems to be an off-by-one sometimes. Not enough of these.
for _ in 0..=num_markings {
let pt1 = turn.line.dist_along(dist_along);
let pt1 = line.dist_along(dist_along);
// Reuse perp_line. Project away an arbitrary amount
let pt2 = pt1.project_away(1.0, turn.line.angle());
markings.push(perp_line(Line::new(pt1, pt2), LANE_THICKNESS));

View File

@ -184,26 +184,21 @@ fn make_crosswalks(i: &Intersection, map: &Map) -> Vec<Turn> {
// TODO and the mirror ones
for idx1 in 0..roads.len() as isize {
if let Some(l1) = get_incoming_sidewalk(map, i.id, wraparound_get(&roads, idx1).0) {
// Make the crosswalk to the other side
if let Some(l2) = get_outgoing_sidewalk(map, i.id, wraparound_get(&roads, idx1).0) {
result.push(make_turn(i.id, TurnType::Crosswalk, l1, l2));
}
// Find the shared corner
// TODO -1 and not +1 is brittle... must be the angle sorting
if let Some(l2) = get_outgoing_sidewalk(map, i.id, wraparound_get(&roads, idx1 - 1).0) {
let angle_diff = (l1.last_line().angle().normalized_degrees()
- l2.first_line().angle().normalized_degrees()).abs();
if let Some(l3) = get_outgoing_sidewalk(map, i.id, wraparound_get(&roads, idx1 - 1).0) {
result.push(make_turn(i.id, TurnType::SharedSidewalkCorner, l1, l3));
// On some legs of a 3-way intersection (and probably other cases too), the
// adjacent road is a full sidewalk... TODO this is maybe a matter of rendering
//let angle_diff = (l1.last_line().angle().normalized_degrees()
// - l3.first_line().angle().normalized_degrees()).abs();
// TODO tuning
if angle_diff < 30.0 {
result.push(make_turn(i.id, TurnType::Crosswalk, l1, l2));
} else {
result.push(make_turn(i.id, TurnType::SharedSidewalkCorner, l1, l2));
if let Some(l3) =
get_outgoing_sidewalk(map, i.id, wraparound_get(&roads, idx1 - 2).0)
{
let angle_diff = (l1.last_line().angle().normalized_degrees()
- l3.first_line().angle().normalized_degrees()).abs();
// TODO tuning
if angle_diff < 15.0 {
result.push(make_turn(i.id, TurnType::Crosswalk, l1, l3));
}
}
}
}
}
}