From b1381ddd693995d4920a0e683b313ed46869bf6f Mon Sep 17 00:00:00 2001 From: Sergey Shambir Date: Mon, 25 Feb 2013 04:12:41 +0400 Subject: [PATCH] Nif loader: workaround for missed textures in BB/BH Works for Better Bodies / Better Heads addons. --- components/nifogre/ogre_nif_loader.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/components/nifogre/ogre_nif_loader.cpp b/components/nifogre/ogre_nif_loader.cpp index dfbc93ee9..0ee778df3 100644 --- a/components/nifogre/ogre_nif_loader.cpp +++ b/components/nifogre/ogre_nif_loader.cpp @@ -540,7 +540,7 @@ static Ogre::String getMaterial(const Nif::NiTriShape *shape, const Ogre::String Nif::NiSourceTexture *st = t->textures[0].texture.getPtr(); if (st->external) { - /* Bethesda at some at some point converted all their BSA + /* Bethesda at some point converted all their BSA * textures from tga to dds for increased load speed, but all * texture file name references were kept as .tga. */ @@ -559,6 +559,17 @@ static Ogre::String getMaterial(const Nif::NiTriShape *shape, const Ogre::String if(!Ogre::ResourceGroupManager::getSingleton().resourceExistsInAnyGroup(texName)) texName = path + st->filename; } + else if (!Ogre::ResourceGroupManager::getSingleton().resourceExistsInAnyGroup(texName)) + { + // workaround for Better Heads addon + size_t lastSlash = st->filename.rfind('\\'); + if (lastSlash != std::string::npos && lastSlash + 1 != st->filename.size()) { + texName = path + st->filename.substr(lastSlash + 1); + // workaround for Better Bodies addon + if (!Ogre::ResourceGroupManager::getSingleton().resourceExistsInAnyGroup(texName)) + texName = st->filename; + } + } } else warn("Found internal texture, ignoring."); }