fix name lost in mesh and nodes when load with aiProcess_PreTransformVertices flag

pull/1424/head
Amit Cirt 2017-09-09 19:04:15 +03:00
parent dbde54b4f7
commit 2ec46cc188
1 changed files with 8 additions and 2 deletions

View File

@ -160,6 +160,11 @@ void PretransformVertices::CollectData( aiScene* pcScene, aiNode* pcNode, unsign
unsigned int& num_ref = num_refs[pcNode->mMeshes[i]];
ai_assert(0 != num_ref);
--num_ref;
// Save the name of the last mesh
if (num_ref==0)
{
pcMeshOut->mName = pcMesh->mName;
}
if (identity) {
// copy positions without modifying them
@ -626,9 +631,10 @@ void PretransformVertices::Execute( aiScene* pScene)
// now delete all nodes in the scene and build a new
// flat node graph with a root node and some level 1 children
aiNode* newRoot = new aiNode();
newRoot->mName = pScene->mRootNode->mName;
delete pScene->mRootNode;
pScene->mRootNode = new aiNode();
pScene->mRootNode->mName.Set("<dummy_root>");
if (1 == pScene->mNumMeshes && !pScene->mNumLights && !pScene->mNumCameras)
{
@ -646,7 +652,7 @@ void PretransformVertices::Execute( aiScene* pScene)
{
aiNode* pcNode = *nodes = new aiNode();
pcNode->mParent = pScene->mRootNode;
pcNode->mName.length = ::ai_snprintf(pcNode->mName.data,MAXLEN,"mesh_%u",i);
pcNode->mName = pScene->mMeshes[i]->mName;
// setup mesh indices
pcNode->mNumMeshes = 1;