Merge pull request #2523 from muxanickms/topic/embedded_texture_name_fix

All textures use relative path except embedded textures, this is a fix for it
pull/2528/head
Kim Kulling 2019-06-30 20:30:17 +02:00 committed by GitHub
commit ff662a6104
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -1642,7 +1642,7 @@ namespace Assimp {
out_tex->pcData = reinterpret_cast<aiTexel*>(const_cast<Video&>(video).RelinquishContent()); out_tex->pcData = reinterpret_cast<aiTexel*>(const_cast<Video&>(video).RelinquishContent());
// try to extract a hint from the file extension // try to extract a hint from the file extension
const std::string& filename = video.FileName().empty() ? video.RelativeFilename() : video.FileName(); const std::string& filename = video.RelativeFilename().empty() ? video.FileName() : video.RelativeFilename();
std::string ext = BaseImporter::GetExtension(filename); std::string ext = BaseImporter::GetExtension(filename);
if (ext == "jpeg") { if (ext == "jpeg") {
@ -1653,7 +1653,7 @@ namespace Assimp {
memcpy(out_tex->achFormatHint, ext.c_str(), ext.size()); memcpy(out_tex->achFormatHint, ext.c_str(), ext.size());
} }
out_tex->mFilename.Set(video.FileName().c_str()); out_tex->mFilename.Set(filename.c_str());
return static_cast<unsigned int>(textures.size() - 1); return static_cast<unsigned int>(textures.size() - 1);
} }

View File

@ -241,6 +241,7 @@ TEST_F(utFBXImporterExporter, importEmbeddedAsciiTest) {
aiString path; aiString path;
aiTextureMapMode modes[2]; aiTextureMapMode modes[2];
EXPECT_EQ(aiReturn_SUCCESS, mat->GetTexture(aiTextureType_DIFFUSE, 0, &path, nullptr, nullptr, nullptr, nullptr, modes)); EXPECT_EQ(aiReturn_SUCCESS, mat->GetTexture(aiTextureType_DIFFUSE, 0, &path, nullptr, nullptr, nullptr, nullptr, modes));
ASSERT_STREQ(path.C_Str(), "..\\..\\..\\Desktop\\uv_test.png");
ASSERT_EQ(1, scene->mNumTextures); ASSERT_EQ(1, scene->mNumTextures);
ASSERT_TRUE(scene->mTextures[0]->pcData); ASSERT_TRUE(scene->mTextures[0]->pcData);