[IMaterial] Fix technique mapping

This commit is contained in:
momo5502 2017-04-16 01:51:41 +02:00
parent 79c38f44f3
commit a177e20bf6

View File

@ -52,14 +52,20 @@ namespace Assets
"_eyeoffset", "_eyeoffset",
}; };
for(int i = 0; i < ARRAYSIZE(techsetSuffix) && !asset->techniqueSet; ++i) if (!asset->techniqueSet)
{ {
asset->techniqueSet = Components::AssetHandler::FindAssetForZone(Game::XAssetType::ASSET_TYPE_TECHNIQUE_SET, (techset + techsetSuffix[i]).data(), builder).techniqueSet; for (int i = 0; i < ARRAYSIZE(techsetSuffix); ++i)
if(asset->techniqueSet)
{ {
if (asset->techniqueSet->name[0] == ',') continue; Game::MaterialTechniqueSet* techsetPtr = Components::AssetHandler::FindAssetForZone(Game::XAssetType::ASSET_TYPE_TECHNIQUE_SET, (techset + techsetSuffix[i]).data(), builder).techniqueSet;
Components::Logger::Print("Techset '%s' has been mapped to '%s'\n", techset.data(), asset->techniqueSet->name);
if (techsetPtr)
{
asset->techniqueSet = techsetPtr;
if (asset->techniqueSet->name[0] == ',') continue; // Try to find a better one
Components::Logger::Print("Techset '%s' has been mapped to '%s'\n", techset.data(), asset->techniqueSet->name);
break;
}
} }
} }
@ -126,28 +132,31 @@ namespace Assets
// Find correct sortkey by comparing techsets // Find correct sortkey by comparing techsets
Game::DB_EnumXAssets_Internal(Game::XAssetType::ASSET_TYPE_MATERIAL, [](Game::XAssetHeader header, void* data) Game::DB_EnumXAssets_Internal(Game::XAssetType::ASSET_TYPE_MATERIAL, [](Game::XAssetHeader header, void* data)
{ {
Game::Material* material = reinterpret_cast<Game::Material*>(data); if (!replacementFound)
const char* name = material->techniqueSet->name;
if (name[0] == ',') ++name;
if (std::string(name) == header.material->techniqueSet->name)
{ {
material->sortKey = header.material->sortKey; Game::Material* material = reinterpret_cast<Game::Material*>(data);
const char* name = material->techniqueSet->name;
if (name[0] == ',') ++name;
// This is temp, as nobody has time to fix materials if (std::string(name) == header.material->techniqueSet->name)
material->stateBitsCount = header.material->stateBitsCount; {
material->stateBitTable = header.material->stateBitTable; material->sortKey = header.material->sortKey;
std::memcpy(material->stateBitsEntry, header.material->stateBitsEntry, 48);
material->constantCount = header.material->constantCount;
material->constantTable = header.material->constantTable;
replacementFound = true; // This is temp, as nobody has time to fix materials
material->stateBitsCount = header.material->stateBitsCount;
material->stateBitTable = header.material->stateBitTable;
std::memcpy(material->stateBitsEntry, header.material->stateBitsEntry, 48);
material->constantCount = header.material->constantCount;
material->constantTable = header.material->constantTable;
replacementFound = true;
}
} }
}, asset, false); }, asset, false);
if(!replacementFound) if(!replacementFound)
{ {
Components::Logger::Print("No replacment found for material %s with technset %s\n", asset->name, asset->techniqueSet->name); Components::Logger::Print("No replacement found for material %s with techset %s\n", asset->name, asset->techniqueSet->name);
} }
if (!reader.end()) if (!reader.end())