diff --git a/changes.txt b/changes.txt index e9aeb8a5..6087eb4e 100644 --- a/changes.txt +++ b/changes.txt @@ -1,6 +1,7 @@ -------------------------- Changes in 1.9 (not yet released) +- obj/mtl loader no longer messes up bump textures when the name starts with a number - CImageLoaderBMP now supports loading 1-bit images with palette data - Hardware meshbuffers are now deleted when they hold the last reference to a meshbuffer - Variable order inside SMaterial and SMaterialLayer changed for better packing diff --git a/source/Irrlicht/COBJMeshFileLoader.cpp b/source/Irrlicht/COBJMeshFileLoader.cpp index b7de81bd..ed1aaf48 100644 --- a/source/Irrlicht/COBJMeshFileLoader.cpp +++ b/source/Irrlicht/COBJMeshFileLoader.cpp @@ -387,9 +387,9 @@ const c8* COBJMeshFileLoader::readTextures(const c8* bufPtr, const c8* const buf // map_Ks - specular color texture map // map_Ka - ambient color texture map // map_Ns - shininess texture map - if ((!strncmp(bufPtr,"map_bump",8)) || (!strncmp(bufPtr,"bump",4))) + if (!strncmp(bufPtr,"map_bump",8) || !strncmp(bufPtr,"map_Bump",8) || !strncmp(bufPtr,"bump",4)) type=1; // normal map - else if ((!strncmp(bufPtr,"map_d",5)) || (!strncmp(bufPtr,"map_opacity",11))) + else if (!strncmp(bufPtr,"map_d",5) || !strncmp(bufPtr,"map_opacity",11)) type=2; // opacity map else if (!strncmp(bufPtr,"map_refl",8)) type=3; // reflection map @@ -487,8 +487,15 @@ const c8* COBJMeshFileLoader::readTextures(const c8* bufPtr, const c8* const buf if ((type==1) && (core::isdigit(textureNameBuf[0]))) { - currMaterial->Meshbuffer->Material.MaterialTypeParam=core::fast_atof(textureNameBuf); - bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, bufEnd); + // Haven't found that in any official mtl description, usually bump parameter should only be after -bm + // But I'll leave it (with added checks in 1.9) as maybe there are some exporters doing this and likely can't be a valid filename + const char *out=0; + irr::f32 bumpScale = core::fast_atof(textureNameBuf, &out); + if ( *out == 0 ) // name is only a number + { + currMaterial->Meshbuffer->Material.MaterialTypeParam=bumpScale; + bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, bufEnd); + } } if (clamp) currMaterial->Meshbuffer->Material.setFlag(video::EMF_TEXTURE_WRAP, video::ETC_CLAMP); diff --git a/tests/tests-last-passed-at.txt b/tests/tests-last-passed-at.txt index 1697fe69..57a930f3 100644 --- a/tests/tests-last-passed-at.txt +++ b/tests/tests-last-passed-at.txt @@ -1,4 +1,4 @@ Tests finished. 72 tests of 72 passed. Compiled as DEBUG -Test suite pass at GMT Thu Feb 29 13:39:39 2024 +Test suite pass at GMT Sat Mar 16 16:24:16 2024