fix ped<->bike animation

This commit is contained in:
Dustin Carlino 2018-11-18 17:07:17 -08:00
parent b618842ad2
commit 30a03d3159
2 changed files with 17 additions and 10 deletions

View File

@ -85,6 +85,7 @@ impl Command {
DrivingGoal::Border(_, l) => (*l, map.get_l(*l).length()),
};
PathRequest {
// TODO or bike lane, gah
start: map.get_driving_lane_from_sidewalk(*start_sidewalk).unwrap(),
start_dist: *start_dist,
end: goal_lane,
@ -610,7 +611,7 @@ impl Spawner {
at.next(),
trip,
ped,
SidewalkSpot::bike_rack(lane, dist),
SidewalkSpot::bike_rack(last_lane, dist),
walk_to,
));
}

View File

@ -1,7 +1,7 @@
use abstutil;
use abstutil::{deserialize_multimap, serialize_multimap, Error};
use dimensioned::si;
use geom::Pt2D;
use geom::{Line, Pt2D};
use instrument::capture_backtrace;
use intersections::{IntersectionSimState, Request};
use map_model::{
@ -311,19 +311,25 @@ impl Pedestrian {
if let Some(ref fp) = self.front_path {
map.get_b(fp.bldg).front_path.line.dist_along(fp.dist_along)
} else if let Some(ref bp) = self.bike_parking {
let (base_pos, angle) = self.on.dist_along(self.dist_along, map);
let sidewalk_pos = self.on.dist_along(self.dist_along, map).0;
let street_pos = map
.get_l(
map.get_driving_lane_from_sidewalk(self.on.as_lane())
.unwrap(),
).dist_along(self.dist_along)
.0;
let line = Line::new(sidewalk_pos, street_pos);
let progress: f64 =
((now - bp.started_at).as_time() / TIME_TO_PREPARE_BIKE).value_unsafe;
assert!(progress >= 0.0 && progress <= 1.0);
let project_away_ratio = if bp.is_parking {
progress
} else {
let ratio = if bp.is_parking {
1.0 - progress
} else {
progress
};
// TODO how many lanes away? and we're assuming the equivalent dist_along is
// perpendicular
use map_model::LANE_THICKNESS;
base_pos.project_away(project_away_ratio * LANE_THICKNESS, angle.rotate_degs(90.0))
line.dist_along(ratio * line.length())
} else {
self.on.dist_along(self.dist_along, map).0
}