mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-25 07:25:47 +03:00
add some logging to debug #19
This commit is contained in:
parent
dc2cc81249
commit
ed2f703e85
@ -330,6 +330,8 @@ impl<'a> Timer<'a> {
|
||||
for (idx, req) in requests.into_iter().enumerate() {
|
||||
let tx = tx.clone();
|
||||
scope.execute(move || {
|
||||
// TODO Can we catch panics here, dump a better stacktrace? ezgui runner does
|
||||
// this
|
||||
tx.send((idx, cb(req))).unwrap();
|
||||
});
|
||||
}
|
||||
|
@ -298,6 +298,11 @@ pub fn spawn_agents_around(i: IntersectionID, ui: &mut UI, ctx: &EventCtx) {
|
||||
let sim = &mut ui.primary.sim;
|
||||
let mut rng = ui.primary.current_flags.sim_flags.make_rng();
|
||||
|
||||
let mut timer = Timer::new(format!(
|
||||
"spawning agents around {} (rng seed {:?})",
|
||||
i, ui.primary.current_flags.sim_flags.rng_seed
|
||||
));
|
||||
|
||||
for l in &map.get_i(i).incoming_lanes {
|
||||
let lane = map.get_l(*l);
|
||||
if lane.is_driving() || lane.is_biking() {
|
||||
@ -348,7 +353,7 @@ pub fn spawn_agents_around(i: IntersectionID, ui: &mut UI, ctx: &EventCtx) {
|
||||
}
|
||||
}
|
||||
|
||||
sim.spawn_all_trips(map, &mut Timer::throwaway(), false);
|
||||
sim.spawn_all_trips(map, &mut timer, false);
|
||||
sim.step(map, SMALL_DT);
|
||||
ui.recalculate_current_selection(ctx);
|
||||
}
|
||||
|
@ -1,16 +1,17 @@
|
||||
use fast_paths::{NodeId, ShortestPath};
|
||||
use serde::{Deserialize, Deserializer, Serialize};
|
||||
use std::collections::BTreeMap;
|
||||
use std::fmt::Debug;
|
||||
|
||||
// TODO Upstream this in fast_paths when this is more solid.
|
||||
#[derive(Serialize)]
|
||||
pub struct NodeMap<T: Copy + Ord + Serialize> {
|
||||
pub struct NodeMap<T: Copy + Ord + Debug + Serialize> {
|
||||
#[serde(skip_serializing)]
|
||||
node_to_id: BTreeMap<T, NodeId>,
|
||||
id_to_node: Vec<T>,
|
||||
}
|
||||
|
||||
impl<T: Copy + Ord + Serialize> NodeMap<T> {
|
||||
impl<T: Copy + Ord + Debug + Serialize> NodeMap<T> {
|
||||
pub fn new() -> NodeMap<T> {
|
||||
NodeMap {
|
||||
node_to_id: BTreeMap::new(),
|
||||
@ -29,7 +30,11 @@ impl<T: Copy + Ord + Serialize> NodeMap<T> {
|
||||
}
|
||||
|
||||
pub fn get(&self, node: T) -> NodeId {
|
||||
self.node_to_id[&node]
|
||||
if let Some(id) = self.node_to_id.get(&node) {
|
||||
*id
|
||||
} else {
|
||||
panic!("{:?} not in NodeMap", node);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn translate(&self, path: &ShortestPath) -> Vec<T> {
|
||||
@ -44,7 +49,7 @@ impl<T: Copy + Ord + Serialize> NodeMap<T> {
|
||||
pub fn deserialize_nodemap<
|
||||
'de,
|
||||
D: Deserializer<'de>,
|
||||
T: Deserialize<'de> + Copy + Ord + Serialize,
|
||||
T: Deserialize<'de> + Copy + Ord + Debug + Serialize,
|
||||
>(
|
||||
d: D,
|
||||
) -> Result<NodeMap<T>, D::Error> {
|
||||
|
@ -17,7 +17,7 @@ pub struct SidewalkPathfinder {
|
||||
path_calc: ThreadLocal<RefCell<PathCalculator>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Serialize, Deserialize)]
|
||||
enum Node {
|
||||
// false is src_i, true is dst_i
|
||||
SidewalkEndpoint(LaneID, bool),
|
||||
|
Loading…
Reference in New Issue
Block a user