| 1291 | } |
| 1292 | |
| 1293 | bool Bundle3D::loadSkinDataBinary(SkinData* skindata) |
| 1294 | { |
| 1295 | if (!seekToFirstType(BUNDLE_TYPE_MESHSKIN)) |
| 1296 | return false; |
| 1297 | |
| 1298 | std::string boneName = _binaryReader.readString(); |
| 1299 | |
| 1300 | // transform |
| 1301 | float bindShape[16]; |
| 1302 | if (!_binaryReader.readMatrix(bindShape)) |
| 1303 | { |
| 1304 | AXLOGW("warning: Failed to read SkinData: bindShape matrix '{}'.", _path); |
| 1305 | return false; |
| 1306 | } |
| 1307 | |
| 1308 | // bone count |
| 1309 | unsigned int boneNum; |
| 1310 | if (!_binaryReader.read(&boneNum)) |
| 1311 | { |
| 1312 | AXLOGW("warning: Failed to read SkinData: boneNum '{}'.", _path); |
| 1313 | return false; |
| 1314 | } |
| 1315 | |
| 1316 | // Fix bug: check if the bone number is 0. |
| 1317 | if (boneNum == 0) |
| 1318 | return false; |
| 1319 | |
| 1320 | // bone names and bind pos |
| 1321 | float bindpos[16]; |
| 1322 | for (unsigned int i = 0; i < boneNum; ++i) |
| 1323 | { |
| 1324 | std::string skinBoneName = _binaryReader.readString(); |
| 1325 | skindata->skinBoneNames.emplace_back(skinBoneName); |
| 1326 | if (!_binaryReader.readMatrix(bindpos)) |
| 1327 | { |
| 1328 | AXLOGW("warning: Failed to load SkinData: bindpos '{}'.", _path); |
| 1329 | return false; |
| 1330 | } |
| 1331 | skindata->inverseBindPoseMatrices.emplace_back(bindpos); |
| 1332 | } |
| 1333 | |
| 1334 | skindata->skinBoneOriginMatrices.resize(boneNum); |
| 1335 | |
| 1336 | boneName = _binaryReader.readString(); |
| 1337 | |
| 1338 | // bind shape |
| 1339 | _binaryReader.readMatrix(bindShape); |
| 1340 | int rootIndex = skindata->getSkinBoneNameIndex(boneName); |
| 1341 | if (rootIndex < 0) |
| 1342 | { |
| 1343 | skindata->addNodeBoneNames(boneName); |
| 1344 | rootIndex = skindata->getBoneNameIndex(boneName); |
| 1345 | skindata->nodeBoneOriginMatrices.emplace_back(bindShape); |
| 1346 | } |
| 1347 | else |
| 1348 | { |
| 1349 | skindata->skinBoneOriginMatrices[rootIndex] = bindShape; |
| 1350 | } |
nothing calls this directly
no test coverage detected