LWO: take last CLIP with the requested index (CLIPs ordered by ordinal string)

pull/90/head
Alexander Gessler 2013-09-18 14:27:56 +02:00
parent e9ffabbfee
commit ab2e81d004
1 changed files with 13 additions and 11 deletions

View File

@ -167,19 +167,21 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex
// The older LWOB format does not use indirect references to clips. // The older LWOB format does not use indirect references to clips.
// The file name of a texture is directly specified in the tex chunk. // The file name of a texture is directly specified in the tex chunk.
if (mIsLWO2) { if (mIsLWO2) {
// find the corresponding clip // find the corresponding clip (take the last one if multiple
ClipList::iterator clip = mClips.begin(); // share the same index)
ClipList::iterator end = mClips.end(), candidate = end;
temp = (*it).mClipIdx; temp = (*it).mClipIdx;
for (ClipList::iterator end = mClips.end(); clip != end; ++clip) { for (ClipList::iterator clip = mClips.begin(); clip != end; ++clip) {
if ((*clip).idx == temp) if ((*clip).idx == temp) {
break; candidate = clip;
}
} }
if (mClips.end() == clip) { if (candidate == end) {
DefaultLogger::get()->error("LWO2: Clip index is out of bounds"); DefaultLogger::get()->error("LWO2: Clip index is out of bounds");
temp = 0; temp = 0;
// fixme: appearently some LWO files shipping with Doom3 don't // fixme: apparently some LWO files shipping with Doom3 don't
// have clips at all ... check whether that's true or whether // have clips at all ... check whether that's true or whether
// it's a bug in the loader. // it's a bug in the loader.
@ -188,16 +190,16 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex
//continue; //continue;
} }
else { else {
if (Clip::UNSUPPORTED == (*clip).type) { if (Clip::UNSUPPORTED == (*candidate).type) {
DefaultLogger::get()->error("LWO2: Clip type is not supported"); DefaultLogger::get()->error("LWO2: Clip type is not supported");
continue; continue;
} }
AdjustTexturePath((*clip).path); AdjustTexturePath((*candidate).path);
s.Set((*clip).path); s.Set((*candidate).path);
// Additional image settings // Additional image settings
int flags = 0; int flags = 0;
if ((*clip).negate) { if ((*candidate).negate) {
flags |= aiTextureFlags_Invert; flags |= aiTextureFlags_Invert;
} }
pcMat->AddProperty(&flags,1,AI_MATKEY_TEXFLAGS(type,cur)); pcMat->AddProperty(&flags,1,AI_MATKEY_TEXFLAGS(type,cur));