region: Region, // automatically affect pieces here
occulter: PieceId, // kept in synch with PieceOccult::active
notches: Notches, // kept in synch with PieceOccult::passive
+ unnotched: HashSet<PieceId>, // kept in synch with PieceOccult::passive
ppiece_use_size: Pos, // taken from first piece
#[serde(flatten)] views: OccultationViews,
}
-> Option<usize> {
self.active_occ(goccults)?.map(|occ| {
let notches_len = usize::try_from(occ.notches.len()).unwrap();
- notches_len
+ notches_len + occ.unnotched.len()
})
}
if let Some(notch) = permute_notch {
occ.notches.remove(piece, notch)
.unwrap_or_else(|e| error!("removing occulted piece {:?}", e));
+ } else {
+ occ.unnotched.remove(&piece);
}
}
}
}
pub fn pieces(&self) -> impl Iterator<Item=PieceId> + '_ {
- self.notches.iter()
+ chain!(
+ self.notches.iter(),
+ self.unnotched.iter().cloned(),
+ )
}
}
.notches
.remove(piece, old_notch)
.unwrap();
+ } else {
+ occ
+ .unnotched
+ .remove(&piece);
}
};
let passive = if_chain!{
if let Some(ilk) = wants!( ipc.occilk.as_ref() );
then {
let permute_notch = match ilk {
- IOI::Distinct(_) => None,
+ IOI::Distinct(_) => {
+ occ.unnotched.insert(piece);
+ None
+ },
IOI::Mix(ilk) => {
if_chain!{
if occ.notches.is_empty();
views,
ppiece_use_size: PosC::zero(),
notches: default(),
+ unnotched: default(),
};
debug!("creating occultation {:?}", &occultation);
trace_dbg!("recalc", &recalc);
pub use fs2::FileExt;
pub use if_chain::if_chain;
pub use index_vec::{define_index_type, index_vec, IndexSlice, IndexVec};
-pub use itertools::{iproduct, izip, zip_eq, EitherOrBoth, Itertools};
+pub use itertools::{chain, iproduct, izip, zip_eq, EitherOrBoth, Itertools};
pub use lazy_static::lazy_static;
pub use log::{debug, error, info, trace, warn};
pub use log::{log, log_enabled};