From 592f284be3eedf045ba2f957110ab57a4293931a Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Tue, 19 Jun 2018 10:26:27 -0700 Subject: [PATCH] fix center lines for two-ways --- TODO.md | 2 +- docs/backlog.md | 1 + editor/src/plugins/selection.rs | 2 ++ editor/src/render/mod.rs | 4 ++-- geom/src/road.rs | 5 +++-- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/TODO.md b/TODO.md index 99e00a9779..b5cf12e105 100644 --- a/TODO.md +++ b/TODO.md @@ -46,12 +46,12 @@ - multiple lanes - display + mouseover parking lane and sidewalk - - make the center lines in geom layer work (use debug mode to verify) - something broke curved roads - make extra lanes for oneways work - have to switch from Centered to DrivingDirection somehow - either translate points up-front and be normal or fix geom layer (for turns and intersections) + - dont allow cars on non-driving lanes :) - model cars parking - maybe render numbers on the cars to distinguish them - document the FSM (on lane driving, waiting, turning, parking, etc) diff --git a/docs/backlog.md b/docs/backlog.md index 7bcc1e130b..254fee147f 100644 --- a/docs/backlog.md +++ b/docs/backlog.md @@ -20,6 +20,7 @@ - and maybe to recalculate fixedish things if they change? - more advanced road modeling, like https://wiki.openstreetmap.org/wiki/Proposed_features/Street_area +- yellow center lines eat into the width of one lane arbitrarily ## Conga line idea diff --git a/editor/src/plugins/selection.rs b/editor/src/plugins/selection.rs index 9729feb1dd..7db5269c61 100644 --- a/editor/src/plugins/selection.rs +++ b/editor/src/plugins/selection.rs @@ -174,6 +174,8 @@ impl SelectionState { draw_map.get_t(turn.id).draw_full(g, render::TURN_COLOR); }, } + // TODO tmp + draw_map.get_r(id).draw_debug(g, geom_map.get_r(id)); } SelectionState::TooltipRoad(id) => { canvas.draw_mouse_tooltip(g, &draw_map.get_r(id).tooltip_lines(map, geom_map)); diff --git a/editor/src/render/mod.rs b/editor/src/render/mod.rs index 24cba69008..f813e62d2a 100644 --- a/editor/src/render/mod.rs +++ b/editor/src/render/mod.rs @@ -25,8 +25,8 @@ const BIG_ARROW_TIP_LENGTH: f64 = 1.0; const TURN_ICON_ARROW_TIP_LENGTH: f64 = BIG_ARROW_TIP_LENGTH * 0.8; const TURN_ICON_ARROW_LENGTH: f64 = 2.0; -pub const DEBUG_COLOR: Color = canvas::PURPLE; -pub const BRIGHT_DEBUG_COLOR: Color = [1.0, 0.1, 0.55, 1.0]; +pub const DEBUG_COLOR: Color = canvas::RED; +pub const BRIGHT_DEBUG_COLOR: Color = [0.8, 0.1, 0.1, 1.0]; pub const ROAD_COLOR: Color = canvas::BLACK; pub const PARKING_COLOR: Color = canvas::PURPLE; pub const SIDEWALK_COLOR: Color = canvas::GREEN; diff --git a/geom/src/road.rs b/geom/src/road.rs index 64938cdf3a..077da4513b 100644 --- a/geom/src/road.rs +++ b/geom/src/road.rs @@ -41,6 +41,7 @@ impl GeomRoad { pts[num_pts - 1] = Pt2D::from(new_last_pt); // TODO handle offset + let offset = road.offset as f64; let lane_center_shift = if road.one_way_road { 0.0 } else if road.use_yellow_center_lines { @@ -48,9 +49,9 @@ impl GeomRoad { // shouldn't match either lane. Needs to be its own thing, or adjust the bbox. (LANE_THICKNESS / 2.0) + (BIG_ARROW_THICKNESS / 2.0) } else { - (LANE_THICKNESS / 2.0) + LANE_THICKNESS * (offset + 0.5) }; - // TODO when drawing cars along these lines, do we have the line overlap problem? + // TODO when drawing cars along these lines, do we have the line overlap problem? yes. let lane_center_lines: Vec<(Pt2D, Pt2D)> = pts.windows(2) .map(|pair| { geometry::shift_line_perpendicularly_in_driving_direction(