Thanks to visit codestin.com
Credit goes to github.com

Skip to content

MTL file in same directory cannot be loaded #177

@mlimper

Description

@mlimper

Hi @silverweed, Hi @syoyo !

I just updated tinyobj for my application, and there seems to be a problem:

On Windows, if the .mtl file is in the same directory and simply referenced as, say "myMTLFile.mtl" from within the OBJ, the current version fails to load it. There was a recent change via a PR: #176

I suppose this is what broke it for this particular case - for the example mentioned above I get a warning from tinyOBI saying "WARN: Material file [ \myMTLFile.mtl ] not found.". I am not sure what would be the correct way to fix this (without breaking what @silverweed fixed in #176, for example). For now I added a workaround changing the following (line 1747)

if (baseDir[baseDir.length() - 1] != dirsep)
      baseDir += dirsep;

to

if (!baseDir.empty() && baseDir[baseDir.length() - 1] != dirsep)
      baseDir += dirsep;

This worked for me, but, again, not sure if this is a good final fix.

Thanks & keep up the great work!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions