Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions crates/renderling/src/gltf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1236,14 +1236,21 @@ where
self.primitives.iter().flat_map(|(_, rs)| rs.iter())
}

fn nodes_in_scene_recursive<'a>(&'a self, node_index: usize, nodes: &mut Vec<&'a GltfNode>) {
if let Some(node) = self.nodes.get(node_index) {
nodes.push(node);
for child_index in node.children.iter() {
self.nodes_in_scene_recursive(*child_index, nodes);
}
}
}

pub fn nodes_in_scene(&self, scene_index: usize) -> impl Iterator<Item = &GltfNode> {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is lacking documentation, which is my fault. It should mention that this function roughly follows the gltf::Scene::nodes function.

I think what we need here is a new pub recursive_nodes_in_scene(&self, scene_index: usize) -> impl Iterator<Item = &GltfNode>, and maybe we should rename nodes_in_scene to root_nodes_in_scene.

let scene = self.scenes.get(scene_index);
let mut nodes = vec![];
if let Some(indices) = scene {
for node_index in indices {
if let Some(node) = self.nodes.get(*node_index) {
nodes.push(node);
}
self.nodes_in_scene_recursive(*node_index, &mut nodes);
}
}
nodes.into_iter()
Expand Down
Loading