Skip to content
This repository has been archived by the owner on Jun 6, 2018. It is now read-only.

Commit

Permalink
fix(instantiate_model): fix issue where whole model wasn't instantiated
Browse files Browse the repository at this point in the history
Previously, due to unresolved issues with other parts of the engine,
`Scene::instantiate_model()` would not create the full model hierarchy,
only its root mesh. Now the full mesh is created (mostly) correctly.
  • Loading branch information
randomPoison committed Dec 8, 2015
1 parent ee70262 commit 591db7b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/resource/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,11 @@ impl ResourceManager {
&visual_scene.node[0]
};

let mut uri = String::from(resource);
let uri = String::from(resource);
self.instantiate_node(scene, node, uri)
}

fn instantiate_node(&self, scene: &Scene, node: &Node, mut uri: String) -> Result<Entity, String> {
uri.push_str(".");
uri.push_str(node.id.as_ref().unwrap());

Expand All @@ -234,16 +238,22 @@ impl ResourceManager {

let entity = scene.create_entity();
{
// TODO: Apply the node's transform to the entity transform.
let mut transform_manager = scene.get_manager_mut::<TransformManager>();
transform_manager.assign(entity);
scene.get_manager_mut::<MeshManager>()
.give_mesh(entity, mesh_data);
}

// Instantiate each of the children and set the current node as their parent.
for node in &node.nodes {
let child = try!(self.instantiate_node(scene, node, uri.clone()));

let mut transform_manager = scene.get_manager_mut::<TransformManager>();
transform_manager.set_child(entity, child);
}

return Ok(entity);
Ok(entity)
}

pub fn get_shader<P: AsRef<Path> + ::std::fmt::Debug>(
Expand Down

0 comments on commit 591db7b

Please sign in to comment.