mirror of
https://github.com/a-b-street/abstreet.git
synced 2025-01-01 10:57:17 +03:00
flags to disable drawing some expensive stuff, to make debugging small_seattle a bit easier
This commit is contained in:
parent
8b6a863b60
commit
195d077c98
@ -118,8 +118,7 @@ fn launch_test(
|
||||
run_name: format!("{} with {}", test.test_name, test.edits1_name),
|
||||
edits_name: test.edits1_name.clone(),
|
||||
},
|
||||
kml: current_flags.kml.clone(),
|
||||
draw_parcels: current_flags.draw_parcels,
|
||||
..current_flags.clone()
|
||||
},
|
||||
cs,
|
||||
prerender,
|
||||
@ -133,8 +132,7 @@ fn launch_test(
|
||||
run_name: format!("{} with {}", test.test_name, test.edits2_name),
|
||||
edits_name: test.edits2_name.clone(),
|
||||
},
|
||||
kml: current_flags.kml.clone(),
|
||||
draw_parcels: current_flags.draw_parcels,
|
||||
..current_flags.clone()
|
||||
},
|
||||
cs,
|
||||
prerender,
|
||||
|
@ -20,34 +20,42 @@ pub struct DrawLane {
|
||||
}
|
||||
|
||||
impl DrawLane {
|
||||
pub fn new(lane: &Lane, map: &Map, cs: &ColorScheme, prerender: &Prerender) -> DrawLane {
|
||||
pub fn new(
|
||||
lane: &Lane,
|
||||
map: &Map,
|
||||
draw_lane_markings: bool,
|
||||
cs: &ColorScheme,
|
||||
prerender: &Prerender,
|
||||
) -> DrawLane {
|
||||
let road = map.get_r(lane.parent);
|
||||
let polygon = lane.lane_center_pts.make_polygons(LANE_THICKNESS);
|
||||
|
||||
let mut markings: Vec<(Color, Polygon)> = Vec::new();
|
||||
if road.is_canonical_lane(lane.id) {
|
||||
markings.push((
|
||||
cs.get_def("road center line", Color::YELLOW),
|
||||
road.center_pts.make_polygons(BIG_ARROW_THICKNESS),
|
||||
));
|
||||
}
|
||||
match lane.lane_type {
|
||||
LaneType::Sidewalk => {
|
||||
markings.extend(calculate_sidewalk_lines(lane, cs));
|
||||
if draw_lane_markings {
|
||||
if road.is_canonical_lane(lane.id) {
|
||||
markings.push((
|
||||
cs.get_def("road center line", Color::YELLOW),
|
||||
road.center_pts.make_polygons(BIG_ARROW_THICKNESS),
|
||||
));
|
||||
}
|
||||
LaneType::Parking => {
|
||||
markings.extend(calculate_parking_lines(lane, cs));
|
||||
match lane.lane_type {
|
||||
LaneType::Sidewalk => {
|
||||
markings.extend(calculate_sidewalk_lines(lane, cs));
|
||||
}
|
||||
LaneType::Parking => {
|
||||
markings.extend(calculate_parking_lines(lane, cs));
|
||||
}
|
||||
LaneType::Driving | LaneType::Bus => {
|
||||
markings.extend(calculate_driving_lines(lane, road, cs));
|
||||
markings.extend(calculate_turn_markings(map, lane, cs));
|
||||
}
|
||||
LaneType::Biking => {}
|
||||
};
|
||||
if lane.is_driving()
|
||||
&& map.get_i(lane.dst_i).intersection_type == IntersectionType::StopSign
|
||||
{
|
||||
markings.extend(calculate_stop_sign_line(road, lane, map, cs));
|
||||
}
|
||||
LaneType::Driving | LaneType::Bus => {
|
||||
markings.extend(calculate_driving_lines(lane, road, cs));
|
||||
markings.extend(calculate_turn_markings(map, lane, cs));
|
||||
}
|
||||
LaneType::Biking => {}
|
||||
};
|
||||
if lane.is_driving()
|
||||
&& map.get_i(lane.dst_i).intersection_type == IntersectionType::StopSign
|
||||
{
|
||||
markings.extend(calculate_stop_sign_line(road, lane, map, cs));
|
||||
}
|
||||
|
||||
let draw_default = prerender.upload_borrowed(vec![(
|
||||
|
@ -51,7 +51,13 @@ impl DrawMap {
|
||||
let mut lanes: Vec<DrawLane> = Vec::new();
|
||||
for l in map.all_lanes() {
|
||||
timer.next();
|
||||
lanes.push(DrawLane::new(l, map, cs, prerender));
|
||||
lanes.push(DrawLane::new(
|
||||
l,
|
||||
map,
|
||||
!flags.dont_draw_lane_markings,
|
||||
cs,
|
||||
prerender,
|
||||
));
|
||||
}
|
||||
|
||||
let mut turn_to_lane_offset: HashMap<TurnID, usize> = HashMap::new();
|
||||
@ -77,15 +83,14 @@ impl DrawMap {
|
||||
})
|
||||
.collect();
|
||||
|
||||
timer.start_iter("make DrawBuildings", map.all_buildings().len());
|
||||
let buildings: Vec<DrawBuilding> = map
|
||||
.all_buildings()
|
||||
.iter()
|
||||
.map(|b| {
|
||||
let mut buildings: Vec<DrawBuilding> = Vec::new();
|
||||
if !flags.dont_draw_buildings {
|
||||
timer.start_iter("make DrawBuildings", map.all_buildings().len());
|
||||
for b in map.all_buildings() {
|
||||
timer.next();
|
||||
DrawBuilding::new(b, cs, prerender)
|
||||
})
|
||||
.collect();
|
||||
buildings.push(DrawBuilding::new(b, cs, prerender));
|
||||
}
|
||||
}
|
||||
|
||||
let mut parcels: Vec<DrawParcel> = Vec::new();
|
||||
if flags.draw_parcels {
|
||||
@ -130,11 +135,15 @@ impl DrawMap {
|
||||
for s in map.all_bus_stops().values() {
|
||||
bus_stops.insert(s.id, DrawBusStop::new(s, map, cs, prerender));
|
||||
}
|
||||
let areas: Vec<DrawArea> = map
|
||||
.all_areas()
|
||||
.iter()
|
||||
.map(|a| DrawArea::new(a, cs, prerender))
|
||||
.collect();
|
||||
|
||||
let mut areas: Vec<DrawArea> = Vec::new();
|
||||
if !flags.dont_draw_areas {
|
||||
timer.start_iter("make DrawAreas", map.all_areas().len());
|
||||
for a in map.all_areas() {
|
||||
timer.next();
|
||||
areas.push(DrawArea::new(a, cs, prerender));
|
||||
}
|
||||
}
|
||||
|
||||
timer.start("create quadtree");
|
||||
let mut quadtree = QuadTree::default(map.get_bounds().as_bbox());
|
||||
@ -210,7 +219,8 @@ impl DrawMap {
|
||||
prerender: &Prerender,
|
||||
) {
|
||||
// No need to edit the quadtree; the bbox shouldn't depend on lane type.
|
||||
self.lanes[id.0] = DrawLane::new(map.get_l(id), map, cs, prerender);
|
||||
// TODO Preserve flags.dont_draw_lane_markings
|
||||
self.lanes[id.0] = DrawLane::new(map.get_l(id), map, true, cs, prerender);
|
||||
}
|
||||
|
||||
pub fn edit_remove_turn(&mut self, id: TurnID) {
|
||||
|
@ -26,6 +26,19 @@ pub struct Flags {
|
||||
/// Should parcels be drawn? They're slow and not so useful.
|
||||
#[structopt(long = "draw_parcels")]
|
||||
pub draw_parcels: bool,
|
||||
|
||||
// TODO Ideally these'd be phrased positively, but can't easily make them default to true.
|
||||
/// Should areas be drawn? Can sometimes be slow.
|
||||
#[structopt(long = "dont_draw_areas")]
|
||||
pub dont_draw_areas: bool,
|
||||
|
||||
/// Should buildings be drawn? Sometimes there's an awful lot of them.
|
||||
#[structopt(long = "dont_draw_buildings")]
|
||||
pub dont_draw_buildings: bool,
|
||||
|
||||
/// Should lane markings be drawn? Sometimes they eat too much GPU memory.
|
||||
#[structopt(long = "dont_draw_lane_markings")]
|
||||
pub dont_draw_lane_markings: bool,
|
||||
}
|
||||
|
||||
pub trait UIState {
|
||||
|
Loading…
Reference in New Issue
Block a user