MCPcopy Create free account
hub / github.com/assimp/assimp / ParseHierarchyChunk

Method ParseHierarchyChunk

code/AssetLib/3DS/3DSLoader.cpp:609–883  ·  view source on GitHub ↗

------------------------------------------------------------------------------------------------ Read hierarchy and keyframe info

Source from the content-addressed store, hash-verified

607// ------------------------------------------------------------------------------------------------
608// Read hierarchy and keyframe info
609void 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);

Callers

nothing calls this directly

Calls 15

uniqueFunction · 0.85
aiQuaternionClass · 0.85
GetPtrMethod · 0.80
GetI1Method · 0.80
IncPtrMethod · 0.80
GetI2Method · 0.80
GetI4Method · 0.80
eraseMethod · 0.80
FindNodeFunction · 0.70
push_backMethod · 0.45
GetF4Method · 0.45
reserveMethod · 0.45

Tested by

no test coverage detected