| 41 | namespace Ogre |
| 42 | { |
| 43 | SkeletonDef::SkeletonDef( const v1::Skeleton *originalSkeleton, Real frameRate ) : |
| 44 | mNumUnusedSlots( 0 ), |
| 45 | mName( originalSkeleton->getName() ) |
| 46 | { |
| 47 | mBones.reserve( originalSkeleton->getNumBones() ); |
| 48 | |
| 49 | // Clone the bone data |
| 50 | size_t numDepthLevels = 1; |
| 51 | v1::Skeleton::ConstBoneIterator itor = originalSkeleton->getBoneIteratorConst(); |
| 52 | while( itor.hasMoreElements() ) |
| 53 | { |
| 54 | v1::OldBone *bone = itor.getNext(); |
| 55 | size_t parentIndex = std::numeric_limits<size_t>::max(); |
| 56 | if( bone->getParent() ) |
| 57 | { |
| 58 | assert( !bone->getParent() || dynamic_cast<v1::OldBone *>( bone->getParent() ) ); |
| 59 | v1::OldBone *parent = static_cast<v1::OldBone *>( bone->getParent() ); |
| 60 | parentIndex = parent->getHandle(); |
| 61 | |
| 62 | size_t tmpDepthLevels = 2; |
| 63 | v1::OldNode *tmpParent = parent; |
| 64 | while( ( tmpParent = tmpParent->getParent() ) ) |
| 65 | ++tmpDepthLevels; |
| 66 | numDepthLevels = std::max( numDepthLevels, tmpDepthLevels ); |
| 67 | } |
| 68 | |
| 69 | BoneData boneData( bone->getHandle(), parentIndex, bone->getPosition(), |
| 70 | bone->getOrientation(), bone->getScale(), bone->getName(), |
| 71 | bone->getInheritOrientation(), bone->getInheritScale() ); |
| 72 | mBoneIndexByName[bone->getName()] = mBones.size(); |
| 73 | mBones.push_back( boneData ); |
| 74 | } |
| 75 | |
| 76 | mBonesPerDepth.resize( numDepthLevels ); |
| 77 | mDepthLevelInfoVec.resize( numDepthLevels ); |
| 78 | for( size_t i = 0; i < mBones.size(); ++i ) |
| 79 | { |
| 80 | size_t currentDepthLevel = 0; |
| 81 | BoneData const *tmpBone = &mBones[i]; |
| 82 | while( tmpBone->parent != std::numeric_limits<size_t>::max() ) |
| 83 | { |
| 84 | tmpBone = &mBones[tmpBone->parent]; |
| 85 | ++currentDepthLevel; |
| 86 | } |
| 87 | |
| 88 | DepthLevelInfo &info = mDepthLevelInfoVec[currentDepthLevel]; |
| 89 | info.firstBoneIndex = std::min( i, info.firstBoneIndex ); |
| 90 | ++info.numBonesInLevel; |
| 91 | |
| 92 | mBonesPerDepth[currentDepthLevel].push_back( i ); |
| 93 | } |
| 94 | |
| 95 | // Populate both mBoneToSlot and mSlotToBone |
| 96 | mBoneToSlot.reserve( originalSkeleton->getNumBones() ); |
| 97 | for( size_t i = 0; i < originalSkeleton->getNumBones(); ++i ) |
| 98 | { |
| 99 | const v1::OldBone *bone = originalSkeleton->getBone( (uint16)i ); |
| 100 |
nothing calls this directly
no test coverage detected