pub struct Stage {
nodes: SlotMap<NodeId, Node>,
root: NodeId,
}Expand description
Scene graph root.
Owns all nodes via a SlotMap keyed by NodeId. The tree is rooted at
a Container returned by Stage::root. Child relationships are tracked
inside each Container.
Fields§
§nodes: SlotMap<NodeId, Node>§root: NodeIdImplementations§
Source§impl Stage
impl Stage
Sourcepub fn add_child(
&mut self,
parent: NodeId,
child: impl Into<Node>,
) -> Option<NodeId>
pub fn add_child( &mut self, parent: NodeId, child: impl Into<Node>, ) -> Option<NodeId>
Insert child as a child of parent. Returns the new node ID.
child’s parent field is set; parent’s children list is appended.
Returns None if parent doesn’t exist.
Sourcepub fn detach(&mut self, child: NodeId) -> bool
pub fn detach(&mut self, child: NodeId) -> bool
Detach child from its parent without destroying it.
After this call the child is an orphan still reachable via Stage::get
but no longer in any container’s children list. Returns true if the
child was attached.
Sourcepub fn destroy(&mut self, id: NodeId) -> bool
pub fn destroy(&mut self, id: NodeId) -> bool
Destroy a node and (recursively) all its descendants. Detaches from parent first.
Returns true if the node existed.
Sourcepub fn traverse_pre_order(
&self,
start: NodeId,
visit: impl FnMut(NodeId, &Node),
)
pub fn traverse_pre_order( &self, start: NodeId, visit: impl FnMut(NodeId, &Node), )
Pre-order traversal from a starting node. Visits the start first, then each child’s subtree in insertion order.
fn collect_descendants(&self, id: NodeId) -> Vec<NodeId>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Stage
impl !RefUnwindSafe for Stage
impl Send for Stage
impl Sync for Stage
impl Unpin for Stage
impl UnsafeUnpin for Stage
impl !UnwindSafe for Stage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().