diff --git a/game/src/edit/mod.rs b/game/src/edit/mod.rs index ba5a7f0470..5226fca47e 100644 --- a/game/src/edit/mod.rs +++ b/game/src/edit/mod.rs @@ -690,7 +690,7 @@ pub fn apply_map_edits(ctx: &mut EventCtx, app: &mut App, edits: MapEdits) { for r in roads_changed { let road = app.primary.map.get_r(r); - app.primary.draw_map.roads[r.0].clear_rendering(); + app.primary.draw_map.recreate_road(road, &app.primary.map); // An edit to one lane potentially affects markings in all lanes in the same road, because // of one-way markings, driving lines, etc. diff --git a/map_gui/src/render/map.rs b/map_gui/src/render/map.rs index eccd5408ad..62a499442e 100644 --- a/map_gui/src/render/map.rs +++ b/map_gui/src/render/map.rs @@ -4,7 +4,9 @@ use aabb_quadtree::QuadTree; use abstutil::Timer; use geom::{Bounds, Polygon}; -use map_model::{AreaID, BuildingID, BusStopID, IntersectionID, LaneID, Map, ParkingLotID, RoadID}; +use map_model::{ + AreaID, BuildingID, BusStopID, IntersectionID, LaneID, Map, ParkingLotID, Road, RoadID, +}; use widgetry::{Color, Drawable, EventCtx, GeomBatch}; use crate::colors::ColorScheme; @@ -145,7 +147,9 @@ impl DrawMap { let mut quadtree_ids = HashMap::new(); // TODO use iter chain if everything was boxed as a renderable... for obj in &roads { - quadtree.insert_with_box(obj.get_id(), obj.get_outline(map).get_bounds().as_bbox()); + let item_id = + quadtree.insert_with_box(obj.get_id(), obj.get_outline(map).get_bounds().as_bbox()); + quadtree_ids.insert(obj.get_id(), item_id); } for (_, obj) in &lanes { let item_id = @@ -480,4 +484,16 @@ impl DrawMap { self.quadtree_ids.insert(draw.get_id(), item_id); self.intersections[i.0] = draw; } + + pub fn recreate_road(&mut self, road: &Road, map: &Map) { + let item_id = self.quadtree_ids.remove(&ID::Road(road.id)).unwrap(); + self.quadtree.remove(item_id).unwrap(); + + let draw = DrawRoad::new(road); + let item_id = self + .quadtree + .insert_with_box(draw.get_id(), draw.get_outline(map).get_bounds().as_bbox()); + self.quadtree_ids.insert(draw.get_id(), item_id); + self.roads[road.id.0] = draw; + } }