mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-25 03:41:09 +03:00
starting a plugin to interactively spawn specific agents
This commit is contained in:
parent
11045fd44f
commit
998c27ddff
@ -24,12 +24,13 @@
|
|||||||
|
|
||||||
- zorder for bridges/tunnels
|
- zorder for bridges/tunnels
|
||||||
- apply to cars/peds too; figure out statics/dynamics plumbing
|
- apply to cars/peds too; figure out statics/dynamics plumbing
|
||||||
- first need to interactively spawn a car/ped somewhere to test this easily
|
|
||||||
|
|
||||||
- degenerate-2's should only have one crosswalk
|
- degenerate-2's should only have one crosswalk
|
||||||
- then make them thinner
|
- then make them thinner
|
||||||
|
|
||||||
- ped paths through sidewalk corners are totally broken
|
- ped paths through sidewalk corners are totally broken
|
||||||
|
- calculate the better paths first, then make the corner geometry from that?
|
||||||
|
- car turns often clip sidewalk corners now
|
||||||
|
|
||||||
- figure out what to do about yellow center lines
|
- figure out what to do about yellow center lines
|
||||||
- intersections on one-ways look weird
|
- intersections on one-ways look weird
|
||||||
|
@ -2,6 +2,16 @@
|
|||||||
|
|
||||||
## Quick n easy
|
## Quick n easy
|
||||||
|
|
||||||
|
- interactively spawn a car/ped somewhere to test this easily
|
||||||
|
- start to end of driving lanes
|
||||||
|
- pathfinding or trace or something is wrong for walking; the last line sometimes has the wrong distance
|
||||||
|
- actually spawn stuff
|
||||||
|
- stop disabling mouseover at low zoom when in this mode
|
||||||
|
- then back to zorder for cars/peds
|
||||||
|
|
||||||
|
- try showing traffic signals by little boxes at the end of lanes
|
||||||
|
- red circle means right turn on red OK, red right arrow means nope, green means normal turns ok, green arrow means protected left, crosswalk hand or stick figure
|
||||||
|
|
||||||
- color roads as solid black when zoomed out, and make intersections similar (except for stop sign / signal)
|
- color roads as solid black when zoomed out, and make intersections similar (except for stop sign / signal)
|
||||||
- audit all panics
|
- audit all panics
|
||||||
- tune text color, size, padding
|
- tune text color, size, padding
|
||||||
|
@ -6,3 +6,4 @@ pub mod floodfill;
|
|||||||
pub mod geom_validation;
|
pub mod geom_validation;
|
||||||
pub mod hider;
|
pub mod hider;
|
||||||
pub mod layers;
|
pub mod layers;
|
||||||
|
pub mod spawn_agent;
|
||||||
|
88
editor/src/plugins/debug/spawn_agent.rs
Normal file
88
editor/src/plugins/debug/spawn_agent.rs
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
use crate::objects::{Ctx, ID};
|
||||||
|
use crate::plugins::{Plugin, PluginCtx};
|
||||||
|
use dimensioned::si;
|
||||||
|
use ezgui::{Color, GfxCtx, Key};
|
||||||
|
use map_model::{BuildingID, PathRequest, Pathfinder, Trace, LANE_THICKNESS};
|
||||||
|
use std::f64;
|
||||||
|
|
||||||
|
pub struct SpawnAgent {
|
||||||
|
from_bldg: BuildingID,
|
||||||
|
|
||||||
|
maybe_goal: Option<(BuildingID, Option<Trace>)>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl SpawnAgent {
|
||||||
|
pub fn new(ctx: &mut PluginCtx) -> Option<SpawnAgent> {
|
||||||
|
if let Some(ID::Building(id)) = ctx.primary.current_selection {
|
||||||
|
if ctx
|
||||||
|
.input
|
||||||
|
.contextual_action(Key::F3, "spawn an agent starting here")
|
||||||
|
{
|
||||||
|
return Some(SpawnAgent {
|
||||||
|
from_bldg: id,
|
||||||
|
maybe_goal: None,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Plugin for SpawnAgent {
|
||||||
|
fn blocking_event(&mut self, ctx: &mut PluginCtx) -> bool {
|
||||||
|
ctx.input.set_mode("Agent Spawner", &ctx.canvas);
|
||||||
|
if ctx.input.modal_action("quit") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO disabling mouseover at low zoom is actually annoying now
|
||||||
|
if let Some(ID::Building(id)) = ctx.primary.current_selection {
|
||||||
|
if self
|
||||||
|
.maybe_goal
|
||||||
|
.as_ref()
|
||||||
|
.map(|(b, _)| *b != id)
|
||||||
|
.unwrap_or(true)
|
||||||
|
{
|
||||||
|
self.maybe_goal = Some((id, None));
|
||||||
|
|
||||||
|
let map = &ctx.primary.map;
|
||||||
|
let start = map.get_b(self.from_bldg).front_path.sidewalk;
|
||||||
|
if let Some(path) = Pathfinder::shortest_distance(
|
||||||
|
map,
|
||||||
|
PathRequest {
|
||||||
|
start,
|
||||||
|
end: map.get_b(id).front_path.sidewalk,
|
||||||
|
can_use_bike_lanes: false,
|
||||||
|
can_use_bus_lanes: false,
|
||||||
|
},
|
||||||
|
) {
|
||||||
|
self.maybe_goal =
|
||||||
|
Some((id, path.trace(map, start.dist_along(), f64::MAX * si::M)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
self.maybe_goal = None;
|
||||||
|
}
|
||||||
|
|
||||||
|
if self.maybe_goal.is_some() && ctx.input.contextual_action(Key::F3, "end the agent here") {
|
||||||
|
// TODO spawn em
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
fn draw(&self, g: &mut GfxCtx, ctx: &Ctx) {
|
||||||
|
if let Some((_, Some(ref trace))) = self.maybe_goal {
|
||||||
|
g.draw_polygon(ctx.cs.get("route"), &trace.make_polygons(LANE_THICKNESS));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn color_for(&self, obj: ID, ctx: &Ctx) -> Option<Color> {
|
||||||
|
if ID::Building(self.from_bldg) == obj {
|
||||||
|
Some(ctx.cs.get("selected"))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -231,6 +231,9 @@ impl UIState for DefaultUIState {
|
|||||||
} else if let Some(p) = debug::debug_polygon::DebugPolygon::new(&mut ctx) {
|
} else if let Some(p) = debug::debug_polygon::DebugPolygon::new(&mut ctx) {
|
||||||
self.exclusive_blocking_plugin = Some(Box::new(p));
|
self.exclusive_blocking_plugin = Some(Box::new(p));
|
||||||
return;
|
return;
|
||||||
|
} else if let Some(p) = debug::spawn_agent::SpawnAgent::new(&mut ctx) {
|
||||||
|
self.exclusive_blocking_plugin = Some(Box::new(p));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -178,6 +178,7 @@ impl<S: UIState> GUI<RenderingHints> for UI<S> {
|
|||||||
(Key::Comma, "prev item"),
|
(Key::Comma, "prev item"),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
ModalMenu::new("Agent Spawner", vec![(Key::Enter, "quit")]),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user