Jump to content
  • Advertisement
Sign in to follow this  
jeffreyp23

Infinite loop with recursive loading

This topic is 2526 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys,

Today i tried to get assimp integrated in my game,
but when i try to load a model i get in an infinite loop(which will become a stack overflow).
I'm trying to get the example(Sample_SimpleOpenGL) working with DirectX11

Here is the function that is causing this :
[source]

void TAssimp::RecursiveLoad(const struct aiScene *sc, const struct aiNode* nd)
{
unsigned int n = 0;

for (; n < scene->mRootNode->mNumMeshes; ++n) {
mesh = scene->mMeshes[scene->mRootNode->mMeshes[n]];

for (DWORD t = 0; t < mesh->mNumFaces; ++t) {
face = &mesh->mFaces[t];

switch(face->mNumIndices) {
case 1: renderMethod = D3D11_PRIMITIVE_TOPOLOGY_POINTLIST; break;
case 2: renderMethod = D3D11_PRIMITIVE_TOPOLOGY_LINELIST; break;
case 3: renderMethod = D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST; break;
default: renderMethod = D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP; break;
}

for(DWORD i = 0; i < face->mNumIndices; i++) {
index[recursiveCount] = face->mIndices;

// if(mesh->mColors[0] != NULL)
// Color4f(&mesh->mColors[0][index]);

if(mesh->mNormals != NULL){
TANormal nTemp;
nTemp.x = mesh->mNormals[index[recursiveCount]].x;
nTemp.y = mesh->mNormals[index[recursiveCount]].y;
nTemp.z = mesh->mNormals[index[recursiveCount]].z;
normals.push_back(nTemp);
}

TAVertex vTemp;
vTemp.x = mesh->mVertices[index[recursiveCount]].x;
vTemp.y = mesh->mVertices[index[recursiveCount]].y;
vTemp.z = mesh->mVertices[index[recursiveCount]].z;
vertices.push_back(vTemp);
}

}

recursiveCount += 1;

}
for (n = 0; n < scene->mRootNode->mNumChildren; ++n) {
RecursiveLoad(sc, scene->mRootNode->mChildren[n]);
}

recursiveCount = 0;

}

[/source]

Thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
In each recursion you repeat on scene->mRootNode?
I think it's static so your recursion won't stop?
Maybe you need to repeat on the parameters,
const struct aiScene *sc and const struct aiNode* nd

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!