Fixed recursive process node function to process root node and not ignore

This commit is contained in:
Xiao Qi 2023-01-07 21:33:08 +08:00
parent 6eca9b021f
commit e0392bd601
2 changed files with 19 additions and 13 deletions

View File

@ -40,21 +40,21 @@ namespace SH_COMP
void MeshCompiler::ProcessNode(AiNodeConstPtr node, aiScene const& scene, MeshVectorRef meshes, RigData& rig) noexcept
{
for (auto i{ 0 }; i < node->mNumChildren; ++i)
if (node->mNumMeshes > 0)
{
auto child{ node->mChildren[i] };
if (child->mNumMeshes > 0)
{
aiMesh* mesh = scene.mMeshes[child->mMeshes[0]];
aiMesh* mesh = scene.mMeshes[node->mMeshes[0]];
meshes.emplace_back();
GetMesh(*mesh, meshes.back());
meshes.back().name = child->mName.C_Str();
meshes.back().name = node->mName.C_Str();
}
else
{
BuildArmature(child, rig);
BuildArmature(node, rig);
}
for (auto i{ 0 }; i < node->mNumChildren; ++i)
{
ProcessNode(node->mChildren[i], scene, meshes, rig);
}
}

View File

@ -18,6 +18,8 @@ int main(int argc, char* argv[])
{
std::vector<std::string> paths;
#if 0
if (argc == 1)
{
if (std::filesystem::is_directory(ASSET_ROOT))
@ -47,13 +49,17 @@ int main(int argc, char* argv[])
paths.emplace_back(argv[i]);
}
}
#else
for (auto const& path : paths)
{
SH_COMP::MeshCompiler::LoadAndCompile(path);
}
#endif
//SH_COMP::MeshCompiler::LoadAndCompile("Raccoon.gltf");
SH_COMP::MeshCompiler::LoadAndCompile("MD_Homeowner-NoRig.gltf");
return 0;
}