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

Method InitializeAnimationLayer

trinity/Tr2GrannyAnimationLayer.cpp:85–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83}
84
85void Tr2GrannyAnimationLayer::InitializeAnimationLayer( const Tr2GrannyAnimation* grannyAnimation )
86{
87 m_useCMF = grannyAnimation->IsUsingCMF();
88
89 if( grannyAnimation->IsUsingCMF() )
90 {
91 const cmf::Skeleton* skeleton = grannyAnimation->GetSkeleton();
92 if( !skeleton )
93 {
94 return;
95 }
96
97 m_sequencer = std::make_unique<cmf::AnimationSequencer>( *skeleton );
98
99 if( m_trackMaskName )
100 {
101 ExtractTrackMask( grannyAnimation, m_trackMaskName );
102 }
103 else
104 {
105 m_boneMask.skeleton = skeleton;
106 m_boneMask.boneWeights.resize( skeleton->bones.size() );
107 for( auto& boneWeight : m_boneMask.boneWeights )
108 {
109 boneWeight = m_defaultBoneWeight;
110 }
111 }
112 for( const auto& bone : m_bones )
113 {
114 unsigned int boneIndex;
115 if( grannyAnimation->FindBoneByName( bone.c_str(), boneIndex ) )
116 {
117 CCP_ASSERT( boneIndex < m_boneMask.boneWeights.size() );
118 m_boneMask.boneWeights[boneIndex] = m_defaultBoneWeight;
119 }
120 }
121 }
122#if WITH_GRANNY
123 else
124 {
125 granny_model* model = grannyAnimation->GetGrannyModel();
126 if( !model )
127 {
128 return;
129 }
130
131 m_modelInstance = GrannyInstantiateModel( model );
132 granny_skeleton* skeleton = GrannyGetSourceSkeleton( m_modelInstance );
133 m_boneCount = skeleton->BoneCount;
134 m_trackMask = GrannyNewTrackMask( m_defaultBoneWeight, skeleton->BoneCount );
135
136 if( m_trackMaskName )
137 {
138 ExtractTrackMask( grannyAnimation, m_trackMaskName );
139 }
140 for( auto it = m_bones.begin(); it != m_bones.end(); it++ )
141 {
142 unsigned int boneIndex;

Callers 3

RebuildCachedDataMethod · 0.80
AddAnimationLayerMethod · 0.80

Calls 7

sizeMethod · 0.80
IsUsingCMFMethod · 0.45
GetSkeletonMethod · 0.45
FindBoneByNameMethod · 0.45
GetGrannyModelMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected