| 1549 | } |
| 1550 | |
| 1551 | bool Bundle3D::loadAnimationDataBinary(std::string_view id, Animation3DData* animationdata) |
| 1552 | { |
| 1553 | |
| 1554 | if (_version == "0.1" || _version == "0.2" || _version == "0.3" || _version == "0.4") |
| 1555 | { |
| 1556 | if (!seekToFirstType(BUNDLE_TYPE_ANIMATIONS)) |
| 1557 | return false; |
| 1558 | } |
| 1559 | else |
| 1560 | { |
| 1561 | // if id is not a null string, we need to add a suffix of "animation" for seeding. |
| 1562 | std::string id_{id}; |
| 1563 | if (!id.empty()) |
| 1564 | id_.append("animation"); |
| 1565 | |
| 1566 | if (!seekToFirstType(BUNDLE_TYPE_ANIMATIONS, id_)) |
| 1567 | return false; |
| 1568 | } |
| 1569 | |
| 1570 | unsigned int animNum = 1; |
| 1571 | if (_version == "0.3" || _version == "0.4") |
| 1572 | { |
| 1573 | if (!_binaryReader.read(&animNum)) |
| 1574 | { |
| 1575 | AXLOGW("warning: Failed to read AnimationData: animNum '{}'.", _path); |
| 1576 | return false; |
| 1577 | } |
| 1578 | } |
| 1579 | |
| 1580 | bool has_found = false; |
| 1581 | for (unsigned int k = 0; k < animNum; ++k) |
| 1582 | { |
| 1583 | animationdata->resetData(); |
| 1584 | std::string animId = _binaryReader.readString(); |
| 1585 | |
| 1586 | if (!_binaryReader.read(&animationdata->_totalTime)) |
| 1587 | { |
| 1588 | AXLOGW("warning: Failed to read AnimationData: totalTime '{}'.", _path); |
| 1589 | return false; |
| 1590 | } |
| 1591 | |
| 1592 | unsigned int nodeAnimationNum; |
| 1593 | if (!_binaryReader.read(&nodeAnimationNum)) |
| 1594 | { |
| 1595 | AXLOGW("warning: Failed to read AnimationData: animNum '{}'.", _path); |
| 1596 | return false; |
| 1597 | } |
| 1598 | for (unsigned int i = 0; i < nodeAnimationNum; ++i) |
| 1599 | { |
| 1600 | std::string boneName = _binaryReader.readString(); |
| 1601 | unsigned int keyframeNum; |
| 1602 | if (!_binaryReader.read(&keyframeNum)) |
| 1603 | { |
| 1604 | AXLOGW("warning: Failed to read AnimationData: keyframeNum '{}'.", _path); |
| 1605 | return false; |
| 1606 | } |
| 1607 | |
| 1608 | animationdata->_rotationKeys[boneName].reserve(keyframeNum); |
nothing calls this directly
no test coverage detected