| 840 | } |
| 841 | |
| 842 | bool Tr2GrannyAnimation::InitializeBoundingInfo() |
| 843 | { |
| 844 | if( IsUsingCMF() ) |
| 845 | { |
| 846 | auto cmfData = GetCMFData(); |
| 847 | if( !cmfData ) |
| 848 | { |
| 849 | return false; |
| 850 | } |
| 851 | |
| 852 | if( cmfData->skeletons.size() == 0 ) |
| 853 | { |
| 854 | return false; |
| 855 | } |
| 856 | |
| 857 | if( cmfData->meshes.size() == 0 ) |
| 858 | { |
| 859 | return false; |
| 860 | } |
| 861 | |
| 862 | if( !m_useMeshBinding ) |
| 863 | { |
| 864 | return false; |
| 865 | } |
| 866 | |
| 867 | auto& skeleton = cmfData->skeletons[m_modelIndex]; |
| 868 | |
| 869 | auto boneBindings = cmfData->meshes[0].boneBindings; |
| 870 | m_boneBounds.clear(); |
| 871 | for( int boneIdx = 0; boneIdx < skeleton.bones.size(); boneIdx++ ) |
| 872 | { |
| 873 | auto name = skeleton.bones[boneIdx]; |
| 874 | auto boneBinding = std::find_if( boneBindings.begin(), boneBindings.end(), [name]( const cmf::BoneBinding& bb ) { |
| 875 | return name == bb.name; |
| 876 | } ); |
| 877 | if( boneBinding != boneBindings.end() ) |
| 878 | { |
| 879 | GrannyBoneBindingBounds bounds; |
| 880 | bounds.m_boneIndex = boneIdx; |
| 881 | auto minBounds = boneBinding->bounds.m_min; |
| 882 | auto maxBounds = boneBinding->bounds.m_max; |
| 883 | bounds.m_corners[0] = minBounds; |
| 884 | bounds.m_corners[1] = maxBounds; |
| 885 | bounds.m_corners[2] = Vector3( minBounds.x, minBounds.y, maxBounds.z ); |
| 886 | bounds.m_corners[3] = Vector3( minBounds.x, maxBounds.y, minBounds.z ); |
| 887 | bounds.m_corners[4] = Vector3( minBounds.x, maxBounds.y, maxBounds.z ); |
| 888 | bounds.m_corners[5] = Vector3( maxBounds.x, minBounds.y, minBounds.z ); |
| 889 | bounds.m_corners[6] = Vector3( maxBounds.x, minBounds.y, maxBounds.z ); |
| 890 | bounds.m_corners[7] = Vector3( maxBounds.x, maxBounds.y, minBounds.z ); |
| 891 | m_boneBounds.push_back( bounds ); |
| 892 | } |
| 893 | } |
| 894 | |
| 895 | return true; |
| 896 | } |
| 897 | #if WITH_GRANNY |
| 898 | else |
| 899 | { |
nothing calls this directly
no test coverage detected