mirage-engine 0.2.0

Mirage, an immediate-mode 3D engine for simple games on desktop and the browser
Documentation
//! What the tests of a loaded source read off the data a build returns.

use crate::assets::Unresolved;
use crate::mesh::{Clip, Geometry, MeshData, Part};

/// The mesh `data` builds to, `"Hull"` standing in for a `Meshes` set's own
/// name for it.
///
/// Fails the test where any pull of that build did not resolve.
pub(crate) fn geometry<P: Part, C: Clip>(data: MeshData<P, C>) -> Geometry {
    let built = data.erased("Hull");
    assert!(
        built.unresolved.is_empty(),
        "built whole: {:?}",
        built.unresolved
    );

    built.geometry
}

/// What the pulls of `data`'s build did not get, `"Hull"` standing in for a
/// `Meshes` set's own name for it.
pub(crate) fn unresolved<P: Part, C: Clip>(data: MeshData<P, C>) -> Unresolved {
    data.erased("Hull").unresolved
}

/// The same as the startup error states it, without the line every one of
/// them opens with.
pub(crate) fn error<P: Part, C: Clip>(data: MeshData<P, C>) -> String {
    let recorded = unresolved(data)
        .error()
        .expect("something did not resolve")
        .to_string();

    recorded
        .strip_prefix("the game's assets did not resolve: ")
        .expect("every startup error opens with that")
        .to_owned()
}