Sketch out more render pass entry points

This commit is contained in:
Tad Hardesty 2018-02-05 00:12:33 -08:00
parent cba570ffbd
commit a1f34edeab
2 changed files with 45 additions and 3 deletions

View file

@ -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;
}
}

View file

@ -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<Atom>,
) -> 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<Atom>,
overlays: &mut Vec<Atom>,
) {}
/// 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<Box<RenderPass>> {
#[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/")
}
}