-1

I've been having this problem for a while and I'm certain I've got something fundamentally wrong. Assimp is built from source from the most recent commit on github, but I have also tried on v5.0.0/1/2.

I can import an fbx file almost to completion in Assimp (converted so all meshes are made of triangles), but when accessing the face data from a mesh, the face is null (or points to invalid memory).

The entire code:

void recursive_explorer(aiNode *n, const aiScene *s) {
    if (n) {
        if (n->mNumChildren != 0) {
            for (unsigned i = 0; i < n->mNumChildren; i++) {
                recursive_explorer(n->mChildren[i], s);
            }
        } else {
            printf("%d\n", n->mNumMeshes);

            for (unsigned j = 0; j < n->mNumMeshes; j++) {
                const struct aiMesh *m = s->mMeshes[n->mMeshes[j]];
                printf("\t%d\n", m->mNumFaces);
                if (m->HasFaces()) {
                    for (unsigned k = 0; k < m->mNumFaces; k++) {
                        printf("\t\t%p\n", &m->mFaces[k]);
                    }
                }
            }
        }
    }
}

int main() {
    Assimp::Importer importer;
    std::fstream f("../maps/de_dust2.fbx");
    const aiScene *s = importer.ReadFile("../maps/de_dust2.fbx",
                                         aiProcess_SortByPType | aiProcess_JoinIdenticalVertices |
                                         aiProcess_Triangulate);

    printf("Root has %d children\n", s->mRootNode->mNumChildren);
    for (unsigned i = 0; i < s->mRootNode->mNumChildren; i++) {
        printf("[%u] %s\n", i, s->mRootNode->mChildren[i]->mName.C_Str());
        recursive_explorer(s->mRootNode->mChildren[i], s);
    }

    return 0;
}

Results in:

Root has 3 children
[0] CINEMA_4D_Editor
0
[1] Sky
0
0
0
0
0
[2] de_dust2
2
    4
        0x1b1b1b1b1b1b1b1b
        0x1b1b1b1b1b1b1b2b
        0x1b1b1b1b1b1b1b3b
        ...

If I try access a face (to get the mNumIndices or mIndices), I get a segfault.

I have experimented with different preprocessing options though I haven't yet found the right combination.

I know this CAN work as I have managed to get this specific map to work before, though I'm sure I've missed something very obvious. Thanks in advance!

beeves
  • 11
  • 3
  • 1
    Have you tried debugging (besides [printf debugging](https://stackoverflow.com/a/189570/949561)) your code? – blurryroots Jan 06 '22 at 17:21
  • My debugger tells me faces are invalid and throws a EXC_BAD_ACCESS error if I try access them, regardless of fbx or object file. – beeves Jan 06 '22 at 17:58
  • Sounds like an issue at loading time. Are the faces ever loaded / read correctly? – blurryroots Jan 06 '22 at 18:01
  • I'm not sure I understand, but the only time they are accessed is in that print statement. I don't think I have a way of knowing if they are ever loaded before that as that procedure that prints them is the explorer that finds them. – beeves Jan 06 '22 at 18:46
  • Yes you have a way. Start a debugging session and step through the loading process. Then inspect the model fields, to see if they are properly loaded / processed. – blurryroots Jan 06 '22 at 18:48
  • I was trying to avoid that given I have a very tight work deadline. I'll do a more in-depth debug when I have time and see if it warrants a PR. – beeves Jan 06 '22 at 19:07

1 Answers1

0

I have found that assimp build v5.1.0.rc1 works given my current environment:

  • MacOS Monterey 12.1
  • cmake V3.16
  • clang 13.0.0

Things I tested to try get v5.1.5 working:

  • A handful of different .fbx and .obj files
  • Most assimp importer preprocessor options
  • All (even slightly) relevant cmake build flags

Perhaps this is specifically a MacOS issue, though I've seen a few other posts online with similar problems that this will hopefully aid. Thank you for the help everyone.

beeves
  • 11
  • 3