diff --git a/src/tools/minimap.rs b/src/tools/minimap.rs index a903c647..bcfed217 100644 --- a/src/tools/minimap.rs +++ b/src/tools/minimap.rs @@ -187,7 +187,7 @@ pub fn generate( 'atom: for atom in atoms { // At this time, space is invisible. Earlier steps need to process it. for pass in render_passes.iter() { - if !pass.final_filter(&atom, objtree) { + if !pass.late_filter(&atom, objtree) { continue 'atom; } } diff --git a/src/tools/render_passes/mod.rs b/src/tools/render_passes/mod.rs index cb011ab2..46143145 100644 --- a/src/tools/render_passes/mod.rs +++ b/src/tools/render_passes/mod.rs @@ -1,9 +1,51 @@ use dm::objtree::*; use minimap::Atom; +/// A map rendering pass. +/// +/// These methods are applied to any given atom in roughly the order they +/// appear here. #[allow(unused_variables)] pub trait RenderPass { - fn final_filter(&self, atom: &Atom, objtree: &ObjectTree) -> bool { true } + /// Filter atoms at the beginning of the process. + /// + /// Return `false` to discard the atom. + fn early_filter(&self, + atom: &Atom, + objtree: &ObjectTree, + ) -> bool { true } + + /// Expand atoms, such as spawners into the atoms they spawn. + /// + /// Return `true` to consume the original atom. + fn expand(&self, + atom: &Atom, + objtree: &ObjectTree, + output: &mut Vec, + ) -> bool { false } + + /// Adjust the variables of an atom. + fn adjust_vars(&self, + atom: &mut Atom, + objtree: &ObjectTree, + ) {} + + /// Apply overlays and underlays to an atom, in the form of pseudo-atoms. + fn overlays(&self, + atom: &mut Atom, + objtree: &ObjectTree, + underlays: &mut Vec, + overlays: &mut Vec, + ) {} + + /// Filter atoms at the end of the process. + /// + /// Will act on adjusted atoms and pseudo-atoms from `adjust_vars` and + /// `overlays`. Return `true` to keep and `false` to discard. + fn late_filter(&self, + atom: &Atom, + objtree: &ObjectTree, + ) -> bool { true } } pub struct RenderPassInfo { @@ -55,7 +97,7 @@ pub fn configure(include: &str, exclude: &str) -> Vec> { #[derive(Default)] pub struct HideSpace; impl RenderPass for HideSpace { - fn final_filter(&self, atom: &Atom, _: &ObjectTree) -> bool { + fn late_filter(&self, atom: &Atom, _: &ObjectTree) -> bool { !atom.istype("/turf/open/space/") } }