mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-24 09:24:26 +03:00
experiment with building roofs
This commit is contained in:
parent
17e02ebdf0
commit
820a660132
@ -16,6 +16,7 @@
|
||||
- zoom in too much, what might you see? ;)
|
||||
- loading screen: snakey cars
|
||||
- game intro/backstory: history of seattle urban planning
|
||||
- player context: a drone. people will look up eventually.
|
||||
|
||||
## Tutorial
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
- rename Car->Vehicle?
|
||||
- spawning is convoluted
|
||||
- popdat trip -> Scenario SpawnTrip -> pick ped speed and make spawner's TripSpec -> create trip and schedule a Command -> last minute rewriting when executing the command
|
||||
- more precise car FSM by putting scheduler pointer into carstate
|
||||
|
||||
## ezgui layer
|
||||
|
||||
|
@ -81,6 +81,11 @@ impl DrawBuilding {
|
||||
);
|
||||
}
|
||||
|
||||
// TODO Slow and looks silly, but it's a nice experiment.
|
||||
/*for poly in bldg.polygon.shrink(-3.0) {
|
||||
batch.push(cs.get_def("building roof", Color::rgb(150, 75, 0)), poly);
|
||||
}*/
|
||||
|
||||
DrawBuilding {
|
||||
id: bldg.id,
|
||||
label,
|
||||
|
@ -9,6 +9,7 @@ aabb-quadtree = "0.1.0"
|
||||
abstutil = { path = "../abstutil" }
|
||||
geo = "0.12.0"
|
||||
geo-booleanop = "0.2.0"
|
||||
geo-offset = "0.1.0"
|
||||
histogram = "0.6.9"
|
||||
ordered-float = "1.0.1"
|
||||
polylabel = "1.3.0"
|
||||
|
@ -1,5 +1,6 @@
|
||||
use crate::{Bounds, Distance, HashablePt2D, Pt2D};
|
||||
use geo_booleanop::boolean::BooleanOp;
|
||||
use geo_offset::Offset;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use std::fmt;
|
||||
|
||||
@ -184,27 +185,17 @@ impl Polygon {
|
||||
}
|
||||
|
||||
pub fn intersection(&self, other: &Polygon) -> Vec<Polygon> {
|
||||
let multi = to_geo(self.points()).intersection(&to_geo(other.points()));
|
||||
multi
|
||||
.into_iter()
|
||||
.map(|poly| {
|
||||
Polygon::new(
|
||||
&poly
|
||||
.into_inner()
|
||||
.0
|
||||
.into_points()
|
||||
.into_iter()
|
||||
.map(|pt| Pt2D::new(pt.x(), pt.y()))
|
||||
.collect(),
|
||||
)
|
||||
})
|
||||
.collect()
|
||||
from_multi(to_geo(self.points()).intersection(&to_geo(other.points())))
|
||||
}
|
||||
|
||||
pub fn polylabel(&self) -> Pt2D {
|
||||
let pt = polylabel::polylabel(&to_geo(&self.points()), &1.0);
|
||||
Pt2D::new(pt.x(), pt.y())
|
||||
}
|
||||
|
||||
pub fn shrink(&self, distance: f64) -> Vec<Polygon> {
|
||||
from_multi(to_geo(self.points()).offset(distance).unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Polygon {
|
||||
@ -297,3 +288,20 @@ fn to_geo(pts: &Vec<Pt2D>) -> geo::Polygon<f64> {
|
||||
Vec::new(),
|
||||
)
|
||||
}
|
||||
|
||||
fn from_multi(multi: geo::MultiPolygon<f64>) -> Vec<Polygon> {
|
||||
multi
|
||||
.into_iter()
|
||||
.map(|poly| {
|
||||
Polygon::new(
|
||||
&poly
|
||||
.into_inner()
|
||||
.0
|
||||
.into_points()
|
||||
.into_iter()
|
||||
.map(|pt| Pt2D::new(pt.x(), pt.y()))
|
||||
.collect(),
|
||||
)
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user