MCPcopy Create free account
hub / github.com/carbonengine/trinity / GetDynamicBounds

Method GetDynamicBounds

trinity/Tr2GrannyAnimation.cpp:953–1021  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

951}
952
953bool 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];

Callers

nothing calls this directly

Calls 6

IsUsingCMFFunction · 0.85
BoundingSphereInitializeFunction · 0.85
BoundingBoxInitializeFunction · 0.85
BoundingBoxUpdateFunction · 0.85
BoundingSphereUpdateFunction · 0.85
emptyMethod · 0.80

Tested by

no test coverage detected