passive: Option<OccId>, // kept in synch with Occultation::pieces
}
+pub type DisplacementIndex = usize;
+
#[derive(Clone,Debug,Serialize,Deserialize)]
pub struct Occultation {
region: Area, // automatically affect pieces here
occulter: PieceId, // kept in synch with PieceOccult::active
- pieces: BTreeSet<PieceId>, // kept in synch with PieceOccult::passive
+ // kept synch with PO::passive. indices are either 0 or dense, 0..len()
+ // except after recalculate_occultation_general and before xxx tbd
+ pieces: BTreeMap<PieceId, DisplacementIndex>,
#[serde(flatten)] views: OccultationViews,
}
}
};
update_pieces(ONI::Old, &|opcs|{ opcs.remove(&piece); });
- update_pieces(ONI::New, &|opcs|{ opcs.insert(piece); });
+ update_pieces(ONI::New, &|opcs|{ opcs.insert(piece,0); });
gpieces.byid_mut(piece).unwrap().occult.passive = *occids.new();
})(); // <- no ?, infallible commitment
pieces_fallback_buf = gpieces
.iter()
.filter_map(|(ppiece, pgpc)| {
- if pgpc.occult.passive == Some(occid) { Some(ppiece) }
+ if pgpc.occult.passive == Some(occid) { Some((ppiece,0)) }
else { None }
})
.collect();
&pieces_fallback_buf
};
- for &ppiece in pieces.iter() {
+ for (&ppiece,_) in pieces.iter() {
recalculate_occultation_ofmany(gplayers, gpieces, goccults, ipieces,
ppiece, &mut updates)
.unwrap_or_else(|e| {
pub use std::borrow::Cow;
pub use std::cmp::{self, max, min, Ordering};
pub use std::collections::VecDeque;
-pub use std::collections::{btree_set, BTreeSet};
+pub use std::collections::{btree_map, btree_set, BTreeMap, BTreeSet};
pub use std::collections::{hash_map, HashMap, HashSet};
pub use std::convert::{Infallible, TryFrom, TryInto};
pub use std::env;