• Advertisement
Sign in to follow this  

Infinite loop with recursive loading

This topic is 2352 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