mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-28 03:35:51 +03:00
remove steepness plugin; it's annoying and useless
This commit is contained in:
parent
3b372dd9ce
commit
a626f5c542
@ -572,6 +572,7 @@ Plugin styles are blocking or ambient. And some can conflict...
|
||||
- show score plugin is modal and nonblocking; lets not instantiate it till we need it. list of stackable modal things, just make sure not to create one again.
|
||||
- sim controls is a little weird; for now, it's always nonblocking and ambient and ever-present.
|
||||
- display logs is easy, just an exclusive blocking plugin.
|
||||
- debug mode stuff...
|
||||
|
||||
|
||||
|
||||
|
@ -4,18 +4,13 @@ mod floodfill;
|
||||
mod geom_validation;
|
||||
mod hider;
|
||||
mod layers;
|
||||
mod steep;
|
||||
|
||||
use crate::objects::{Ctx, ID};
|
||||
use crate::plugins::{Plugin, PluginCtx};
|
||||
use ezgui::{Color, GfxCtx};
|
||||
use map_model::Map;
|
||||
|
||||
pub struct DebugMode {
|
||||
// steepness acts like one of the active plugins, except that it needs to cache state while
|
||||
// inactive.
|
||||
active_plugin: Option<Box<Plugin>>,
|
||||
steepness: steep::SteepnessVisualizer,
|
||||
|
||||
// Ambient; they don't conflict with any of the main plugins.
|
||||
hider: hider::Hider,
|
||||
@ -23,10 +18,9 @@ pub struct DebugMode {
|
||||
}
|
||||
|
||||
impl DebugMode {
|
||||
pub fn new(map: &Map) -> DebugMode {
|
||||
pub fn new() -> DebugMode {
|
||||
DebugMode {
|
||||
active_plugin: None,
|
||||
steepness: steep::SteepnessVisualizer::new(map),
|
||||
hider: hider::Hider::new(),
|
||||
layers: layers::ToggleableLayers::new(),
|
||||
}
|
||||
@ -53,8 +47,6 @@ impl Plugin for DebugMode {
|
||||
self.active_plugin = None;
|
||||
return false;
|
||||
}
|
||||
} else if self.steepness.active {
|
||||
return self.steepness.blocking_event(ctx);
|
||||
}
|
||||
|
||||
if let Some(p) = chokepoints::ChokepointsFinder::new(ctx) {
|
||||
@ -65,8 +57,6 @@ impl Plugin for DebugMode {
|
||||
self.active_plugin = Some(Box::new(p));
|
||||
} else if let Some(p) = geom_validation::Validator::new(ctx) {
|
||||
self.active_plugin = Some(Box::new(p));
|
||||
} else if self.steepness.blocking_event(ctx) {
|
||||
return true;
|
||||
}
|
||||
|
||||
self.active_plugin.is_some()
|
||||
@ -75,16 +65,12 @@ impl Plugin for DebugMode {
|
||||
fn draw(&self, g: &mut GfxCtx, ctx: &Ctx) {
|
||||
if let Some(ref plugin) = self.active_plugin {
|
||||
plugin.draw(g, ctx);
|
||||
} else if self.steepness.active {
|
||||
self.steepness.draw(g, ctx);
|
||||
}
|
||||
}
|
||||
|
||||
fn color_for(&self, obj: ID, ctx: &Ctx) -> Option<Color> {
|
||||
if let Some(ref plugin) = self.active_plugin {
|
||||
return plugin.color_for(obj, ctx);
|
||||
} else if self.steepness.active {
|
||||
return self.steepness.color_for(obj, ctx);
|
||||
}
|
||||
None
|
||||
}
|
||||
|
@ -1,64 +0,0 @@
|
||||
// Copyright 2018 Google LLC, licensed under http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
// TODO check out https://accessmap.io/ for inspiration on how to depict elevation
|
||||
|
||||
use crate::objects::{Ctx, ID};
|
||||
use crate::plugins::{Plugin, PluginCtx};
|
||||
use ezgui::Color;
|
||||
use map_model::Map;
|
||||
use std::f64;
|
||||
|
||||
pub struct SteepnessVisualizer {
|
||||
pub active: bool,
|
||||
min_difference: f64,
|
||||
max_difference: f64,
|
||||
}
|
||||
|
||||
impl SteepnessVisualizer {
|
||||
pub fn new(map: &Map) -> SteepnessVisualizer {
|
||||
let mut s = SteepnessVisualizer {
|
||||
active: false,
|
||||
min_difference: f64::MAX,
|
||||
max_difference: f64::MIN_POSITIVE,
|
||||
};
|
||||
for r in map.all_roads() {
|
||||
let d = (map.get_i(r.src_i).elevation - map.get_i(r.dst_i).elevation)
|
||||
.value_unsafe
|
||||
.abs();
|
||||
// TODO hack! skip crazy outliers in terrible way.
|
||||
if d > 100.0 {
|
||||
continue;
|
||||
}
|
||||
s.min_difference = s.min_difference.min(d);
|
||||
s.max_difference = s.max_difference.max(d);
|
||||
}
|
||||
s
|
||||
}
|
||||
}
|
||||
|
||||
impl Plugin for SteepnessVisualizer {
|
||||
fn blocking_event(&mut self, ctx: &mut PluginCtx) -> bool {
|
||||
if ctx.input.action_chosen("show/hide road steepness") {
|
||||
self.active = !self.active;
|
||||
}
|
||||
self.active
|
||||
}
|
||||
|
||||
fn color_for(&self, obj: ID, ctx: &Ctx) -> Option<Color> {
|
||||
if !self.active {
|
||||
return None;
|
||||
}
|
||||
|
||||
match obj {
|
||||
ID::Lane(l) => {
|
||||
let e1 = ctx.map.get_source_intersection(l).elevation;
|
||||
let e2 = ctx.map.get_destination_intersection(l).elevation;
|
||||
let d = (e1 - e2).value_unsafe.abs();
|
||||
let normalized =
|
||||
(d - self.min_difference) / (self.max_difference - self.min_difference);
|
||||
Some(Color::rgb_f(normalized as f32, 0.0, 0.0))
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
@ -463,7 +463,7 @@ pub struct PluginsPerMap {
|
||||
impl PluginsPerMap {
|
||||
pub fn new(state: &PerMapUI, canvas: &Canvas, timer: &mut Timer) -> PluginsPerMap {
|
||||
let mut plugins = PluginsPerMap {
|
||||
debug_mode: DebugMode::new(&state.map),
|
||||
debug_mode: DebugMode::new(),
|
||||
view_mode: ViewMode::new(&state.map, &state.draw_map, timer),
|
||||
time_travel: TimeTravel::new(),
|
||||
};
|
||||
|
@ -40,7 +40,6 @@ impl<S: UIState> GUI<RenderingHints> for UI<S> {
|
||||
(Key::Num2, "show/hide intersections"),
|
||||
(Key::Num3, "show/hide lanes"),
|
||||
(Key::Num4, "show/hide parcels"),
|
||||
(Key::Num5, "show/hide road steepness"),
|
||||
(Key::Num6, "show OSM colors"),
|
||||
(Key::Num7, "show/hide extra shapes"),
|
||||
(Key::Num9, "show/hide all turn icons"),
|
||||
|
Loading…
Reference in New Issue
Block a user