| 951 | } |
| 952 | |
| 953 | bool Tr2GrannyAnimation::GetDynamicBounds( Vector4& boundingSphere, Vector3& aabbMin, Vector3& aabbMax ) |
| 954 | { |
| 955 | if( IsUsingCMF() ) |
| 956 | { |
| 957 | Vector3 transformed[8]; |
| 958 | if( m_boneBounds.empty() && !InitializeBoundingInfo() ) |
| 959 | { |
| 960 | return false; |
| 961 | } |
| 962 | |
| 963 | BoundingSphereInitialize( boundingSphere ); |
| 964 | BoundingBoxInitialize( aabbMin, aabbMax ); |
| 965 | |
| 966 | for( const auto& bb : m_boneBounds ) |
| 967 | { |
| 968 | const Matrix& mat = m_worldTransforms[bb.m_boneIndex]; |
| 969 | |
| 970 | for( unsigned point = 0; point < 8; point++ ) |
| 971 | { |
| 972 | transformed[point] = TransformCoord( bb.m_corners[point], mat ); |
| 973 | BoundingBoxUpdate( aabbMin, aabbMax, transformed[point] ); |
| 974 | BoundingSphereUpdate( transformed[point], boundingSphere ); |
| 975 | } |
| 976 | } |
| 977 | |
| 978 | return true; |
| 979 | } |
| 980 | #if WITH_GRANNY |
| 981 | else |
| 982 | { |
| 983 | Vector3 transformed[8]; |
| 984 | if( m_boneBounds.empty() && !InitializeBoundingInfo() ) |
| 985 | { |
| 986 | return false; |
| 987 | } |
| 988 | |
| 989 | BoundingSphereInitialize( boundingSphere ); |
| 990 | BoundingBoxInitialize( aabbMin, aabbMax ); |
| 991 | |
| 992 | for( const auto& bb : m_boneBounds ) |
| 993 | { |
| 994 | const Matrix* mat = reinterpret_cast<const Matrix*>( GrannyGetWorldPose4x4( m_worldPose, bb.m_boneIndex ) ); |
| 995 | |
| 996 | for( unsigned point = 0; point < 8; point++ ) |
| 997 | { |
| 998 | transformed[point] = TransformCoord( bb.m_corners[point], *mat ); |
| 999 | BoundingBoxUpdate( aabbMin, aabbMax, transformed[point] ); |
| 1000 | BoundingSphereUpdate( transformed[point], boundingSphere ); |
| 1001 | } |
| 1002 | } |
| 1003 | |
| 1004 | const granny_file_info* fi = GetFileInfo(); |
| 1005 | if( fi ) |
| 1006 | { |
| 1007 | aabbMin += *reinterpret_cast<Vector3*>( fi->Models[m_modelIndex]->InitialPlacement.Position ); |
| 1008 | aabbMax += *reinterpret_cast<Vector3*>( fi->Models[m_modelIndex]->InitialPlacement.Position ); |
| 1009 | boundingSphere.x += fi->Models[m_modelIndex]->InitialPlacement.Position[0]; |
| 1010 | boundingSphere.y += fi->Models[m_modelIndex]->InitialPlacement.Position[1]; |
nothing calls this directly
no test coverage detected