| 971 | } |
| 972 | |
| 973 | Vector4 Tr2GStateAnimation::CalculateSkinnedBoundingSphere( granny_file_info* fi ) |
| 974 | { |
| 975 | PrePhysicsAnimation( 0, IdentityMatrix() ); |
| 976 | |
| 977 | if( !m_meshBinding ) |
| 978 | { |
| 979 | return Vector4( 0.f, 0.f, 0.f, -1.f ); |
| 980 | } |
| 981 | |
| 982 | if( !fi ) |
| 983 | { |
| 984 | fi = GetFileInfo(); |
| 985 | } |
| 986 | if( !fi ) |
| 987 | { |
| 988 | return Vector4( 0.f, 0.f, 0.f, -1.f ); |
| 989 | } |
| 990 | |
| 991 | // Known input and output vertex format |
| 992 | granny_mesh* mesh = fi->Models[m_modelIndex]->MeshBindings[m_meshBindingIndex].Mesh; |
| 993 | granny_int32x vertCount = GrannyGetMeshVertexCount( mesh ); |
| 994 | |
| 995 | std::vector<granny_pwn313_vertex> sourceVerts( vertCount ); |
| 996 | std::vector<granny_pn33_vertex> deformedVerts( vertCount ); |
| 997 | |
| 998 | GrannyCopyMeshVertices( mesh, GrannyPWN313VertexType, &sourceVerts[0] ); |
| 999 | |
| 1000 | granny_mesh_deformer* deformer = GrannyNewMeshDeformer( GrannyPWN313VertexType, |
| 1001 | GrannyPN33VertexType, |
| 1002 | GrannyDeformPositionNormal, |
| 1003 | GrannyDontAllowUncopiedTail ); |
| 1004 | if( !deformer ) |
| 1005 | { |
| 1006 | return Vector4( 0.f, 0.f, 0.f, -1.f ); |
| 1007 | } |
| 1008 | |
| 1009 | GrannyDeformVertices( deformer, GrannyGetMeshBindingFromBoneIndices( m_meshBinding ), (granny_real32*)GrannyGetWorldPoseComposite4x4Array( m_worldPose ), vertCount, &sourceVerts[0], &deformedVerts[0] ); |
| 1010 | |
| 1011 | // Gather a list of pointers to the positions |
| 1012 | std::vector<const Vector3*> points( vertCount ); |
| 1013 | for( int32_t p = 0; p < vertCount; ++p ) |
| 1014 | { |
| 1015 | points[p] = (const Vector3*)&deformedVerts[p].Position; |
| 1016 | } |
| 1017 | |
| 1018 | // Calculate the bounding sphere |
| 1019 | Vector4 boundingSphere; |
| 1020 | BoundingSphereFromPoints( boundingSphere, &points[0], points.size() ); |
| 1021 | |
| 1022 | return boundingSphere; |
| 1023 | } |
| 1024 | |
| 1025 | |
| 1026 | granny_model* Tr2GStateAnimation::GetGrannyModel() const |
nothing calls this directly
no test coverage detected