prerender areas and be able to debug their geometry

This commit is contained in:
Dustin Carlino 2019-02-09 19:01:18 -08:00
parent 9d450363ea
commit 0f1d0d24ca
7 changed files with 53 additions and 17 deletions

View File

@ -39,6 +39,8 @@
- but theyre not marked everywhere
- and theyre hard to associate with roads (sometimes need to infer a planter strip)
- draw ALL water and greenery areas
- cant mouseover areas created from polylines, seemingly
- multipolygons seem broken
- draw benches, bike racks
- render trees
- look for current stop sign priorities
@ -59,6 +61,11 @@
- Disconnected map
- Some lane-changing model needed to determine this
- Impossible turns (from a far bus lane to a crazy left)
- Buildings intersecting roads, probably because bad lane inference
- when this happens, get rid of parking lanes first (one or both sides?)
- iterative process... have to redo affected roads and intersections
- we havent filtered buildings by proximity to sidewalk yet
- if we dont filter at all, we pick up some houseboats! :) should draw water...
## Release

View File

@ -78,6 +78,23 @@ impl DebugPolygon {
});
}
}
Some(ID::Area(id)) => {
if ctx.input.contextual_action(Key::X, "debug area geometry") {
let pts = &ctx.primary.map.get_a(id).points;
let center = if pts[0] == *pts.last().unwrap() {
// TODO The center looks really wrong for Volunteer Park and others, but I
// think it's because they have many points along some edges.
Pt2D::center(&pts.iter().skip(1).cloned().collect())
} else {
Pt2D::center(pts)
};
return Some(DebugPolygon {
items: pts.iter().map(|pt| Item::Point(*pt)).collect(),
current: 0,
center: Some(center),
});
}
}
_ => {}
}
None

View File

@ -57,6 +57,7 @@ impl ToggleableLayers {
&mut self.show_parcels,
&mut self.show_extra_shapes,
&mut self.show_all_turn_icons,
&mut self.show_areas,
&mut self.debug_mode,
]
}

View File

@ -1,22 +1,33 @@
use crate::colors::ColorScheme;
use crate::objects::{DrawCtx, ID};
use crate::render::{RenderOptions, Renderable};
use ezgui::{Color, GfxCtx};
use ezgui::{Color, Drawable, GfxCtx, Prerender};
use geom::{Bounds, Polygon, Pt2D};
use map_model::{Area, AreaID, AreaType};
#[derive(Debug)]
pub struct DrawArea {
pub id: AreaID,
fill_polygon: Polygon,
area_type: AreaType,
draw_default: Drawable,
}
impl DrawArea {
pub fn new(area: &Area) -> DrawArea {
pub fn new(area: &Area, cs: &ColorScheme, prerender: &Prerender) -> DrawArea {
let fill_polygon = area.get_polygon();
let draw_default = prerender.upload_borrowed(vec![(
match area.area_type {
AreaType::Park => cs.get_def("park area", Color::GREEN),
AreaType::Swamp => cs.get_def("swamp area", Color::rgb_f(0.0, 1.0, 0.6)),
AreaType::Water => cs.get_def("water area", Color::BLUE),
},
&fill_polygon,
)]);
DrawArea {
id: area.id,
fill_polygon: area.get_polygon(),
area_type: area.area_type,
fill_polygon,
draw_default,
}
}
}
@ -26,13 +37,12 @@ impl Renderable for DrawArea {
ID::Area(self.id)
}
fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, ctx: &DrawCtx) {
let color = match self.area_type {
AreaType::Park => ctx.cs.get_def("park area", Color::GREEN),
AreaType::Swamp => ctx.cs.get_def("swamp area", Color::rgb_f(0.0, 1.0, 0.6)),
AreaType::Water => ctx.cs.get_def("water area", Color::BLUE),
};
g.draw_polygon(opts.color.unwrap_or(color), &self.fill_polygon);
fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, _ctx: &DrawCtx) {
if let Some(color) = opts.color {
g.draw_polygon(color, &self.fill_polygon);
} else {
g.redraw(&self.draw_default);
}
}
fn get_bounds(&self) -> Bounds {

View File

@ -16,13 +16,11 @@ impl fmt::Display for ExtraShapeID {
}
}
#[derive(Debug)]
enum Shape {
Polygon(Polygon),
Circle(Circle),
}
#[derive(Debug)]
pub struct DrawExtraShape {
pub id: ExtraShapeID,
shape: Shape,

View File

@ -130,7 +130,11 @@ impl DrawMap {
for s in map.all_bus_stops().values() {
bus_stops.insert(s.id, DrawBusStop::new(s, map));
}
let areas: Vec<DrawArea> = map.all_areas().iter().map(|a| DrawArea::new(a)).collect();
let areas: Vec<DrawArea> = map
.all_areas()
.iter()
.map(|a| DrawArea::new(a, cs, prerender))
.collect();
timer.start("create quadtree");
let mut quadtree = QuadTree::default(map.get_bounds().as_bbox());

View File

@ -8,7 +8,6 @@ use ezgui::{Color, Drawable, GfxCtx, Prerender};
use geom::{Bounds, Circle, Distance, Line, Pt2D};
use map_model::{Map, Turn, TurnID, LANE_THICKNESS};
#[derive(Debug)]
pub struct DrawTurn {
pub id: TurnID,
icon_circle: Circle,