mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-27 00:12:55 +03:00
improve car/bike zordering when crossing z levels
This commit is contained in:
parent
969135d93b
commit
ccf0b2f647
@ -94,10 +94,17 @@ impl DrawBike {
|
||||
);
|
||||
}
|
||||
|
||||
let zorder = input
|
||||
.partly_on
|
||||
.into_iter()
|
||||
.chain(vec![input.on])
|
||||
.map(|on| on.get_zorder(map))
|
||||
.max()
|
||||
.unwrap();
|
||||
DrawBike {
|
||||
id: input.id,
|
||||
body_circle,
|
||||
zorder: input.on.get_zorder(map),
|
||||
zorder,
|
||||
draw_default: prerender.upload(draw_default),
|
||||
}
|
||||
}
|
||||
|
@ -150,11 +150,20 @@ impl DrawCar {
|
||||
);
|
||||
}
|
||||
|
||||
// TODO Technically some of the body may need to be at different zorders during
|
||||
// transitions, but that's way too much effort
|
||||
let zorder = input
|
||||
.partly_on
|
||||
.into_iter()
|
||||
.chain(vec![input.on])
|
||||
.map(|on| on.get_zorder(map))
|
||||
.max()
|
||||
.unwrap();
|
||||
DrawCar {
|
||||
id: input.id,
|
||||
body: input.body,
|
||||
body_polygon,
|
||||
zorder: input.on.get_zorder(map),
|
||||
zorder,
|
||||
draw_default: prerender.upload(draw_default),
|
||||
}
|
||||
}
|
||||
|
@ -61,6 +61,7 @@ impl Car {
|
||||
) -> DrawCarInput {
|
||||
assert!(front >= Distance::ZERO);
|
||||
// This goes from back to front
|
||||
let mut partly_on = Vec::new();
|
||||
let raw_body = if front >= self.vehicle.length {
|
||||
self.router
|
||||
.head()
|
||||
@ -83,6 +84,7 @@ impl Car {
|
||||
self.vehicle.id, leftover
|
||||
);
|
||||
}
|
||||
partly_on.push(self.last_steps[i]);
|
||||
let len = self.last_steps[i].length(map);
|
||||
let start = (len - leftover).max(Distance::ZERO);
|
||||
let piece = self.last_steps[i]
|
||||
@ -215,6 +217,7 @@ impl Car {
|
||||
CarState::Idling(_, _) => CarStatus::Parked,
|
||||
},
|
||||
on: self.router.head(),
|
||||
partly_on,
|
||||
label: if self.vehicle.vehicle_type == VehicleType::Bus
|
||||
|| self.vehicle.vehicle_type == VehicleType::Train
|
||||
{
|
||||
|
@ -208,6 +208,7 @@ impl ParkingSimState {
|
||||
waiting_for_turn: None,
|
||||
status: CarStatus::Parked,
|
||||
on: Traversable::Lane(lane),
|
||||
partly_on: Vec::new(),
|
||||
label: None,
|
||||
|
||||
body: map
|
||||
@ -227,6 +228,7 @@ impl ParkingSimState {
|
||||
status: CarStatus::Parked,
|
||||
// Just used for z-order
|
||||
on: Traversable::Lane(pl.driving_pos.lane()),
|
||||
partly_on: Vec::new(),
|
||||
label: None,
|
||||
|
||||
body: PolyLine::must_new(vec![
|
||||
|
@ -34,7 +34,10 @@ pub struct DrawCarInput {
|
||||
pub id: CarID,
|
||||
pub waiting_for_turn: Option<TurnID>,
|
||||
pub status: CarStatus,
|
||||
// Front of the car
|
||||
pub on: Traversable,
|
||||
// Possibly the rest
|
||||
pub partly_on: Vec<Traversable>,
|
||||
pub label: Option<String>,
|
||||
|
||||
// Starts at the BACK of the car.
|
||||
|
Loading…
Reference in New Issue
Block a user