From Melchoir Franz, "ac3d.cpp does currently strip everything but the file name in

"texture" paths. This is to drop absolute paths that some
3d editors export (even AC3D itself!). But this also strips
directories of relative paths, which is wrong and contradicts
the ac3d reference implementation. (The reference implementation
doesn't strip anything, though, and so takes the absolute paths
as they are. Definitely not what we want.)

The attached solution checks absolute paths and only strips
those:

 (1)  A:\\foo\\bar.png   ->   bar.png            (as before)
 (2)  /foo/bar.png       ->   bar.png            (as before)

 (3)  foo/bar.png        ->   foo/bar.png        (new)
 (4)  ../foo/bar.png     ->   ../foo/bar.png     (new)

"
This commit is contained in:
Robert Osfield 2008-03-13 16:18:03 +00:00
parent a460d66533
commit 110c761695

View File

@ -1121,13 +1121,15 @@ readObject(std::istream& stream, FileData& fileData, const osg::Matrix& parentTr
// read the texture name // read the texture name
std::string texname = readString(stream); std::string texname = readString(stream);
// strip the path to the texture, just look in the directory we read the ac file // strip absolute paths
if (texname[0] == '/' || isalpha(texname[0]) && texname[1] == ':') {
std::string::size_type p = texname.rfind('\\'); std::string::size_type p = texname.rfind('\\');
if (p != std::string::npos) if (p != std::string::npos)
texname = texname.substr(p+1, std::string::npos); texname = texname.substr(p+1, std::string::npos);
p = texname.rfind('/'); p = texname.rfind('/');
if (p != std::string::npos) if (p != std::string::npos)
texname = texname.substr(p+1, std::string::npos); texname = texname.substr(p+1, std::string::npos);
}
textureData = fileData.toTextureData(texname); textureData = fileData.toTextureData(texname);
} }