mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-24 09:24:26 +03:00
use start/end line angle of the turn rather than line from start point to end point.
update uses of turn.angle() now that it's relative
This commit is contained in:
parent
3df3ee7aa5
commit
3bb3169ab4
@ -92,8 +92,8 @@ impl DrawBike {
|
||||
draw_default.push(
|
||||
cs.turn_arrow,
|
||||
PolyLine::must_new(vec![
|
||||
body_pos.project_away(body_radius / 2.0, angle.opposite()),
|
||||
body_pos.project_away(body_radius / 2.0, angle),
|
||||
body_pos.project_away(body_radius / 2.0, (facing + angle).opposite()),
|
||||
body_pos.project_away(body_radius / 2.0, facing + angle),
|
||||
])
|
||||
.make_arrow(Distance::meters(0.15), ArrowCap::Triangle),
|
||||
);
|
||||
|
@ -32,7 +32,7 @@ impl DrawPedestrian {
|
||||
|
||||
if let Some(t) = input.waiting_for_turn {
|
||||
// A silly idea for peds... use hands to point at their turn?
|
||||
let angle = map.get_t(t).angle();
|
||||
let angle = input.facing + map.get_t(t).angle();
|
||||
draw_default.push(
|
||||
cs.turn_arrow,
|
||||
PolyLine::must_new(vec![
|
||||
|
@ -199,7 +199,7 @@ impl DrawMovement {
|
||||
}
|
||||
|
||||
// Produces (circle, arrow)
|
||||
fn make_circle_geom(offset: f64, pl: PolyLine, angle: Angle) -> (Polygon, Polygon) {
|
||||
fn make_circle_geom(offset: f64, pl: PolyLine, turn_angle: Angle) -> (Polygon, Polygon) {
|
||||
let height = 2.0 * TURN_ICON_ARROW_LENGTH;
|
||||
// Always extend the pl first to handle short entry lanes
|
||||
let extension = PolyLine::must_new(vec![
|
||||
@ -212,9 +212,10 @@ fn make_circle_geom(offset: f64, pl: PolyLine, angle: Angle) -> (Polygon, Polygo
|
||||
let center = slice.middle();
|
||||
let block = Circle::new(center, TURN_ICON_ARROW_LENGTH).to_polygon();
|
||||
|
||||
let arrow_angle = pl.last_line().angle().opposite() + turn_angle;
|
||||
let arrow = PolyLine::must_new(vec![
|
||||
center.project_away(TURN_ICON_ARROW_LENGTH / 2.0, angle.opposite()),
|
||||
center.project_away(TURN_ICON_ARROW_LENGTH / 2.0, angle),
|
||||
center.project_away(TURN_ICON_ARROW_LENGTH / 2.0, arrow_angle.opposite()),
|
||||
center.project_away(TURN_ICON_ARROW_LENGTH / 2.0, arrow_angle),
|
||||
])
|
||||
.make_arrow(Distance::meters(0.5), ArrowCap::Triangle);
|
||||
|
||||
|
@ -103,10 +103,18 @@ impl Turn {
|
||||
self.geom.intersection(&other.geom).is_some()
|
||||
}
|
||||
|
||||
// TODO What should this be for zero-length turns? Probably src's pt1 to dst's pt2 or
|
||||
// something.
|
||||
// The relative angle of the turn, should be the angle from the src lane to the dst lane, but
|
||||
// instead uses the first and last lines of the turn geometry, which is currently not quite the
|
||||
// same angle as between the source and destination lanes
|
||||
pub fn angle(&self) -> Angle {
|
||||
self.geom.first_pt().angle_to(self.geom.last_pt())
|
||||
if self.geom.points().len() < 3 {
|
||||
return Angle::ZERO;
|
||||
}
|
||||
|
||||
self.geom
|
||||
.last_line()
|
||||
.angle()
|
||||
.shortest_rotation_towards(self.geom.first_line().angle())
|
||||
}
|
||||
|
||||
pub fn between_sidewalks(&self) -> bool {
|
||||
|
Loading…
Reference in New Issue
Block a user