From 058be9323dd245f589126a2c17a13b7501850209 Mon Sep 17 00:00:00 2001 From: Gellule Xg Date: Tue, 6 Dec 2011 20:14:01 -1000 Subject: [PATCH] Removed LWOImporter::AddChildren and LWOImporter::GenerateNodeGraph --- code/LWOLoader.cpp | 92 ---------------------------------------------- 1 file changed, 92 deletions(-) diff --git a/code/LWOLoader.cpp b/code/LWOLoader.cpp index d2f295b0c..af6187d46 100644 --- a/code/LWOLoader.cpp +++ b/code/LWOLoader.cpp @@ -528,98 +528,6 @@ void LWOImporter::ComputeNormals(aiMesh* mesh, const std::vector& } } -// ------------------------------------------------------------------------------------------------ -void LWOImporter::AddChildren(aiNode* node, uint16_t parent, std::vector& apcNodes) -{ - for (std::vector::iterator it = apcNodes.begin(); it != apcNodes.end(); ++it) { - if (*it) { - LWO::Layer* layer = (LWO::Layer*)(*it)->mParent; - if (layer->mParent == parent && layer->mIndex != parent) - ++node->mNumChildren; - } - } - - if (node->mNumChildren) { - unsigned int p = 0; - - node->mChildren = new aiNode* [ node->mNumChildren ]; - for (std::vector::iterator it = apcNodes.begin(); it != apcNodes.end(); ++it) { - if (*it) { - LWO::Layer* layer = (LWO::Layer*)(*it)->mParent; - if (layer->mParent == parent && layer->mIndex != parent) { - aiNode* nd = node->mChildren[p++] = *it; - nd->mParent = node; - - // fixme: ignore pivot points for the moment - //nd->mTransformation.a4 = layer->mPivot.x; - //nd->mTransformation.b4 = layer->mPivot.y; - //nd->mTransformation.c4 = layer->mPivot.z; - - // recursively add more children - (*it) = NULL; - AddChildren(nd,layer->mIndex,apcNodes); - } - } - } - } -} - -// ------------------------------------------------------------------------------------------------ -void LWOImporter::GenerateNodeGraph(std::vector& apcNodes) -{ - // now generate the final nodegraph - generate a root node and attach children - aiNode* root = pScene->mRootNode = new aiNode(); - root->mName.Set(""); - AddChildren(root,0,apcNodes); - - // check whether we added all layers with meshes assigned to the output graph. - // if not, add them to the root node - unsigned int extra = 0; - for (std::vector::iterator it = apcNodes.begin(); it != apcNodes.end(); ++it) { - if ((*it) && (*it)->mNumMeshes) - ++extra; - } - - if (extra) { - const unsigned int newSize = extra + pScene->mRootNode->mNumChildren; - aiNode** const apcNewNodes = new aiNode*[newSize]; - if((extra = root->mNumChildren)) - ::memcpy(apcNewNodes,root->mChildren,extra*sizeof(void*)); - - aiNode** cc = apcNewNodes+extra; - for (std::vector::iterator it = apcNodes.begin(); it != apcNodes.end(); ++it) { - if ((*it) && (*it)->mNumMeshes) { - aiNode* nd = *cc++ = *it; - nd->mParent = pScene->mRootNode; - - // recursively add more children - (*it) = NULL; - AddChildren(nd,((LWO::Layer*)nd->mParent)->mIndex,apcNodes); - } - } - delete[] root->mChildren; - root->mChildren = apcNewNodes; - root->mNumChildren = newSize; - } - if (!pScene->mRootNode->mNumChildren) - throw DeadlyImportError("LWO: Unable to build a valid node graph"); - - // Remove a single root node with no meshes assigned to it ... - if (1 == pScene->mRootNode->mNumChildren) { - aiNode* pc = pScene->mRootNode->mChildren[0]; - pc->mParent = pScene->mRootNode->mChildren[0] = NULL; - delete pScene->mRootNode; - pScene->mRootNode = pc; - } - - // convert the whole stuff to RH with CCW winding - MakeLeftHandedProcess maker; - maker.Execute(pScene); - - FlipWindingOrderProcess flipper; - flipper.Execute(pScene); -} - // ------------------------------------------------------------------------------------------------ void LWOImporter::ResolveTags() {