fix spawning of vehicles on borders

This commit is contained in:
Dustin Carlino 2019-02-02 14:20:51 -08:00
parent e330061b91
commit f9ccecad26
3 changed files with 6 additions and 7 deletions

View File

@ -4,13 +4,11 @@
- cache draw agents
- actually use Drawables in the places
- have to undo the hacks for cars appearing out of a border
## Quick n easy
- try showing traffic signals by little boxes at the end of lanes
- red circle means right turn on red OK, red right arrow means nope, green means normal turns ok, green arrow means protected left, crosswalk hand or stick figure
- Circle::new radius and pt project_away should take meters type
- if a lane could feasibly have multiple turn options but doesnt, print "ONLY"
- color roads as solid black when zoomed out, and make intersections similar (except for stop sign / signal)

View File

@ -90,7 +90,6 @@ impl Pt2D {
}
// TODO better name
// TODO Meters for dist?
pub fn project_away(self, dist: Distance, theta: Angle) -> Pt2D {
// If negative, caller should use theta.opposite()
assert!(dist >= Distance::ZERO);

View File

@ -10,7 +10,6 @@ use crate::{
AgentID, CarID, Event, ParkedCar, ParkingSpot, PedestrianID, Tick, TripID, VehicleType,
};
use abstutil::{fork_rng, WeightedUsizeChoice};
use geom::Distance;
use map_model::{
BuildingID, BusRoute, BusRouteID, BusStopID, LaneID, LaneType, Map, Path, PathRequest,
Pathfinder, Position, RoadID,
@ -114,7 +113,7 @@ impl Command {
DrivingGoal::Border(_, l) => *l,
};
PathRequest {
start: Position::new(*start, Distance::ZERO),
start: Position::new(*start, vehicle.length),
end: Position::new(goal_lane, map.get_l(goal_lane).length()),
can_use_bus_lanes: vehicle.vehicle_type == VehicleType::Bus,
can_use_bike_lanes: vehicle.vehicle_type == VehicleType::Bike,
@ -222,7 +221,7 @@ impl Spawner {
owner: None,
maybe_parked_car: None,
vehicle: vehicle.clone(),
start: Position::new(start, Distance::ZERO),
start: Position::new(start, vehicle.length),
router: match goal {
DrivingGoal::ParkNear(b) => {
if vehicle.vehicle_type == VehicleType::Bike {
@ -461,11 +460,13 @@ impl Spawner {
if let DrivingGoal::ParkNear(b) = goal {
legs.push(TripLeg::Walk(SidewalkSpot::building(b, map)));
}
let vehicle = Vehicle::generate_car(car_id, base_rng);
assert!(map.get_l(first_lane).length() > vehicle.length);
self.enqueue_command(Command::DriveFromBorder {
at,
trip: trips.new_trip(at, Some(ped_id), legs),
car: car_id,
vehicle: Vehicle::generate_car(car_id, base_rng),
vehicle,
start: first_lane,
goal,
});
@ -599,6 +600,7 @@ impl Spawner {
if let DrivingGoal::ParkNear(b) = goal {
legs.push(TripLeg::Walk(SidewalkSpot::building(b, map)));
}
assert!(map.get_l(first_lane).length() > vehicle.length);
self.enqueue_command(Command::DriveFromBorder {
at,
trip: trips.new_trip(at, Some(ped_id), legs),