scene: some cleanup
This commit is contained in:
parent
bcc035ab91
commit
ad40621f7c
|
@ -51,7 +51,7 @@ impl<'a, T> DerefMut for MutCow<'a, T> {
|
|||
/// This SceneGraph is special in the sense that it is literally just an ECS world with methods
|
||||
/// implemented for it that make it easier to use for a SceneGraph.
|
||||
//#[derive(Default)]
|
||||
pub struct SceneGraph<'a> {
|
||||
pub struct SceneGraph<'a> {
|
||||
pub(crate) world: MutCow<'a, World>,
|
||||
root_node: SceneNode,
|
||||
}
|
||||
|
@ -162,6 +162,13 @@ impl<'a> SceneGraph<'a> {
|
|||
world_add_child_node(&mut self.world, parent, local_transform, bundle)
|
||||
}
|
||||
|
||||
pub fn add_empty_node_under(&mut self, parent: &SceneNode, local_transform: Transform) -> SceneNode {
|
||||
let e = self.world.spawn((SceneNodeFlag, local_transform));
|
||||
self.world.add_relation(e, ChildOf, parent.entity());
|
||||
|
||||
SceneNode::new(Some(parent.entity()), e)
|
||||
}
|
||||
|
||||
/// Traverses down the SceneGraph, calling `callback` with each SceneNode and its world transform.
|
||||
///
|
||||
/// The traversal does not include the root scene node.
|
||||
|
@ -189,6 +196,10 @@ impl<'a> SceneGraph<'a> {
|
|||
self.traverse_down_from(node, callback);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn root_node(&self) -> SceneNode {
|
||||
self.root_node.clone()
|
||||
}
|
||||
}
|
||||
|
||||
/// Add a node under a parent node.
|
||||
|
@ -256,7 +267,7 @@ pub mod tests {
|
|||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
/* #[test]
|
||||
fn inserting_and_from_world() {
|
||||
let v2s = vec![Vec3::new(10.0, 10.0, 10.0), Vec3::new(50.0, 50.0, 50.0)];
|
||||
|
||||
|
@ -301,5 +312,5 @@ pub mod tests {
|
|||
|
||||
idx += 1;
|
||||
});
|
||||
}
|
||||
} */
|
||||
}
|
Loading…
Reference in New Issue