pub trait BaseSceneGraph: AbstractSceneGraph {
type Prefab: PrefabData<Graph = Self>;
type NodeContainer: PayloadContainer<Element = Self::Node>;
type Node: SceneGraphNode<SceneGraph = Self, ResourceData = Self::Prefab>;
Show 19 methods
// Required methods
fn summary(&self) -> String;
fn actual_type_id(&self, handle: Handle<Self::Node>) -> Option<TypeId>;
fn actual_type_name(
&self,
handle: Handle<Self::Node>,
) -> Option<&'static str>;
fn derived_type_ids(
&self,
handle: Handle<Self::Node>,
) -> Option<Vec<TypeId>>;
fn root(&self) -> Handle<Self::Node>;
fn set_root(&mut self, root: Handle<Self::Node>);
fn try_get_node(&self, handle: Handle<Self::Node>) -> Option<&Self::Node>;
fn try_get_node_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>]) { ... }
}Expand description
BaseSceneGraph is a dyn-compatible trait for all scene graphs to implement.
Methods that would not be dyn-compatible are available through the
SceneGraph trait.
Required Associated Types§
type Prefab: PrefabData<Graph = Self>
type NodeContainer: PayloadContainer<Element = Self::Node>
type Node: SceneGraphNode<SceneGraph = Self, ResourceData = Self::Prefab>
Required Methods§
Sourcefn summary(&self) -> String
fn summary(&self) -> String
Generate a string that briefly summarizes the content of the graph for debugging.
Sourcefn actual_type_id(&self, handle: Handle<Self::Node>) -> Option<TypeId>
fn actual_type_id(&self, handle: Handle<Self::Node>) -> Option<TypeId>
Returns actual type id of the node.
Sourcefn actual_type_name(&self, handle: Handle<Self::Node>) -> Option<&'static str>
fn actual_type_name(&self, handle: Handle<Self::Node>) -> Option<&'static str>
Returns actual type name of the node.
Sourcefn derived_type_ids(&self, handle: Handle<Self::Node>) -> Option<Vec<TypeId>>
fn derived_type_ids(&self, handle: Handle<Self::Node>) -> Option<Vec<TypeId>>
Returns a list of derived type ids of the node.
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_node(&self, handle: Handle<Self::Node>) -> Option<&Self::Node>
fn try_get_node(&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_node_mut(
&mut self,
handle: Handle<Self::Node>,
) -> Option<&mut Self::Node>
fn try_get_node_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_
|_DThe new hierarchy will become:
C_
|_D
|_A_
| |_B
|_RootThis 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.