mirror of https://github.com/AxioDL/metaforce.git
Correct handling of empty skinned models
This commit is contained in:
parent
3f7431286c
commit
87e5aea6f5
|
@ -1345,17 +1345,18 @@ bool ANCS::CookCSKR(const hecl::ProjectPath& outPath,
|
||||||
if (!modelCookFunc(*modelPath))
|
if (!modelCookFunc(*modelPath))
|
||||||
Log.report(logvisor::Fatal, _SYS_STR("unable to cook '%s'"), modelPath->getRelativePath().data());
|
Log.report(logvisor::Fatal, _SYS_STR("unable to cook '%s'"), modelPath->getRelativePath().data());
|
||||||
|
|
||||||
|
std::vector<std::pair<std::vector<std::pair<uint32_t, float>>, uint32_t>> skins;
|
||||||
|
uint32_t posCount = 0;
|
||||||
|
uint32_t normCount = 0;
|
||||||
athena::io::FileReader skinIO(skinIntPath.getAbsolutePath(), 1024*32, false);
|
athena::io::FileReader skinIO(skinIntPath.getAbsolutePath(), 1024*32, false);
|
||||||
if (skinIO.hasError())
|
if (!skinIO.hasError())
|
||||||
Log.report(logvisor::Fatal, _SYS_STR("unable to open '%s'"), skinIntPath.getRelativePath().data());
|
{
|
||||||
|
|
||||||
std::vector<std::string> boneNames;
|
std::vector<std::string> boneNames;
|
||||||
uint32_t boneNameCount = skinIO.readUint32Big();
|
uint32_t boneNameCount = skinIO.readUint32Big();
|
||||||
boneNames.reserve(boneNameCount);
|
boneNames.reserve(boneNameCount);
|
||||||
for (uint32_t i=0 ; i<boneNameCount ; ++i)
|
for (uint32_t i=0 ; i<boneNameCount ; ++i)
|
||||||
boneNames.push_back(skinIO.readString());
|
boneNames.push_back(skinIO.readString());
|
||||||
|
|
||||||
std::vector<std::pair<std::vector<std::pair<uint32_t, float>>, uint32_t>> skins;
|
|
||||||
uint32_t skinCount = skinIO.readUint32Big();
|
uint32_t skinCount = skinIO.readUint32Big();
|
||||||
skins.resize(skinCount);
|
skins.resize(skinCount);
|
||||||
for (uint32_t i=0 ; i<skinCount ; ++i)
|
for (uint32_t i=0 ; i<skinCount ; ++i)
|
||||||
|
@ -1377,10 +1378,11 @@ bool ANCS::CookCSKR(const hecl::ProjectPath& outPath,
|
||||||
virtualBone.second = skinIO.readUint32Big();
|
virtualBone.second = skinIO.readUint32Big();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t posCount = skinIO.readUint32Big();
|
posCount = skinIO.readUint32Big();
|
||||||
uint32_t normCount = skinIO.readUint32Big();
|
normCount = skinIO.readUint32Big();
|
||||||
|
|
||||||
skinIO.close();
|
skinIO.close();
|
||||||
|
}
|
||||||
|
|
||||||
athena::io::TransactionalFileWriter skinOut(outPath.getAbsolutePath());
|
athena::io::TransactionalFileWriter skinOut(outPath.getAbsolutePath());
|
||||||
|
|
||||||
|
@ -1483,12 +1485,16 @@ bool ANCS::CookCSKRPC(const hecl::ProjectPath& outPath,
|
||||||
if (!modelCookFunc(*modelPath))
|
if (!modelCookFunc(*modelPath))
|
||||||
Log.report(logvisor::Fatal, _SYS_STR("unable to cook '%s'"), modelPath->getRelativePath().data());
|
Log.report(logvisor::Fatal, _SYS_STR("unable to cook '%s'"), modelPath->getRelativePath().data());
|
||||||
|
|
||||||
athena::io::FileReader skinIO(skinIntPath.getAbsolutePath(), 1024*32, false);
|
uint32_t bankCount = 0;
|
||||||
if (skinIO.hasError())
|
|
||||||
Log.report(logvisor::Fatal, _SYS_STR("unable to open '%s'"), skinIntPath.getRelativePath().data());
|
|
||||||
|
|
||||||
std::vector<std::vector<uint32_t>> skinBanks;
|
std::vector<std::vector<uint32_t>> skinBanks;
|
||||||
uint32_t bankCount = skinIO.readUint32Big();
|
std::vector<std::string> boneNames;
|
||||||
|
std::vector<std::vector<std::pair<uint32_t, float>>> skins;
|
||||||
|
atUint64 uniquePoolIndexLen = 0;
|
||||||
|
std::unique_ptr<atUint8[]> uniquePoolIndexData;
|
||||||
|
athena::io::FileReader skinIO(skinIntPath.getAbsolutePath(), 1024*32, false);
|
||||||
|
if (!skinIO.hasError())
|
||||||
|
{
|
||||||
|
bankCount = skinIO.readUint32Big();
|
||||||
skinBanks.reserve(bankCount);
|
skinBanks.reserve(bankCount);
|
||||||
for (uint32_t i=0 ; i<bankCount ; ++i)
|
for (uint32_t i=0 ; i<bankCount ; ++i)
|
||||||
{
|
{
|
||||||
|
@ -1503,13 +1509,11 @@ bool ANCS::CookCSKRPC(const hecl::ProjectPath& outPath,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> boneNames;
|
|
||||||
uint32_t boneNameCount = skinIO.readUint32Big();
|
uint32_t boneNameCount = skinIO.readUint32Big();
|
||||||
boneNames.reserve(boneNameCount);
|
boneNames.reserve(boneNameCount);
|
||||||
for (uint32_t i=0 ; i<boneNameCount ; ++i)
|
for (uint32_t i=0 ; i<boneNameCount ; ++i)
|
||||||
boneNames.push_back(skinIO.readString());
|
boneNames.push_back(skinIO.readString());
|
||||||
|
|
||||||
std::vector<std::vector<std::pair<uint32_t, float>>> skins;
|
|
||||||
uint32_t skinCount = skinIO.readUint32Big();
|
uint32_t skinCount = skinIO.readUint32Big();
|
||||||
skins.resize(skinCount);
|
skins.resize(skinCount);
|
||||||
for (uint32_t i=0 ; i<skinCount ; ++i)
|
for (uint32_t i=0 ; i<skinCount ; ++i)
|
||||||
|
@ -1530,10 +1534,11 @@ bool ANCS::CookCSKRPC(const hecl::ProjectPath& outPath,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
atUint64 uniquePoolIndexLen = skinIO.length() - skinIO.position();
|
uniquePoolIndexLen = skinIO.length() - skinIO.position();
|
||||||
auto uniquePoolIndexData = skinIO.readUBytes(uniquePoolIndexLen);
|
uniquePoolIndexData = skinIO.readUBytes(uniquePoolIndexLen);
|
||||||
|
|
||||||
skinIO.close();
|
skinIO.close();
|
||||||
|
}
|
||||||
|
|
||||||
athena::io::TransactionalFileWriter skinOut(outPath.getAbsolutePath());
|
athena::io::TransactionalFileWriter skinOut(outPath.getAbsolutePath());
|
||||||
|
|
||||||
|
@ -1563,6 +1568,7 @@ bool ANCS::CookCSKRPC(const hecl::ProjectPath& outPath,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (uniquePoolIndexLen)
|
||||||
skinOut.writeUBytes(uniquePoolIndexData.get(), uniquePoolIndexLen);
|
skinOut.writeUBytes(uniquePoolIndexData.get(), uniquePoolIndexLen);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue