Skip to main content

SceneGraph

Struct SceneGraph 

Source
pub struct SceneGraph { /* private fields */ }
Expand description

Arena-based scene graph with generational indices.

Implementations§

Source§

impl SceneGraph

Source

pub fn new() -> Self

Create an empty scene graph.

Source

pub fn with_root() -> Self

Create a scene graph with a root container node.

Source

pub fn root(&self) -> Option<NodeId>

The root node, if any.

Source

pub fn set_root(&mut self, id: NodeId)

Set the root node.

Source

pub fn insert(&mut self, node: Node) -> NodeId

Insert a node into the arena, returning its ID.

Source

pub fn remove(&mut self, id: NodeId) -> Option<Node>

Remove a node by ID. Returns the node if it existed.

Source

pub fn get(&self, id: NodeId) -> Option<&Node>

Get a reference to a node.

Source

pub fn get_mut(&mut self, id: NodeId) -> Option<&mut Node>

Get a mutable reference to a node.

Source

pub fn add_child(&mut self, parent: NodeId, child: NodeId)

Add a child to a parent node.

Source

pub fn insert_child(&mut self, parent: NodeId, node: Node) -> NodeId

Insert a node as a child of parent.

Source

pub fn len(&self) -> usize

Number of live nodes.

Source

pub fn is_empty(&self) -> bool

Whether the graph is empty.

Source

pub fn iter(&self) -> impl Iterator<Item = (NodeId, &Node)>

Iterate over all live (NodeId, &Node) pairs.

Source

pub fn world_transform(&self, id: NodeId) -> Affine2D

Compute the world transform for a node by walking up the parent chain.

Source

pub fn collect_marks(&self) -> Vec<(NodeId, Affine2D)>

Collect all leaf marks in z-order (depth-first, sorted by z_order within siblings).

Trait Implementations§

Source§

impl Default for SceneGraph

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.