Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/content/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ pub use people::{
Crowd, PersonInstance, Pose, StrollAgent, StrollPose, Walkway, WalkwayKind, WalkwayNode,
embedded_walkways, stroll_pose,
};
pub use route::{CompiledLine, FieldSource, LineSource, TreeSource};
pub use roads::{RoadPatch, Roads};
pub use route::{CompiledLine, FieldSource, LineSource, TreeSource};
pub use scenarios::{musterbahn_day, re_4711, to_musterstadt};
pub use terrain::{
Scenery, SceneryInstance, TerrainBuilder, TerrainEdits, TerrainOptions, TerrainStats,
Expand Down
15 changes: 4 additions & 11 deletions crates/content/src/roads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -710,11 +710,7 @@ mod tests {
#[test]
fn a_road_lands_on_the_tiles_it_covers() {
// 3 km across, so it spans several 512 m tiles.
let roads = Roads::from_parts(
&[source(440_000.0, 5_715_000.0, 3_000.0, 6.0)],
32,
512.0,
);
let roads = Roads::from_parts(&[source(440_000.0, 5_715_000.0, 3_000.0, 6.0)], 32, 512.0);
assert_eq!(roads.len(), 1);
assert!(roads.touches((859, 11162)), "{:?}", roads.by_tile.keys());
assert!(!roads.touches((0, 0)));
Expand Down Expand Up @@ -813,12 +809,9 @@ mod tests {
assert_eq!(here.len(), 1);
assert_eq!(next.len(), 1);
let v = |patch: &RoadPatch| {
patch
.uvs
.iter()
.fold((f32::MAX, f32::MIN), |(lo, hi), uv| {
(lo.min(uv[1]), hi.max(uv[1]))
})
patch.uvs.iter().fold((f32::MAX, f32::MIN), |(lo, hi), uv| {
(lo.min(uv[1]), hi.max(uv[1]))
})
};
let (lo_here, hi_here) = v(&here[0]);
let (lo_next, hi_next) = v(&next[0]);
Expand Down
39 changes: 32 additions & 7 deletions crates/route-editor/src/roads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,10 @@ fn settings(ui: &mut egui::Ui, dialog: &mut RoadImport, line: &Line) -> bool {
.clone()
.on_disabled_hover_text(t!("field-import-no-envelope"));
}
if start_button.clicked() && ready && let Some(bbox) = envelope_bbox(line) {
if start_button.clicked()
&& ready
&& let Some(bbox) = envelope_bbox(line)
{
start(dialog, bbox);
}
if ui.button(t!("action-cancel")).clicked() {
Expand Down Expand Up @@ -335,7 +338,8 @@ fn finished(
let mut counts: std::collections::BTreeMap<&str, usize> =
std::collections::BTreeMap::new();
for road in roads {
if let Some(class) = road.tags.first().and_then(|t| t.strip_prefix("highway-"))
if let Some(class) =
road.tags.first().and_then(|t| t.strip_prefix("highway-"))
{
*counts.entry(class).or_insert(0) += 1;
}
Expand Down Expand Up @@ -402,7 +406,8 @@ pub fn pick_at(line: &Line, lat: f64, lon: f64) -> Option<usize> {
.points
.iter()
.map(|p| {
let (e, n) = world_coords::geo::to_utm(p.lat.to_radians(), p.lon.to_radians(), zone);
let (e, n) =
world_coords::geo::to_utm(p.lat.to_radians(), p.lon.to_radians(), zone);
glam::DVec2::new(e, n)
})
.collect();
Expand Down Expand Up @@ -767,7 +772,9 @@ mod tests {
road_width: Some(4.0),
..Default::default()
};
state.walk_points.push(world_coords::geo::to_ecef_deg(52.0, 10.0, 0.0));
state
.walk_points
.push(world_coords::geo::to_ecef_deg(52.0, 10.0, 0.0));
assert!(
finish(&mut line, &mut state).is_some(),
"one point is no road"
Expand Down Expand Up @@ -798,10 +805,28 @@ mod tests {
assert!(allowed(&plain, "primary"));
assert!(!allowed(&plain, "track"), "field tracks are opt-in");
assert!(!allowed(&plain, "living_street"));
assert!(allowed(&RoadOptions { tracks: true, ..plain }, "track"));
assert!(allowed(&RoadOptions { tracks: true, ..plain }, "service"));
assert!(allowed(
&RoadOptions {
tracks: true,
..plain
},
"track"
));
assert!(allowed(
&RoadOptions {
tracks: true,
..plain
},
"service"
));
assert!(
allowed(&RoadOptions { narrow: true, ..plain }, "living_street"),
allowed(
&RoadOptions {
narrow: true,
..plain
},
"living_street"
),
"access ways are the narrow option's own"
);
}
Expand Down
5 changes: 1 addition & 4 deletions crates/route-editor/src/tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4096,10 +4096,7 @@ pub fn draw_gizmos(
gizmos.linestrip(
points.iter().map(|p| {
origin.0.to_render(*p)
+ origin
.0
.dir_to_render(EnuFrame::at(*p).up)
* MARK_LIFT
+ origin.0.dir_to_render(EnuFrame::at(*p).up) * MARK_LIFT
}),
accent,
);
Expand Down
8 changes: 7 additions & 1 deletion crates/route-editor/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4225,7 +4225,13 @@ fn issue_target(
.roads
.get(*road as usize)
.and_then(|road| road.points.first())
.map(|p| world_coords::geo::to_ecef_deg(p.lat, p.lon, crate::envelope::height(line, focus))),
.map(|p| {
world_coords::geo::to_ecef_deg(
p.lat,
p.lon,
crate::envelope::height(line, focus),
)
}),
Selection::Road(*road as usize),
),
}
Expand Down
2 changes: 1 addition & 1 deletion crates/world-render/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ pub mod windscreen;
pub use farmland::{
CropExt, CropParams, FieldDraw, FieldMaterial, FieldMaterials, FieldSurface, spawn_fields,
};
pub use plants::{FieldPlants, PlantMaterials, update_field_plants};
pub use people::{
CYCLE_PACE, CYCLE_RATE, CharacterAssets, CharacterGraphs, Dressed, GAIT_FADE, Gait,
PASSENGER_CULL, PERSON_CULL, Passengers, PeopleClock, Person, Stroller, WALKING_ABOVE,
WalkwayHost, WalkwaysBound, bind_walkways, gait, move_strollers, person_bundle, play_gait,
spawn_seated, spawn_strollers,
};
pub use plants::{FieldPlants, PlantMaterials, update_field_plants};
pub use roads::{RoadDraw, RoadMaterial, RoadMaterials, RoadSurfaceMark, spawn_roads};
pub use scatter::{
OBJECT_CULL, PendingTrees, Scattered, SceneryIndex, TREE_CULL, TreeModels, Wood, WorldCatalog,
Expand Down
Loading