Struct Graph

Source
pub struct Graph {
    pub physics: PhysicsWorld,
    pub physics2d: PhysicsWorld,
    pub sound_context: SoundContext,
    pub performance_statistics: GraphPerformanceStatistics,
    pub event_broadcaster: GraphEventBroadcaster,
    /* private fields */
}
Expand description

See module docs.

Fields§

§physics: PhysicsWorld

Backing physics “world”. It is responsible for the physics simulation.

§physics2d: PhysicsWorld

Backing 2D physics “world”. It is responsible for the 2D physics simulation.

§sound_context: SoundContext

Backing sound context. It is responsible for sound rendering.

§performance_statistics: GraphPerformanceStatistics

Performance statistics of a last Graph::update call.

§event_broadcaster: GraphEventBroadcaster

Allows you to “subscribe” for graph events.

Implementations§

Source§

impl Graph

Source

pub const POOL: &'static str = "pool"

Source

pub const PHYSICS: &'static str = "physics"

Source

pub const PHYSICS_2_D: &'static str = "physics2d"

Source

pub const LIGHTMAP: &'static str = "lightmap"

Source

pub const INSTANCE_ID_MAP: &'static str = "instance_id_map"

Source§

impl Graph

Source

pub fn new() -> Self

Creates new graph instance with single root node.

Source

pub fn from_hierarchy(root: Handle<Node>, other_graph: &Self) -> Self

Creates a new graph using a hierarchy of nodes specified by the root.

Source

pub fn change_root_node(&mut self, root: Node)

Sets new root of the graph and attaches the old root to the new root. Old root becomes a child node of the new root.

Source

pub fn find_references_to(&self, target: Handle<Node>) -> Vec<Handle<Node>>

Tries to find references of the given node in other scene nodes. It could be used to check if the node is used by some other scene node or not. Returns an array of nodes, that references the given node. This method is reflection-based, so it is quite slow and should not be used every frame.

Source

pub fn get_two_mut( &mut self, nodes: (Handle<Node>, Handle<Node>), ) -> (&mut Node, &mut Node)

Tries to borrow mutable references to two nodes at the same time by given handles. Will panic if handles overlaps (points to same node).

Source

pub fn get_three_mut( &mut self, nodes: (Handle<Node>, Handle<Node>, Handle<Node>), ) -> (&mut Node, &mut Node, &mut Node)

Tries to borrow mutable references to three nodes at the same time by given handles. Will return Err of handles overlaps (points to same node).

Source

pub fn get_four_mut( &mut self, nodes: (Handle<Node>, Handle<Node>, Handle<Node>, Handle<Node>), ) -> (&mut Node, &mut Node, &mut Node, &mut Node)

Tries to borrow mutable references to four nodes at the same time by given handles. Will panic if handles overlaps (points to same node).

Source

pub fn get_root(&self) -> Handle<Node>

Returns root node of current graph.

Source

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

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

Source

pub fn begin_multi_borrow( &mut self, ) -> MultiBorrowContext<'_, Node, NodeContainer>

Begins multi-borrow that allows you borrow to as many shared references to the graph nodes as you need and only one mutable reference to a node. See MultiBorrowContext::try_get for more info.

§Examples
let mut graph = Graph::new();

let handle1 = PivotBuilder::new(BaseBuilder::new()).build(&mut graph);
let handle2 = PivotBuilder::new(BaseBuilder::new()).build(&mut graph);
let handle3 = PivotBuilder::new(BaseBuilder::new()).build(&mut graph);
let handle4 = PivotBuilder::new(BaseBuilder::new()).build(&mut graph);

let mut ctx = graph.begin_multi_borrow();

let node1 = ctx.try_get(handle1);
let node2 = ctx.try_get(handle2);
let node3 = ctx.try_get(handle3);
let node4 = ctx.try_get(handle4);

assert!(node1.is_ok());
assert!(node2.is_ok());
assert!(node3.is_ok());
assert!(node4.is_ok());

// An attempt to borrow the same node twice as immutable and mutable will fail.
assert!(ctx.try_get_mut(handle1).is_err());

Links specified child with specified parent while keeping the child’s global position and rotation.

Source

pub fn find_first_by_script<S>( &self, root_node: Handle<Node>, ) -> Option<(Handle<Node>, &Node)>
where S: ScriptTrait,

Searches for a first node with a script of the given type S in the hierarchy starting from the given root_node.

Source

pub fn copy_node<F, Pre, Post>( &self, node_handle: Handle<Node>, dest_graph: &mut Graph, filter: &mut F, pre_process_callback: &mut Pre, post_process_callback: &mut Post, ) -> (Handle<Node>, NodeHandleMap<Node>)
where F: FnMut(Handle<Node>, &Node) -> bool, Pre: FnMut(Handle<Node>, &mut Node), Post: FnMut(Handle<Node>, Handle<Node>, &mut Node),

Creates deep copy of node with all children. This is relatively heavy operation! In case if any error happened it returns Handle::NONE. This method can be used to create exact copy of given node hierarchy. For example you can prepare rocket model: case of rocket will be mesh, and fire from nozzle will be particle system, and when you fire from rocket launcher you just need to create a copy of such “prefab”.

§Implementation notes

Returns tuple where first element is handle to copy of node, and second element - old-to-new hash map, which can be used to easily find copy of node by its original.

Filter allows to exclude some nodes from copied hierarchy. It must return false for odd nodes. Filtering applied only to descendant nodes.

Source

pub fn copy_node_inplace<F>( &mut self, node_handle: Handle<Node>, filter: &mut F, ) -> (Handle<Node>, NodeHandleMap<Node>)
where F: FnMut(Handle<Node>, &Node) -> bool,

Creates deep copy of node with all children. This is relatively heavy operation! In case if any error happened it returns Handle::NONE. This method can be used to create exact copy of given node hierarchy. For example you can prepare rocket model: case of rocket will be mesh, and fire from nozzle will be particle system, and when you fire from rocket launcher you just need to create a copy of such “prefab”.

§Implementation notes

Returns tuple where first element is handle to copy of node, and second element - old-to-new hash map, which can be used to easily find copy of node by its original.

Filter allows to exclude some nodes from copied hierarchy. It must return false for odd nodes. Filtering applied only to descendant nodes.

Source

pub fn copy_single_node(&self, node_handle: Handle<Node>) -> Node

Creates copy of a node and breaks all connections with other nodes. Keep in mind that this method may give unexpected results when the node has connections with other nodes. For example if you’ll try to copy a skinned mesh, its copy won’t be skinned anymore - you’ll get just a “shallow” mesh. Also unlike copy_node this method returns copied node directly, it does not inserts it in any graph.

Source

pub fn set_lightmap( &mut self, lightmap: Lightmap, ) -> Result<Option<Lightmap>, &'static str>

Tries to set new lightmap to scene.

Source

pub fn lightmap(&self) -> Option<&Lightmap>

Returns current lightmap.

Source

pub fn aabb_of_descendants<F>( &self, root: Handle<Node>, filter: F, ) -> Option<AxisAlignedBoundingBox>
where F: FnMut(Handle<Node>, &Node) -> bool,

Tries to compute combined axis-aligned bounding box (AABB) in world-space of the hierarchy starting from the given scene node. It will return None if the scene node handle is invalid, otherwise it will return AABB that enclosing all the nodes in the hierarchy.

Source

pub fn update_hierarchical_data_for_descendants( &mut self, node_handle: Handle<Node>, )

Calculates local and global transform, global visibility for each node in graph starting from the specified node and down the tree. The main use case of the method is to update global position (etc.) of an hierarchy of the nodes of some new prefab instance.

§Important Notes

This method could be slow for large hierarchies. You should call it only when absolutely needed.

Source

pub fn update_hierarchical_data(&mut self)

Calculates local and global transform, global visibility for each node in graph starting from the specified node and down the tree. The main use case of the method is to update global position (etc.) of an hierarchy of the nodes of some new prefab instance.

§Important Notes

This method could be slow for large graph. You should call it only when absolutely needed.

Source

pub fn update( &mut self, frame_size: Vector2<f32>, dt: f32, switches: GraphUpdateSwitches, )

Updates nodes in the graph using given delta time.

§Update Switches

Update switches allows you to disable update for parts of the update pipeline, it could be useful for editors where you need to have preview mode to update only specific set of nodes, etc.

Source

pub fn capacity(&self) -> u32

Returns capacity of internal pool. Can be used to iterate over all potentially available indices and try to convert them to handles.

let mut graph = Graph::new();
graph.add_node(Node::new(Pivot::default()));
graph.add_node(Node::new(Pivot::default()));
for i in 0..graph.capacity() {
    let handle = graph.handle_from_index(i);
    if handle.is_some() {
        let node = &mut graph[handle];
        // Do something with node.
    }
}
Source

pub fn handle_from_index(&self, index: u32) -> Handle<Node>

Makes new handle from given index. Handle will be none if index was either out-of-bounds or point to a vacant pool entry.

let mut graph = Graph::new();
graph.add_node(Node::new(Pivot::default()));
graph.add_node(Node::new(Pivot::default()));
for i in 0..graph.capacity() {
    let handle = graph.handle_from_index(i);
    if handle.is_some() {
        let node = &mut graph[handle];
        // Do something with node.
    }
}
Source

pub fn generate_free_handles(&self, amount: usize) -> Vec<Handle<Node>>

Generates a set of handles that could be used to spawn a set of nodes.

Source

pub fn linear_iter(&self) -> impl Iterator<Item = &Node>

Creates an iterator that has linear iteration order over internal collection of nodes. It does not perform any tree traversal!

Source

pub fn pair_iter_mut( &mut self, ) -> impl Iterator<Item = (Handle<Node>, &mut Node)>

Creates new iterator that iterates over internal collection giving (handle; node) pairs.

Source

pub fn take_reserve(&mut self, handle: Handle<Node>) -> (Ticket<Node>, Node)

Extracts node from graph and reserves its handle. It is used to temporarily take ownership over node, and then put node back using given ticket. Extracted node is detached from its parent!

Source

pub fn put_back(&mut self, ticket: Ticket<Node>, node: Node) -> Handle<Node>

Puts node back by given ticket. Attaches back to root node of graph.

Source

pub fn forget_ticket(&mut self, ticket: Ticket<Node>, node: Node) -> Node

Makes node handle vacant again.

Source

pub fn take_reserve_sub_graph(&mut self, root: Handle<Node>) -> SubGraph

Extracts sub-graph starting from a given node. All handles to extracted nodes becomes reserved and will be marked as “occupied”, an attempt to borrow a node at such handle will result in panic!. Please note that root node will be detached from its parent!

Source

pub fn put_sub_graph_back(&mut self, sub_graph: SubGraph) -> Handle<Node>

Puts previously extracted sub-graph into graph. Handles to nodes will become valid again. After that you probably want to re-link returned handle with its previous parent.

Source

pub fn forget_sub_graph(&mut self, sub_graph: SubGraph)

Forgets the entire sub-graph making handles to nodes invalid.

Source

pub fn node_count(&self) -> u32

Returns the number of nodes in the graph.

Source

pub fn clone<F, Pre, Post>( &self, root: Handle<Node>, filter: &mut F, pre_process_callback: &mut Pre, post_process_callback: &mut Post, ) -> (Self, NodeHandleMap<Node>)
where F: FnMut(Handle<Node>, &Node) -> bool, Pre: FnMut(Handle<Node>, &mut Node), Post: FnMut(Handle<Node>, Handle<Node>, &mut Node),

Creates deep copy of graph. Allows filtering while copying, returns copy and old-to-new node mapping.

Source

pub fn local_transform_no_scale(&self, node: Handle<Node>) -> Matrix4<f32>

Returns local transformation matrix of a node without scale.

Source

pub fn global_transform_no_scale(&self, node: Handle<Node>) -> Matrix4<f32>

Returns world transformation matrix of a node without scale.

Source

pub fn isometric_local_transform(&self, node: Handle<Node>) -> Matrix4<f32>

Returns isometric local transformation matrix of a node. Such transform has only translation and rotation.

Source

pub fn isometric_global_transform(&self, node: Handle<Node>) -> Matrix4<f32>

Returns world transformation matrix of a node only. Such transform has only translation and rotation.

Source

pub fn global_scale_matrix(&self, node: Handle<Node>) -> Matrix4<f32>

Returns global scale matrix of a node.

Source

pub fn global_rotation(&self, node: Handle<Node>) -> UnitQuaternion<f32>

Returns rotation quaternion of a node in world coordinates.

Source

pub fn isometric_global_rotation( &self, node: Handle<Node>, ) -> UnitQuaternion<f32>

Returns rotation quaternion of a node in world coordinates without pre- and post-rotations.

Source

pub fn global_rotation_position_no_scale( &self, node: Handle<Node>, ) -> (UnitQuaternion<f32>, Vector3<f32>)

Returns rotation quaternion and position of a node in world coordinates, scale is eliminated.

Source

pub fn isometric_global_rotation_position( &self, node: Handle<Node>, ) -> (UnitQuaternion<f32>, Vector3<f32>)

Returns isometric global rotation and position.

Source

pub fn global_scale(&self, node: Handle<Node>) -> Vector3<f32>

Returns global scale of a node.

Source

pub fn try_get_script_of<T>(&self, node: Handle<Node>) -> Option<&T>
where T: ScriptTrait,

Tries to borrow a node using the given handle and searches the script buffer for a script of type T and cast the first script, that could be found to the specified type.

Source

pub fn try_get_scripts_of<T: ScriptTrait>( &self, node: Handle<Node>, ) -> Option<impl Iterator<Item = &T>>

Tries to borrow a node and query all scripts of the given type T. This method returns None if the given node handle is invalid, otherwise it returns an iterator over the scripts of the type T.

Source

pub fn try_get_script_of_mut<T>(&mut self, node: Handle<Node>) -> Option<&mut T>
where T: ScriptTrait,

Tries to borrow a node using the given handle and searches the script buffer for a script of type T and cast the first script, that could be found to the specified type.

Source

pub fn try_get_scripts_of_mut<T: ScriptTrait>( &mut self, node: Handle<Node>, ) -> Option<impl Iterator<Item = &mut T>>

Tries to borrow a node and query all scripts of the given type T. This method returns None if the given node handle is invalid, otherwise it returns an iterator over the scripts of the type T.

Source

pub fn try_get_script_component_of<C>(&self, node: Handle<Node>) -> Option<&C>
where C: Any,

Tries to borrow a node and find a component of the given type C across all available scripts of the node. If you want to search a component C in a particular script, then use Self::try_get_script_of and then search for component in it.

Source

pub fn try_get_script_component_of_mut<C>( &mut self, node: Handle<Node>, ) -> Option<&mut C>
where C: Any,

Tries to borrow a node and find a component of the given type C across all available scripts of the node. If you want to search a component C in a particular script, then use Self::try_get_script_of_mut and then search for component in it.

Source

pub fn id_to_node_handle(&self, id: SceneNodeId) -> Option<&Handle<Node>>

Returns a handle of the node that has the given id.

Source

pub fn node_by_id(&self, id: SceneNodeId) -> Option<(Handle<Node>, &Node)>

Tries to borrow a node by its id.

Source

pub fn node_by_id_mut( &mut self, id: SceneNodeId, ) -> Option<(Handle<Node>, &mut Node)>

Tries to borrow a node by its id.

Trait Implementations§

Source§

impl AbstractSceneGraph for Graph

Source§

impl BaseSceneGraph for Graph

Source§

type Prefab = Model

Source§

type Node = Node

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 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.
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 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: Read more
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.
Source§

impl ConstructorProvider<Node, Graph> for AnimationBlendingStateMachine

Source§

impl ConstructorProvider<Node, Graph> for AnimationPlayer

Source§

impl ConstructorProvider<Node, Graph> for Camera

Source§

impl ConstructorProvider<Node, Graph> for Collider

Source§

impl ConstructorProvider<Node, Graph> for Collider

Source§

impl ConstructorProvider<Node, Graph> for Decal

Source§

impl ConstructorProvider<Node, Graph> for DirectionalLight

Source§

impl ConstructorProvider<Node, Graph> for Joint

Source§

impl ConstructorProvider<Node, Graph> for Joint

Source§

impl ConstructorProvider<Node, Graph> for Listener

Source§

impl ConstructorProvider<Node, Graph> for Mesh

Source§

impl ConstructorProvider<Node, Graph> for NavigationalMesh

Source§

impl ConstructorProvider<Node, Graph> for ParticleSystem

Source§

impl ConstructorProvider<Node, Graph> for Pivot

Source§

impl ConstructorProvider<Node, Graph> for PointLight

Source§

impl ConstructorProvider<Node, Graph> for Ragdoll

Source§

impl ConstructorProvider<Node, Graph> for Rectangle

Source§

impl ConstructorProvider<Node, Graph> for RigidBody

Source§

impl ConstructorProvider<Node, Graph> for RigidBody

Source§

impl ConstructorProvider<Node, Graph> for Sound

Source§

impl ConstructorProvider<Node, Graph> for SpotLight

Source§

impl ConstructorProvider<Node, Graph> for Sprite

Source§

impl ConstructorProvider<Node, Graph> for Terrain

Source§

impl ConstructorProvider<Node, Graph> for TileMap

Source§

impl Debug for Graph

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Graph

Source§

fn default() -> Self

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

impl Index<Handle<Node>> for Graph

Source§

type Output = Node

The returned type after indexing.
Source§

fn index(&self, index: Handle<Node>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<T> Index<Handle<T>> for Graph
where T: NodeTrait,

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, typed_handle: Handle<T>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl IndexMut<Handle<Node>> for Graph

Source§

fn index_mut(&mut self, index: Handle<Node>) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<T> IndexMut<Handle<T>> for Graph
where T: NodeTrait,

Source§

fn index_mut(&mut self, typed_handle: Handle<T>) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl Reflect for Graph

Source§

fn source_path() -> &'static str

Source§

fn type_name(&self) -> &'static str

Source§

fn doc(&self) -> &'static str

Source§

fn assembly_name(&self) -> &'static str

Returns a parent assembly name of the type that implements this trait. WARNING: You should use proc-macro (#[derive(Reflect)]) to ensure that this method will return correct assembly name. In other words - there’s no guarantee, that any implementation other than proc-macro will return a correct name of the assembly. Alternatively, you can use env!("CARGO_PKG_NAME") as an implementation.
Source§

fn type_assembly_name() -> &'static str

Returns a parent assembly name of the type that implements this trait. WARNING: You should use proc-macro (#[derive(Reflect)]) to ensure that this method will return correct assembly name. In other words - there’s no guarantee, that any implementation other than proc-macro will return a correct name of the assembly. Alternatively, you can use env!("CARGO_PKG_NAME") as an implementation.
Source§

fn fields_info(&self, func: &mut dyn FnMut(&[FieldInfo<'_, '_>]))

Source§

fn into_any(self: Box<Self>) -> Box<dyn Any>

Source§

fn set( &mut self, value: Box<dyn Reflect>, ) -> Result<Box<dyn Reflect>, Box<dyn Reflect>>

Source§

fn as_any(&self, func: &mut dyn FnMut(&dyn Any))

Source§

fn as_any_mut(&mut self, func: &mut dyn FnMut(&mut dyn Any))

Source§

fn as_reflect(&self, func: &mut dyn FnMut(&dyn Reflect))

Source§

fn as_reflect_mut(&mut self, func: &mut dyn FnMut(&mut dyn Reflect))

Source§

fn fields(&self, func: &mut dyn FnMut(&[&dyn Reflect]))

Source§

fn fields_mut(&mut self, func: &mut dyn FnMut(&mut [&mut dyn Reflect]))

Source§

fn field(&self, name: &str, func: &mut dyn FnMut(Option<&dyn Reflect>))

Source§

fn field_mut( &mut self, name: &str, func: &mut dyn FnMut(Option<&mut dyn Reflect>), )

Source§

fn set_field( &mut self, field: &str, value: Box<dyn Reflect>, func: &mut dyn FnMut(Result<Box<dyn Reflect>, Box<dyn Reflect>>), )

Calls user method specified with #[reflect(setter = ..)] or falls back to Reflect::field_mut
Source§

fn as_array(&self, func: &mut dyn FnMut(Option<&(dyn ReflectArray + 'static)>))

Source§

fn as_array_mut( &mut self, func: &mut dyn FnMut(Option<&mut (dyn ReflectArray + 'static)>), )

Source§

fn as_list(&self, func: &mut dyn FnMut(Option<&(dyn ReflectList + 'static)>))

Source§

fn as_list_mut( &mut self, func: &mut dyn FnMut(Option<&mut (dyn ReflectList + 'static)>), )

Source§

fn as_inheritable_variable( &self, func: &mut dyn FnMut(Option<&(dyn ReflectInheritableVariable + 'static)>), )

Source§

fn as_inheritable_variable_mut( &mut self, func: &mut dyn FnMut(Option<&mut (dyn ReflectInheritableVariable + 'static)>), )

Source§

fn as_hash_map( &self, func: &mut dyn FnMut(Option<&(dyn ReflectHashMap + 'static)>), )

Source§

fn as_hash_map_mut( &mut self, func: &mut dyn FnMut(Option<&mut (dyn ReflectHashMap + 'static)>), )

Source§

impl SceneGraph for Graph

Source§

fn pair_iter(&self) -> impl Iterator<Item = (Handle<Self::Node>, &Self::Node)>

Creates new iterator that iterates over internal collection giving (handle; node) pairs.
Source§

fn linear_iter(&self) -> impl Iterator<Item = &Self::Node>

Creates an iterator that has linear iteration order over internal collection of nodes. It does not perform any tree traversal!
Source§

fn linear_iter_mut(&mut self) -> impl Iterator<Item = &mut Self::Node>

Creates an iterator that has linear iteration order over internal collection of nodes. It does not perform any tree traversal!
Source§

fn try_get_of_type<T>(&self, handle: Handle<Self::Node>) -> Option<&T>
where T: 'static,

Tries to borrow a node and fetch its component of specified type.
Source§

fn try_get_mut_of_type<T>( &mut self, handle: Handle<Self::Node>, ) -> Option<&mut T>
where T: 'static,

Tries to mutably borrow a node and fetch its component of specified type.
Source§

fn has_component<T>(&self, handle: Handle<Self::Node>) -> bool
where T: 'static,

Tries to borrow a node by the given handle and checks if it has a component of the specified type.
Source§

fn find_map<C, T>( &self, root_node: Handle<Self::Node>, cmp: &mut C, ) -> Option<(Handle<Self::Node>, &T)>
where C: FnMut(&Self::Node) -> Option<&T>, T: ?Sized,

Searches for a node down the tree starting from the specified node using the specified closure. Returns a tuple with a handle and a reference to the mapped value. If nothing is found, it returns None.
Source§

fn find_up<C>( &self, root_node: Handle<Self::Node>, cmp: &mut C, ) -> Option<(Handle<Self::Node>, &Self::Node)>
where C: FnMut(&Self::Node) -> bool,

Searches for a node up the tree starting from the specified node using the specified closure. Returns a tuple with a handle and a reference to the found node. If nothing is found, it returns None.
Source§

fn find_handle_up<C>( &self, root_node: Handle<Self::Node>, cmp: &mut C, ) -> Handle<Self::Node>
where C: FnMut(&Self::Node) -> bool,

The same as Self::find_up, but only returns node handle which will be Handle::NONE if nothing is found.
Source§

fn find_component_up<T>( &self, node_handle: Handle<Self::Node>, ) -> Option<(Handle<Self::Node>, &T)>
where T: 'static,

Source§

fn find_component<T>( &self, node_handle: Handle<Self::Node>, ) -> Option<(Handle<Self::Node>, &T)>
where T: 'static,

Source§

fn find_up_map<C, T>( &self, root_node: Handle<Self::Node>, cmp: &mut C, ) -> Option<(Handle<Self::Node>, &T)>
where C: FnMut(&Self::Node) -> Option<&T>, T: ?Sized,

Searches for a node up the tree starting from the specified node using the specified closure. Returns a tuple with a handle and a reference to the mapped value. If nothing is found, it returns None.
Source§

fn find_by_name( &self, root_node: Handle<Self::Node>, name: &str, ) -> Option<(Handle<Self::Node>, &Self::Node)>

Searches for a node with the specified name down the tree starting from the specified node. Returns a tuple with a handle and a reference to the found node. If nothing is found, it returns None.
Source§

fn find_up_by_name( &self, root_node: Handle<Self::Node>, name: &str, ) -> Option<(Handle<Self::Node>, &Self::Node)>

Searches for a node with the specified name up the tree starting from the specified node. Returns a tuple with a handle and a reference to the found node. If nothing is found, it returns None.
Source§

fn find_by_name_from_root( &self, name: &str, ) -> Option<(Handle<Self::Node>, &Self::Node)>

Searches for a node with the specified name down the tree starting from the graph root. Returns a tuple with a handle and a reference to the found node. If nothing is found, it returns None.
Source§

fn find_handle_by_name_from_root(&self, name: &str) -> Handle<Self::Node>

Source§

fn find_from_root<C>( &self, cmp: &mut C, ) -> Option<(Handle<Self::Node>, &Self::Node)>
where C: FnMut(&Self::Node) -> bool,

Searches node using specified compare closure starting from root. Returns a tuple with a handle and a reference to the found node. If nothing is found, it returns None.
Source§

fn find<C>( &self, root_node: Handle<Self::Node>, cmp: &mut C, ) -> Option<(Handle<Self::Node>, &Self::Node)>
where C: FnMut(&Self::Node) -> bool,

Searches for a node down the tree starting from the specified node using the specified closure. Returns a tuple with a handle and a reference to the found node. If nothing is found, it returns None.
Source§

fn find_handle<C>( &self, root_node: Handle<Self::Node>, cmp: &mut C, ) -> Handle<Self::Node>
where C: FnMut(&Self::Node) -> bool,

The same as Self::find, but only returns node handle which will be Handle::NONE if nothing is found.
Source§

fn relative_position( &self, child: Handle<Self::Node>, offset: isize, ) -> Option<(Handle<Self::Node>, usize)>

Returns position of the node in its parent children list and the handle to the parent. Adds given offset to the position. For example, if you have the following hierarchy: Read more
Source§

fn traverse_iter( &self, from: Handle<Self::Node>, ) -> impl Iterator<Item = (Handle<Self::Node>, &Self::Node)>

Create a graph depth traversal iterator.
Source§

fn traverse_handle_iter( &self, from: Handle<Self::Node>, ) -> impl Iterator<Item = Handle<Self::Node>>

Create a graph depth traversal iterator.
Source§

fn restore_integrity<F>( &mut self, instantiate: F, ) -> Vec<(Handle<Self::Node>, Resource<Self::Prefab>)>
where F: FnMut(Resource<Self::Prefab>, &Self::Prefab, Handle<Self::Node>, &mut Self) -> (Handle<Self::Node>, NodeHandleMap<Self::Node>),

This method checks integrity of the graph and restores it if needed. For example, if a node was added in a parent asset, then it must be added in the graph. Alternatively, if a node was deleted in a parent asset, then its instance must be deleted in the graph.
Source§

fn restore_original_handles_and_inherit_properties<F>( &mut self, ignored_types: &[TypeId], before_inherit: F, )
where F: FnMut(&Self::Node, &mut Self::Node),

Source§

fn remap_handles( &mut self, instances: &[(Handle<Self::Node>, Resource<Self::Prefab>)], )

Maps handles in properties of instances after property inheritance. It is needed, because when a property contains node handle, the handle cannot be used directly after inheritance. Instead, it must be mapped to respective instance first. Read more
Source§

impl Visit for Graph

Source§

fn visit(&mut self, name: &str, visitor: &mut Visitor) -> VisitResult

Read or write this value, depending on whether Visitor::is_reading() is true or false. Read more

Auto Trait Implementations§

§

impl !Freeze for Graph

§

impl !RefUnwindSafe for Graph

§

impl Send for Graph

§

impl !Sync for Graph

§

impl Unpin for Graph

§

impl !UnwindSafe for Graph

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> AsyncTaskResult for T
where T: Any + Send + 'static,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts self reference as a reference to Any. Could be used to downcast a trait object to a particular type.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts self reference as a reference to Any. Could be used to downcast a trait object to a particular type.
Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Source§

impl<T> FieldValue for T
where T: 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Casts self to a &dyn Any
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<R> GetField for R
where R: Reflect,

Source§

fn get_field<T>(&self, name: &str, func: &mut dyn FnMut(Option<&T>))
where T: 'static,

Source§

fn get_field_mut<T>(&mut self, name: &str, func: &mut dyn FnMut(Option<&mut T>))
where T: 'static,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> ReflectBase for T
where T: Reflect,

Source§

fn as_any_raw(&self) -> &(dyn Any + 'static)

Source§

fn as_any_raw_mut(&mut self) -> &mut (dyn Any + 'static)

Source§

impl<T> ResolvePath for T
where T: Reflect,

Source§

fn resolve_path<'p>( &self, path: &'p str, func: &mut dyn FnMut(Result<&(dyn Reflect + 'static), ReflectPathError<'p>>), )

Source§

fn resolve_path_mut<'p>( &mut self, path: &'p str, func: &mut dyn FnMut(Result<&mut (dyn Reflect + 'static), ReflectPathError<'p>>), )

Source§

fn get_resolve_path<'p, T>( &self, path: &'p str, func: &mut dyn FnMut(Result<&T, ReflectPathError<'p>>), )
where T: Reflect,

Source§

fn get_resolve_path_mut<'p, T>( &mut self, path: &'p str, func: &mut dyn FnMut(Result<&mut T, ReflectPathError<'p>>), )
where T: Reflect,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ScriptMessagePayload for T
where T: 'static + Send + Debug,

Source§

fn as_any_ref(&self) -> &(dyn Any + 'static)

Returns self as &dyn Any
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Returns self as &dyn Any
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more