diff --git a/data/screenshots/montlake/MANIFEST b/data/screenshots/montlake/MANIFEST index 4cec4fdff0..541936ce8c 100644 --- a/data/screenshots/montlake/MANIFEST +++ b/data/screenshots/montlake/MANIFEST @@ -1,4 +1,4 @@ -cbf06bb9139d8abdf1aaf2bf8770b505 ../data/screenshots/pending_montlake/01x01_i354.png +b65283ebfc9689af9998c9801315ec1f ../data/screenshots/pending_montlake/01x01_i354.png eeede8562e5ab310f8e3694f27f9e3c6 ../data/screenshots/pending_montlake/02x01.png a99ca9a0e9ace213133a66fe6cbc9ab7 ../data/screenshots/pending_montlake/03x01.png 2f428cfbef1329279e98c822fef869c1 ../data/screenshots/pending_montlake/04x01.png @@ -14,13 +14,13 @@ b7ba74eaab17a7f58cb9ef23735ff8ce ../data/screenshots/pending_montlake/06x02.png 8075785da2a85970085083577864f2f0 ../data/screenshots/pending_montlake/02x03_i66.png 04f53200a16a95b4bbb962ea9f6f9028 ../data/screenshots/pending_montlake/03x03.png b49908a81b09fec864d9260fc73e0e7e ../data/screenshots/pending_montlake/04x03_i6.png -941352de7111c94f768fb551ee4c2d2a ../data/screenshots/pending_montlake/05x03_i4.png +e1802c81e84dbd4bf27a6632c192db0e ../data/screenshots/pending_montlake/05x03_i4.png 6675ed768785b92d957d13d906ff529d ../data/screenshots/pending_montlake/06x03_i196.png -89d8607ffaf089b18370903479f6ba0d ../data/screenshots/pending_montlake/01x04_i368.png +cbd78505242e0cf4a454b5913ee95791 ../data/screenshots/pending_montlake/01x04_i368.png bdc8cf5cdbfcf3a68ac26087c80788fd ../data/screenshots/pending_montlake/02x04_i51.png df78fc7e827b6252837a9088326d3513 ../data/screenshots/pending_montlake/03x04.png 55ec583123bdf0be6a2e5d15dc286cf7 ../data/screenshots/pending_montlake/04x04_i147.png -dad12152eec1da7443ef86fcfb5a9263 ../data/screenshots/pending_montlake/05x04_i46.png +2558a1137531173ddc978c57eb4d65c6 ../data/screenshots/pending_montlake/05x04_i46.png feef555fe7dad68d634b1ce029882fa4 ../data/screenshots/pending_montlake/06x04_i49.png f557712b070a1395d2fcd4bc61f7d4e2 ../data/screenshots/pending_montlake/01x05_i113.png 0761b6ccefa0eea8a0c801d443a5cd29 ../data/screenshots/pending_montlake/02x05_i14.png @@ -32,25 +32,25 @@ a31646afeaef75adbbe148742f63c77f ../data/screenshots/pending_montlake/01x06_i22 dcadf47c50bdb1bcb65ec0827afd2cf2 ../data/screenshots/pending_montlake/02x06_i8.png 35ef7fd81a613eed14044b7ec2feba3b ../data/screenshots/pending_montlake/03x06_i0.png 2a10bead713476f759d092848b0d6eae ../data/screenshots/pending_montlake/04x06_i101.png -47e2fea021dbaffe6bcbbfc2e37da3bc ../data/screenshots/pending_montlake/05x06_i109.png +c3191ce942ddc92280cd281493febe8e ../data/screenshots/pending_montlake/05x06_i109.png 17cb95cd6354c1c72e047b41727423c8 ../data/screenshots/pending_montlake/06x06_i20.png dd23f0794403af2d5cd80bce1a8f18ab ../data/screenshots/pending_montlake/01x07_i56.png c4d07a30a8ee84083d04df0c9dee4812 ../data/screenshots/pending_montlake/02x07_i8.png 2bc0ee861fa7d5441dbc716f565d6ed9 ../data/screenshots/pending_montlake/03x07_i54.png 06af124c37b5ed1fbf331de7aaec8073 ../data/screenshots/pending_montlake/04x07_i58.png -49fec80c14bdf53167120cf2355d5ccb ../data/screenshots/pending_montlake/05x07_i32.png +8e8896fb264a3807c095f14882c526f3 ../data/screenshots/pending_montlake/05x07_i32.png a46750d073b83cd61c5f699e07728354 ../data/screenshots/pending_montlake/06x07_i33.png 6af4763d0ee98c5be395cd66f8310a79 ../data/screenshots/pending_montlake/01x08_i18.png e02fb00a29359e87baf65b487c1e305e ../data/screenshots/pending_montlake/02x08_i19.png 408b68dc1ddda25683202c7528c44b76 ../data/screenshots/pending_montlake/03x08_i75.png e23374a63d3ac911a3c1a4abe6a91962 ../data/screenshots/pending_montlake/04x08_i16.png -481e5f69f5059ee2543f04cb9fcf58b1 ../data/screenshots/pending_montlake/05x08_i34.png +e8335ea1fa6ea1110e05bd82d389f371 ../data/screenshots/pending_montlake/05x08_i34.png aa38ae16ecb33958293653f314528aed ../data/screenshots/pending_montlake/06x08_i1.png 6b21668aa6edf13ea5047935abe1dc38 ../data/screenshots/pending_montlake/01x09_i124.png 41b976659673289d28fb546174772f07 ../data/screenshots/pending_montlake/02x09_i125.png c197eddcdc198b0ee319bd8ebf9efaa8 ../data/screenshots/pending_montlake/03x09_i40.png 85e1f95977da186bafe23099fed2bc00 ../data/screenshots/pending_montlake/04x09_i30.png -1de584b6b34c7bafc399df119ed7ac05 ../data/screenshots/pending_montlake/05x09_i24.png +b8c74db0da307c8b0542bdb9880190f3 ../data/screenshots/pending_montlake/05x09_i24.png e6da54a23b6d43c133a120d262364aa1 ../data/screenshots/pending_montlake/06x09_i62.png abb8521955b833a9f208795ce8b171ea ../data/screenshots/pending_montlake/01x10_i252.png 7849a9e4ed174eb18b27d62f77dd5501 ../data/screenshots/pending_montlake/02x10_i336.png @@ -78,7 +78,7 @@ cbcdf204496095dcfb5cc5a1e85a8a2f ../data/screenshots/pending_montlake/05x12.png 2f428cfbef1329279e98c822fef869c1 ../data/screenshots/pending_montlake/06x13.png 2f428cfbef1329279e98c822fef869c1 ../data/screenshots/pending_montlake/01x14.png 2f428cfbef1329279e98c822fef869c1 ../data/screenshots/pending_montlake/02x14.png -430ef8a41cc2d0b2d5b95c73d83d6803 ../data/screenshots/pending_montlake/03x14_i357.png +4142fcf04035dcdf6f2eae06aacc769c ../data/screenshots/pending_montlake/03x14_i357.png 7b8fd1ed56fd6e9a6ac86d5a3e56cc8e ../data/screenshots/pending_montlake/04x14.png c00c27b2f110e6145eda29a71c2163c6 ../data/screenshots/pending_montlake/05x14.png 2f428cfbef1329279e98c822fef869c1 ../data/screenshots/pending_montlake/06x14.png diff --git a/editor/src/render/intersection.rs b/editor/src/render/intersection.rs index 078b6c8ca6..2e6cb470a3 100644 --- a/editor/src/render/intersection.rs +++ b/editor/src/render/intersection.rs @@ -3,7 +3,7 @@ use crate::objects::{DrawCtx, ID}; use crate::render::{DrawCrosswalk, DrawTurn, RenderOptions, Renderable}; use abstutil::Timer; use ezgui::{Color, Drawable, GfxCtx, Prerender, ScreenPt, Text}; -use geom::{Circle, Distance, Duration, Line, Polygon, Pt2D}; +use geom::{Circle, Distance, Duration, Line, PolyLine, Polygon, Pt2D}; use map_model::{ Cycle, Intersection, IntersectionID, IntersectionType, Map, Road, TurnPriority, TurnType, LANE_THICKNESS, @@ -401,10 +401,10 @@ fn calculate_border_arrows(i: &Intersection, r: &Road, timer: &mut Timer) -> Vec }; result.extend( // DEGENERATE_INTERSECTION_HALF_LENGTH is 5m... - Line::new( + PolyLine::new(vec![ line.unbounded_dist_along(Distance::meters(-9.5)), line.unbounded_dist_along(Distance::meters(-0.5)), - ) + ]) .make_arrow(width / 3.0) .with_context(timer, format!("outgoing border arrows for {}", r.id)), ); @@ -424,10 +424,10 @@ fn calculate_border_arrows(i: &Intersection, r: &Road, timer: &mut Timer) -> Vec (r.center_pts.first_line().shift_left(width / 2.0), width) }; result.extend( - Line::new( + PolyLine::new(vec![ line.unbounded_dist_along(Distance::meters(-0.5)), line.unbounded_dist_along(Distance::meters(-9.5)), - ) + ]) .make_arrow(width / 3.0) .with_context(timer, format!("incoming border arrows for {}", r.id)), ); diff --git a/editor/src/render/lane.rs b/editor/src/render/lane.rs index 2168a25d67..aa9edee07a 100644 --- a/editor/src/render/lane.rs +++ b/editor/src/render/lane.rs @@ -3,7 +3,7 @@ use crate::objects::{DrawCtx, ID}; use crate::render::{RenderOptions, Renderable, BIG_ARROW_THICKNESS}; use abstutil::Timer; use ezgui::{Color, Drawable, GfxCtx, Prerender}; -use geom::{Circle, Distance, Line, Polygon}; +use geom::{Circle, Distance, Line, PolyLine, Polygon}; use map_model::{ IntersectionType, Lane, LaneID, LaneType, Map, Road, Turn, LANE_THICKNESS, PARKING_SPOT_LENGTH, }; @@ -278,12 +278,12 @@ fn turn_markings( .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 = Line::new( + 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)]; diff --git a/ezgui/src/drawing.rs b/ezgui/src/drawing.rs index 490ab5b822..a9d696c1df 100644 --- a/ezgui/src/drawing.rs +++ b/ezgui/src/drawing.rs @@ -102,7 +102,7 @@ impl<'a> GfxCtx<'a> { } pub fn draw_arrow(&mut self, color: Color, thickness: Distance, line: &Line) { - self.draw_polygons(color, &line.make_arrow(thickness).unwrap()); + self.draw_polygons(color, &line.to_polyline().make_arrow(thickness).unwrap()); } pub fn draw_circle(&mut self, color: Color, circle: &Circle) { diff --git a/geom/src/line.rs b/geom/src/line.rs index ee3d47cf7b..115d9db295 100644 --- a/geom/src/line.rs +++ b/geom/src/line.rs @@ -1,5 +1,4 @@ use crate::{Angle, Distance, PolyLine, Polygon, Pt2D, EPSILON_DIST}; -use abstutil::Warn; use serde_derive::{Deserialize, Serialize}; use std::fmt; @@ -48,42 +47,6 @@ impl Line { self.to_polyline().make_polygons(thickness) } - // TODO One polygon, please :) - pub fn make_arrow(&self, thickness: Distance) -> Warn> { - let head_size = thickness * 2.0; - let angle = self.angle(); - let triangle_height = (head_size / 2.0).sqrt(); - if self.length() < triangle_height { - return Warn::warn( - Vec::new(), - format!("Can't make_arrow of thickness {} for {}", thickness, self), - ); - } - Warn::ok(vec![ - Polygon::new(&vec![ - //self.pt2(), - //self.pt2().project_away(head_size, angle.rotate_degs(-135.0)), - self.reverse() - .dist_along(triangle_height) - .project_away(thickness / 2.0, angle.rotate_degs(90.0)), - self.pt1() - .project_away(thickness / 2.0, angle.rotate_degs(90.0)), - self.pt1() - .project_away(thickness / 2.0, angle.rotate_degs(-90.0)), - self.reverse() - .dist_along(triangle_height) - .project_away(thickness / 2.0, angle.rotate_degs(-90.0)), - //self.pt2().project_away(head_size, angle.rotate_degs(135.0)), - ]), - Polygon::new(&vec![ - self.pt2(), - self.pt2() - .project_away(head_size, angle.rotate_degs(-135.0)), - self.pt2().project_away(head_size, angle.rotate_degs(135.0)), - ]), - ]) - } - pub fn length(&self) -> Distance { self.pt1().dist_to(self.pt2()) } diff --git a/geom/src/polyline.rs b/geom/src/polyline.rs index df5db43718..d80ed15cb8 100644 --- a/geom/src/polyline.rs +++ b/geom/src/polyline.rs @@ -374,18 +374,30 @@ impl PolyLine { polygons } + // TODO One polygon, please :) pub fn make_arrow(&self, thickness: Distance) -> Warn> { - if self.pts.len() == 2 { - self.last_line().make_arrow(thickness) - } else { - self.last_line().make_arrow(thickness).map(|mut polygons| { - polygons.push( - PolyLine::new(self.pts[0..self.pts.len() - 1].to_vec()) - .make_polygons(thickness), - ); - polygons - }) + // TODO Remove overlap between the triangle and last line segment + let head_size = thickness * 2.0; + let triangle_height = (head_size / 2.0).sqrt(); + if self.last_line().length() < triangle_height { + return Warn::warn( + vec![self.make_polygons(thickness)], + format!("Can't make_arrow of thickness {} for {}", thickness, self), + ); } + + let angle = self.last_line().angle(); + Warn::ok(vec![ + self.exact_slice(Distance::ZERO, self.length() - triangle_height) + .make_polygons(thickness), + Polygon::new(&vec![ + self.last_pt(), + self.last_pt() + .project_away(head_size, angle.rotate_degs(-135.0)), + self.last_pt() + .project_away(head_size, angle.rotate_degs(135.0)), + ]), + ]) } // Also return the angle of the line where the hit was found