Trait BaseSceneGraph

Source
pub trait BaseSceneGraph: AbstractSceneGraph {
    type Prefab: PrefabData<Graph = Self>;
    type Node: SceneGraphNode<SceneGraph = Self, ResourceData = Self::Prefab>;

Show 15 methods // Required methods fn root(&self) -> Handle<Self::Node>; fn set_root(&mut self, root: Handle<Self::Node>); fn try_get(&self, handle: Handle<Self::Node>) -> Option<&Self::Node>; fn try_get_mut( &mut self, handle: Handle<Self::Node>, ) -> Option<&mut Self::Node>; fn is_valid_handle(&self, handle: Handle<Self::Node>) -> bool; fn add_node(&mut self, node: Self::Node) -> Handle<Self::Node>; fn remove_node(&mut self, node_handle: Handle<Self::Node>); fn link_nodes( &mut self, child: Handle<Self::Node>, parent: Handle<Self::Node>, ); fn unlink_node(&mut self, node_handle: Handle<Self::Node>); fn isolate_node(&mut self, node_handle: Handle<Self::Node>); // Provided methods fn node(&self, handle: Handle<Self::Node>) -> &Self::Node { ... } fn node_mut(&mut self, handle: Handle<Self::Node>) -> &mut Self::Node { ... } fn change_hierarchy_root( &mut self, prev_root: Handle<Self::Node>, new_root: Handle<Self::Node>, ) -> LinkScheme<Self::Node> { ... } fn apply_link_scheme(&mut self, scheme: LinkScheme<Self::Node>) { ... } fn remove_nodes(&mut self, nodes: &[Handle<Self::Node>]) { ... }
}

Required Associated Types§

Source

type Prefab: PrefabData<Graph = Self>

Source

type Node: SceneGraphNode<SceneGraph = Self, ResourceData = Self::Prefab>

Required Methods§

Source

fn root(&self) -> Handle<Self::Node>

Returns a handle of the root node of the graph.

Source

fn set_root(&mut self, root: Handle<Self::Node>)

Sets the new root of the graph. If used incorrectly, it may create isolated sub-graphs.

Source

fn try_get(&self, handle: Handle<Self::Node>) -> Option<&Self::Node>

Tries to borrow a node, returns Some(node) if the handle is valid, None - otherwise.

Source

fn try_get_mut(&mut self, handle: Handle<Self::Node>) -> Option<&mut Self::Node>

Tries to borrow a node, returns Some(node) if the handle is valid, None - otherwise.

Source

fn is_valid_handle(&self, handle: Handle<Self::Node>) -> bool

Checks whether the given node handle is valid or not.

Source

fn add_node(&mut self, node: Self::Node) -> Handle<Self::Node>

Adds a new node to the graph.

Source

fn remove_node(&mut self, node_handle: Handle<Self::Node>)

Destroys the node and its children recursively.

Links specified child with specified parent.

Unlinks specified node from its parent and attaches it to root graph node.

Source

fn isolate_node(&mut self, node_handle: Handle<Self::Node>)

Detaches the node from its parent, making the node unreachable from any other node in the graph.

Provided Methods§

Source

fn node(&self, handle: Handle<Self::Node>) -> &Self::Node

Borrows a node by its handle.

Source

fn node_mut(&mut self, handle: Handle<Self::Node>) -> &mut Self::Node

Borrows a node by its handle.

Source

fn change_hierarchy_root( &mut self, prev_root: Handle<Self::Node>, new_root: Handle<Self::Node>, ) -> LinkScheme<Self::Node>

Reorders the node hierarchy so the new_root becomes the root node for the entire hierarchy under the prev_root node. For example, if we have this hierarchy and want to set C as the new root:

Root_
     |_A_
         |_B
         |_C_
            |_D

The new hierarchy will become:

C_
  |_D
  |_A_
  |   |_B
  |_Root

This method returns an instance of LinkScheme, that could be used to revert the hierarchy back to its original. See Self::apply_link_scheme for more info.

Applies the given link scheme to the graph, basically reverting graph structure to the one that was before the call of Self::change_hierarchy_root.

Source

fn remove_nodes(&mut self, nodes: &[Handle<Self::Node>])

Removes all the nodes from the given slice.

Implementors§