bility to partially update global properties of an hierachy of nodes
@@ -961,13 +961,7 @@ impl Graph {
Log::writeln(MessageKind::Information, "Graph resolved successfully!");
}
- /// Calculates local and global transform, global visibility for each node in graph.
- /// Normally you not need to call this method directly, it will be called automatically
- /// on each frame. However there is one use case - when you setup complex hierarchy and
- /// need to know global transform of nodes before entering update loop, then you can call
- /// this method.
- pub fn update_hierarchical_data(&mut self) {
- fn update_recursively(
+ pub(crate) fn update_hierarchical_data_recursively(
nodes: &NodePool,
sound_context: &mut SoundContext,
physics: &mut PhysicsWorld,
@@ -1006,11 +1000,36 @@ impl Graph {
node.global_enabled.set(parent_enabled && node.is_enabled());
for &child in node.children() {
- update_recursively(nodes, sound_context, physics, physics2d, child);
+ Self::update_hierarchical_data_recursively(
+ nodes,
+ sound_context,
+ physics,
+ physics2d,
+ child,
+ );
+ }
}
+
+ /// 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.
+ pub fn update_hierarchical_data_for_descendants(&mut self, node_handle: Handle<Node>) {
+ Self::update_hierarchical_data_recursively(
+ &self.pool,
+ &mut self.sound_context,
+ &mut self.physics,
+ &mut self.physics2d,
+ node_handle,
+ );
}
- update_recursively(
+ /// Calculates local and global transform, global visibility for each node in graph.
+ /// Normally you not need to call this method directly, it will be called automatically
+ /// on each frame. However there is one use case - when you setup complex hierarchy and
+ /// need to know global transform of nodes before entering update loop, then you can call
+ /// this method.
+ pub fn update_hierarchical_data(&mut self) {
+ Self::update_hierarchical_data_recursively(
&self.pool,
&mut self.sound_context,
&mut self.physics,
