From 00729f83f7528f6db1ea89262def92c5f78cdd5a Mon Sep 17 00:00:00 2001 From: aramis_acg Date: Wed, 15 Apr 2009 16:24:58 +0000 Subject: [PATCH] FIX: multiple LWO layers referencing a single texture won't anymore cause all layers except the first to have no proper uv coordinates. git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@389 67173fc5-114c-0410-ac8e-9d2fd5bffc1f --- code/LWOMaterial.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/code/LWOMaterial.cpp b/code/LWOMaterial.cpp index 5c3123f3f..ab8dcadca 100644 --- a/code/LWOMaterial.cpp +++ b/code/LWOMaterial.cpp @@ -375,29 +375,30 @@ void LWOImporter::ConvertMaterial(const LWO::Surface& surf,MaterialHelper* pcMat // ------------------------------------------------------------------------------------------------ void LWOImporter::FindUVChannels(LWO::TextureList& list, LWO::Layer& layer, - unsigned int out[AI_MAX_NUMBER_OF_TEXTURECOORDS], unsigned int& next) + unsigned int out[AI_MAX_NUMBER_OF_TEXTURECOORDS], + unsigned int& next) { - for (TextureList::iterator it = list.begin(), end = list.end(); - it != end;++it) - { + for (TextureList::iterator it = list.begin(), end = list.end();it != end;++it) { + // Ignore textures with non-UV mappings for the moment. - if (!(*it).enabled || !(*it).bCanUse || 0xffffffff != (*it).mRealUVIndex || (*it).mapMode != LWO::Texture::UV) { + if (!(*it).enabled || !(*it).bCanUse || (*it).mapMode != LWO::Texture::UV) { continue; } - for (unsigned int i = 0; i < layer.mUVChannels.size();++i) - { - if ((*it).mUVChannelIndex == layer.mUVChannels[i].name) - { + for (unsigned int i = 0; i < layer.mUVChannels.size();++i) { + + bool found = false; + if ((*it).mUVChannelIndex == layer.mUVChannels[i].name) { // check whether we have this channel already - for (unsigned int m = 0; m < next;++m) - { + for (unsigned int m = 0; m < next;++m) { + if (i == out[m]) { (*it).mRealUVIndex = m; + found = true; break; } } - if (0xffffffff == (*it).mRealUVIndex) - { + + if (!found) { (*it).mRealUVIndex = next; out[next++] = i; if (AI_MAX_NUMBER_OF_TEXTURECOORDS != next)