ofxAssimpModelLoader Loading Bug

Just a really weird (and annoying bug) I thought I’d send out to the community.

I have an FBX model with animations I’m loading with ofxAssimpModelLoader and while it normally works just fine, the model is unable to load depending on how images are loaded before it.

If the model is loaded BEFORE filling my vector of images it works fine. However, if I load images with the following code AssImp throws an error.

Loading code:

ofDirectory dir;

dir.listDir("images/wallpapers/");
dir.sort();

if( dir.size() ){
    images.assign(dir.size(), ofImage());
}

for(int i = 0; i < (int)dir.size(); i++){
    images[i].load(dir.getPath(i));
}

Model Loading Error:
[ error ] ofxAssimpModelLoader: loadModel(): FBX-Parser (TOK_DATA, line 19661, col 9) unexpected token, expected TOK_KEY

However, if I load my images with the following code instead, both the images and the model load fine:

for(int i = 0; i < numImages; i++){
    string filename = "images/wallpapers/" + ofToString(i) + ".jpg";
    
    ofImage img;
    img.load(filename);
    
    images.push_back(img);
}

After trying a few combinations, I realized anything that loads the vector using assign() or resize() instead of push_back() causes the error also. Maybe this is an issue with the way OF or ofxAssimpModelLoader handles files/filesystem access. The error above references “line 19661, col 9” (which is the last line of the FBX ASCII file) and an expected token which means assimp thinks the file has whitespace characters at the end where there should be none.

Worked around the bug but figured the world should know.