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§
type Prefab: PrefabData<Graph = Self>
type Node: SceneGraphNode<SceneGraph = Self, ResourceData = Self::Prefab>
Required Methods§
Sourcefn set_root(&mut self, root: Handle<Self::Node>)
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.
Sourcefn try_get(&self, handle: Handle<Self::Node>) -> Option<&Self::Node>
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.
Sourcefn try_get_mut(&mut self, handle: Handle<Self::Node>) -> Option<&mut Self::Node>
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.
Sourcefn is_valid_handle(&self, handle: Handle<Self::Node>) -> bool
fn is_valid_handle(&self, handle: Handle<Self::Node>) -> bool
Checks whether the given node handle is valid or not.
Sourcefn remove_node(&mut self, node_handle: Handle<Self::Node>)
fn remove_node(&mut self, node_handle: Handle<Self::Node>)
Destroys the node and its children recursively.
Sourcefn link_nodes(&mut self, child: Handle<Self::Node>, parent: Handle<Self::Node>)
fn link_nodes(&mut self, child: Handle<Self::Node>, parent: Handle<Self::Node>)
Links specified child with specified parent.
Sourcefn unlink_node(&mut self, node_handle: Handle<Self::Node>)
fn unlink_node(&mut self, node_handle: Handle<Self::Node>)
Unlinks specified node from its parent and attaches it to root graph node.
Sourcefn isolate_node(&mut self, node_handle: Handle<Self::Node>)
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§
Sourcefn node_mut(&mut self, handle: Handle<Self::Node>) -> &mut Self::Node
fn node_mut(&mut self, handle: Handle<Self::Node>) -> &mut Self::Node
Borrows a node by its handle.
Sourcefn change_hierarchy_root(
&mut self,
prev_root: Handle<Self::Node>,
new_root: Handle<Self::Node>,
) -> LinkScheme<Self::Node>
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.
Sourcefn apply_link_scheme(&mut self, scheme: LinkScheme<Self::Node>)
fn apply_link_scheme(&mut self, scheme: LinkScheme<Self::Node>)
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
.
Sourcefn remove_nodes(&mut self, nodes: &[Handle<Self::Node>])
fn remove_nodes(&mut self, nodes: &[Handle<Self::Node>])
Removes all the nodes from the given slice.