------------------------------------------------------------------------------------------------ Read hierarchy and keyframe info
| 607 | // ------------------------------------------------------------------------------------------------ |
| 608 | // Read hierarchy and keyframe info |
| 609 | void Discreet3DSImporter::ParseHierarchyChunk(uint16_t parent) { |
| 610 | ASSIMP_3DS_BEGIN_CHUNK(); |
| 611 | |
| 612 | // get chunk type |
| 613 | switch (chunk.Flag) { |
| 614 | case Discreet3DS::CHUNK_TRACKOBJNAME: |
| 615 | |
| 616 | // This is the name of the object to which the track applies. The chunk also |
| 617 | // defines the position of this object in the hierarchy. |
| 618 | { |
| 619 | |
| 620 | // First of all: get the name of the object |
| 621 | unsigned int cnt = 0; |
| 622 | auto *sz = (const char *)mStream->GetPtr(); |
| 623 | |
| 624 | while (mStream->GetI1()) |
| 625 | ++cnt; |
| 626 | std::string name = std::string(sz, cnt); |
| 627 | |
| 628 | // Now find out whether we have this node already (target animation channels |
| 629 | // are stored with a separate object ID) |
| 630 | Node *pcNode = FindNode(mRootNode, name); |
| 631 | int instanceNumber = 1; |
| 632 | |
| 633 | if (pcNode) { |
| 634 | // if the source is not a CHUNK_TRACKINFO block it won't be an object instance |
| 635 | if (parent != Discreet3DS::CHUNK_TRACKINFO) { |
| 636 | mCurrentNode = pcNode; |
| 637 | break; |
| 638 | } |
| 639 | pcNode->mInstanceCount++; |
| 640 | instanceNumber = pcNode->mInstanceCount; |
| 641 | } |
| 642 | pcNode = new D3DS::Node(name); |
| 643 | pcNode->mInstanceNumber = instanceNumber; |
| 644 | |
| 645 | // There are two unknown values which we can safely ignore |
| 646 | mStream->IncPtr(4); |
| 647 | |
| 648 | // Now read the hierarchy position of the object |
| 649 | uint16_t hierarchy = mStream->GetI2() + 1; |
| 650 | pcNode->mHierarchyPos = hierarchy; |
| 651 | pcNode->mHierarchyIndex = mLastNodeIndex; |
| 652 | |
| 653 | // And find a proper position in the graph for it |
| 654 | if (mCurrentNode && mCurrentNode->mHierarchyPos == hierarchy) { |
| 655 | |
| 656 | // add to the parent of the last touched node |
| 657 | mCurrentNode->mParent->push_back(pcNode); |
| 658 | mLastNodeIndex++; |
| 659 | } else if (hierarchy >= mLastNodeIndex) { |
| 660 | |
| 661 | // place it at the current position in the hierarchy |
| 662 | mCurrentNode->push_back(pcNode); |
| 663 | mLastNodeIndex = hierarchy; |
| 664 | } else { |
| 665 | // need to go back to the specified position in the hierarchy. |
| 666 | InverseNodeSearch(pcNode, mCurrentNode); |
nothing calls this directly
no test coverage detected