use fbxcel::tree::v7400::Tree;
use crate::v7400::{
connection::ConnectionsCache,
definition::DefinitionsCache,
global_settings::GlobalSettings,
object::{scene::SceneHandle, ObjectHandle, ObjectsCache},
};
pub use self::loader::Loader;
mod loader;
#[derive(Debug, Clone)]
pub struct Document {
tree: Tree,
objects: ObjectsCache,
connections: ConnectionsCache,
definitions: DefinitionsCache,
}
impl Document {
pub fn tree(&self) -> &Tree {
&self.tree
}
pub(crate) fn objects_cache(&self) -> &ObjectsCache {
&self.objects
}
pub(crate) fn connections_cache(&self) -> &ConnectionsCache {
&self.connections
}
pub(crate) fn definitions_cache(&self) -> &DefinitionsCache {
&self.definitions
}
pub fn objects(&self) -> impl Iterator<Item = ObjectHandle<'_>> {
self.objects
.object_node_ids()
.map(move |id| id.to_object_handle(self))
}
pub fn scenes(&self) -> impl Iterator<Item = SceneHandle<'_>> {
self.objects.document_nodes().iter().map(move |obj_id| {
SceneHandle::new(obj_id.to_object_handle(self))
.expect("Should never fail: Actually using `Document` objects")
})
}
#[inline]
#[must_use]
pub fn global_settings(&self) -> Option<GlobalSettings> {
GlobalSettings::new(self)
}
}
impl AsRef<Tree> for Document {
fn as_ref(&self) -> &Tree {
&self.tree
}
}