Skip to content

Commit

Permalink
Fix: Works even the root node doesnt have child (#358)
Browse files Browse the repository at this point in the history
Signed-off by: Onur Berk Tore otore19@ku.edu.tr

Co-authored-by: Luca Della Vedova <luca@openrobotics.org>
  • Loading branch information
Onur Berk Töre and luca-della-vedova authored May 30, 2022
1 parent db823ca commit 1795314
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions graphics/src/AssimpLoader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ ignition::math::Matrix4d AssimpLoader::Implementation::ConvertTransform(const ai

void AssimpLoader::Implementation::RecursiveCreate(const aiScene* scene, const aiNode* node, const ignition::math::Matrix4d& transformation, Mesh* mesh)
{
if (!node)
return;

// Visit this node, add the submesh
ignmsg << "Processing node " << node->mName.C_Str() << " with " << node->mNumMeshes << " meshes" << std::endl;
for (unsigned mesh_idx = 0; mesh_idx < node->mNumMeshes; ++mesh_idx)
Expand Down Expand Up @@ -343,13 +346,11 @@ Mesh *AssimpLoader::Load(const std::string &_filename)
}
SkeletonPtr root_skeleton = std::make_shared<Skeleton>(root_skel_node);
mesh->SetSkeleton(root_skeleton);
for (unsigned child_idx = 0; child_idx < root_node->mNumChildren; ++child_idx)
{
// Now create the meshes
// Recursive call to keep track of transforms, mesh is passed by pointer and edited throughout
ignmsg << "Parsing root child " << root_node->mChildren[child_idx]->mName.C_Str() << std::endl;
this->dataPtr->RecursiveCreate(scene, root_node->mChildren[child_idx], root_transformation, mesh);
}

// Now create the meshes
// Recursive call to keep track of transforms, mesh is passed by reference and edited throughout
this->dataPtr->RecursiveCreate(scene, root_node, root_transformation, mesh);

// Add the animations
for (unsigned anim_idx = 0; anim_idx < scene->mNumAnimations; ++anim_idx)
{
Expand Down

0 comments on commit 1795314

Please sign in to comment.