faster method for texture handling

This commit is contained in:
Anakin
2016-11-13 15:46:52 +01:00
parent 0f379ba04a
commit 806024f4f9
3 changed files with 75 additions and 52 deletions

View File

@@ -393,15 +393,7 @@ void Object::analyseSegmChunks(Modl * dataDestination, std::list<ChunkHeader*>&
if (!strcmp("MATI", (*it)->name))
{
fsMesh.seekg((*it)->position);
std::uint32_t tempIndex;
fsMesh.read(reinterpret_cast<char*>(&tempIndex), sizeof(tempIndex));
if (vTextures.size() <= tempIndex)
{
std::cout << "warning texture index <" << tempIndex << "> unknown" << std::endl;
tempData->texture = "";
continue;
}
tempData->texture = vTextures[tempIndex];
fsMesh.read(reinterpret_cast<char*>(&tempData->textureIndex), sizeof(tempData->textureIndex));
continue;
}
@@ -471,7 +463,25 @@ void Object::analyseClthChunks(Modl * dataDestination, std::list<ChunkHeader*>&
char* buffer = new char[(*it)->size];
*buffer = { 0 };
fsMesh.read(buffer, (*it)->size);
tempData->texture = buffer;
bool tempFound(false);
for (unsigned int index = 0; index < vTextures.size(); index++)
{
if (!strcmp(buffer, vTextures[index].c_str()))
{
tempData->textureIndex = index;
tempFound = true;
break;
}
}
if (!tempFound)
{
vTextures.push_back(std::string(buffer));
tempData->textureIndex = vTextures.size() - 1;
}
delete buffer;
continue;
}
@@ -540,6 +550,11 @@ std::vector<Modl*> Object::getModels() const
return vModls;
}
std::vector<std::string> Object::getTextureList() const
{
return vTextures;
}
/////////////////////////////////////////////////////////////////////////
// public functions