mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-27 15:03:20 +03:00
Recreate the road in the quadtree when modifying width. #597
This commit is contained in:
parent
4a0635fa5a
commit
6b30bffc43
@ -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.
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user