From 5321e1036deed6a87440c8fd84270a97967e6710 Mon Sep 17 00:00:00 2001 From: Eddie James Date: Sat, 4 Aug 2018 16:36:04 -0500 Subject: [PATCH] Fix .obj displacement texture parsing The string for an opacity texture is a substring of the displacement texture string. Due to the nature of the string comparison in the material texture parsing, any displacement textures will be incorrectly assigned as opacity textures. Fix this by simply performing the check for displacement texture before checking for opacity texture. --- code/ObjFileMtlImporter.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/code/ObjFileMtlImporter.cpp b/code/ObjFileMtlImporter.cpp index 711740353..16bde1b43 100644 --- a/code/ObjFileMtlImporter.cpp +++ b/code/ObjFileMtlImporter.cpp @@ -332,6 +332,11 @@ void ObjFileMtlImporter::getTexture() { // Specular texture out = & m_pModel->m_pCurrentMaterial->textureSpecular; clampIndex = ObjFile::Material::TextureSpecularType; + } else if ( !ASSIMP_strincmp( pPtr, DisplacementTexture1.c_str(), static_cast(DisplacementTexture1.size()) ) || + !ASSIMP_strincmp( pPtr, DisplacementTexture2.c_str(), static_cast(DisplacementTexture2.size()) ) ) { + // Displacement texture + out = &m_pModel->m_pCurrentMaterial->textureDisp; + clampIndex = ObjFile::Material::TextureDispType; } else if ( !ASSIMP_strincmp( pPtr, OpacityTexture.c_str(), static_cast(OpacityTexture.size()) ) ) { // Opacity texture out = & m_pModel->m_pCurrentMaterial->textureOpacity; @@ -354,11 +359,6 @@ void ObjFileMtlImporter::getTexture() { // Reflection texture(s) //Do nothing here return; - } else if ( !ASSIMP_strincmp( pPtr, DisplacementTexture1.c_str(), static_cast(DisplacementTexture1.size()) ) || - !ASSIMP_strincmp( pPtr, DisplacementTexture2.c_str(), static_cast(DisplacementTexture2.size()) ) ) { - // Displacement texture - out = &m_pModel->m_pCurrentMaterial->textureDisp; - clampIndex = ObjFile::Material::TextureDispType; } else if ( !ASSIMP_strincmp( pPtr, SpecularityTexture.c_str(), static_cast(SpecularityTexture.size()) ) ) { // Specularity scaling (glossiness) out = & m_pModel->m_pCurrentMaterial->textureSpecularity;