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

Method PrePhysicsAnimation

trinity/Tr2GrannyAnimation.cpp:1675–1782  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1673}
1674
1675void Tr2GrannyAnimation::PrePhysicsAnimation( Be::Time time, const Matrix& modelTransform )
1676{
1677 if( IsUsingCMF() )
1678 {
1679 if( IsInitialized() && m_animationEnabled )
1680 {
1681 auto& skeleton = GetCMFData()->skeletons[m_modelIndex];
1682 float animationTime = GetAnimationTime();
1683
1684 m_morphAnimations.clear();
1685
1686 m_baseLayer.SampleAnimation( animationTime, &m_pose, m_eventListener, m_morphAnimations );
1687 for( auto& [_, layer] : m_animationLayers )
1688 {
1689 layer.SampleAnimation( animationTime, &m_tmpPose, &m_pose, m_eventListener, m_morphAnimations, m_additiveMode );
1690 }
1691
1692 UpdateAimingBone( skeleton );
1693
1694 if( m_boneOffset.NeedRebind( (uint32_t)skeleton.bones.size() ) && skeleton.bones.size() )
1695 {
1696 std::vector<std::string> bones( skeleton.bones.size() );
1697 for( size_t i = 0; i < bones.size(); ++i )
1698 {
1699 bones[i] = cmf::ToStdString( skeleton.bones[i] );
1700 }
1701 m_boneOffset.BindToRig( &bones[0], bones.size() );
1702 }
1703
1704 if( m_boneOffset.HaveTransforms() )
1705 {
1706 for( int32_t i = 0; i < skeleton.bones.size(); i++ )
1707 {
1708 ApplyBoneOffsets( i );
1709 }
1710 }
1711
1712 cmf::ComputeWorldTransforms( m_worldTransforms, m_pose );
1713
1714 if( m_useMeshBinding && m_meshBoneMatrixList && m_meshBoneCount )
1715 {
1716 for( int32_t i = 0; i < m_meshBoneCount; i++ )
1717 {
1718 int32_t boneIdx = m_skeletonBoneIndices[i];
1719 if( boneIdx >= 0 )
1720 {
1721 Matrix skinMatrix = skeleton.invBindTransforms[boneIdx] * m_worldTransforms[boneIdx];
1722 m_meshBoneMatrixList[i] = Float4x3( skinMatrix );
1723 }
1724 }
1725 }
1726
1727 UpdateDebugRenderer( skeleton, modelTransform );
1728 }
1729 }
1730#if WITH_GRANNY
1731 else
1732 {

Callers 3

PrePhysicsUpdateMethod · 0.45
UpdateSyncronousMethod · 0.45
UpdateSyncronousMethod · 0.45

Calls 10

IsUsingCMFFunction · 0.85
Float4x3Class · 0.85
SampleAnimationMethod · 0.80
NeedRebindMethod · 0.80
sizeMethod · 0.80
HaveTransformsMethod · 0.80
ifFunction · 0.50
BindToRigMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected