@@ -97,7 +97,7 @@ void CClientIFP::ReadIFPVersion2( bool anp3)
97
97
IFP_Animation & ifpAnimation = m_pVecAnimations->at ( i );
98
98
99
99
CAnimManager * pAnimManager = g_pGame->GetAnimManager ( );
100
- std::unique_ptr < CAnimBlendHierarchy > pAnimationHierarchy = pAnimManager->GetCustomAnimBlendHierarchy ( (CAnimBlendHierarchySAInterface *) &ifpAnimation.Hierarchy );
100
+ std::unique_ptr < CAnimBlendHierarchy > pAnimationHierarchy = pAnimManager->GetCustomAnimBlendHierarchy ( &ifpAnimation.Hierarchy );
101
101
102
102
pAnimationHierarchy->Initialize ( );
103
103
@@ -121,8 +121,9 @@ void CClientIFP::ReadIFPVersion2( bool anp3)
121
121
pAnimationHierarchy->SetName ( AnimationNode.Name );
122
122
pAnimationHierarchy->SetNumSequences ( AnimationNode.TotalObjects );
123
123
pAnimationHierarchy->SetAnimationBlockID ( 0 );
124
+ pAnimationHierarchy->SetRunningCompressed ( m_kbAllKeyFramesCompressed );
124
125
125
- const unsigned short TotalSequences = cIFPSequences + pAnimationHierarchy->GetNumSequences ( );
126
+ const unsigned short TotalSequences = m_kcIFPSequences + pAnimationHierarchy->GetNumSequences ( );
126
127
ifpAnimation.pSequencesMemory = ( char * ) operator new ( 12 * TotalSequences + 4 ); // Allocate memory for sequences ( 12 * seq_count + 4 )
127
128
128
129
pAnimationHierarchy->SetSequences ( reinterpret_cast < CAnimBlendSequenceSAInterface * > ( ifpAnimation.pSequencesMemory + 4 ) );
@@ -147,7 +148,7 @@ void CClientIFP::ReadIFPVersion2( bool anp3)
147
148
bool bUnknownSequence = ObjectNode.BoneID == -1 ;
148
149
if (bUnknownSequence)
149
150
{
150
- size_t UnkownSequenceIndex = cIFPSequences + wUnknownSequences;
151
+ size_t UnkownSequenceIndex = m_kcIFPSequences + wUnknownSequences;
151
152
pAnimationSequenceInterface = pAnimationHierarchy->GetSequence ( UnkownSequenceIndex );
152
153
wUnknownSequences ++;
153
154
}
@@ -157,49 +158,15 @@ void CClientIFP::ReadIFPVersion2( bool anp3)
157
158
pAnimationSequence->SetName ( ObjectNode.Name );
158
159
pAnimationSequence->SetBoneTag ( ObjectNode.BoneID );
159
160
160
- if (bFirstSeq)
161
+ IFP_FrameType iFrameType = static_cast < IFP_FrameType > ( ObjectNode.FrameType );
162
+ size_t iCompressedFrameSize = GetSizeOfCompressedFrame ( iFrameType );
163
+ if ( iCompressedFrameSize )
161
164
{
162
- bFirstSeq = false ;
163
- pAnimationHierarchy->SetRunningCompressed ( ObjectNode.FrameType == 3 || ObjectNode.FrameType == 4 );
164
- }
165
-
166
- size_t data_size = 0 ;
167
- bool bIsRoot;
168
- bool bIsCompressed;
169
- bool bInvalidType = false ;
170
- switch (ObjectNode.FrameType )
171
- {
172
- case 1 :
173
- data_size = 20 * ObjectNode.TotalFrames ; // sizeof(SChildKeyFrame) * seq.frames_count;
174
- bIsRoot = false ;
175
- bIsCompressed = false ;
176
- break ;
177
- case 2 :
178
- data_size = 32 * ObjectNode.TotalFrames ; // sizeof(SRootKeyFrame) * seq.frames_count;
179
- bIsRoot = true ;
180
- bIsCompressed = false ;
181
- break ;
182
- case 3 :
183
- data_size = 10 * ObjectNode.TotalFrames ; // sizeof(SCompressedChildKeyFrame) * seq.frames_count;
184
- bIsRoot = false ;
185
- bIsCompressed = true ;
186
- break ;
187
- case 4 :
188
- data_size = 16 * ObjectNode.TotalFrames ; // sizeof(SCompressedRootKeyFrame) * seq.frames_count;
189
- bIsRoot = true ;
190
- bIsCompressed = true ;
191
- break ;
192
- default :
193
- bInvalidType = true ;
194
- break ;
195
- }
196
- if (!bInvalidType)
197
- {
198
- unsigned char * pKeyFrames = (unsigned char *) OLD_CMemoryMgr_Malloc ( data_size );
165
+ BYTE * pKeyFrames = static_cast < BYTE * > ( OLD_CMemoryMgr_Malloc ( iCompressedFrameSize * ObjectNode.TotalFrames ) );
199
166
200
- pAnimationSequence->SetKeyFrames ( ObjectNode.TotalFrames , bIsRoot, bIsCompressed , pKeyFrames );
167
+ pAnimationSequence->SetKeyFrames ( ObjectNode.TotalFrames , isKeyFramesTypeRoot ( iFrameType ), m_kbAllKeyFramesCompressed , pKeyFrames );
201
168
202
- readBytes ( pKeyFrames, data_size );
169
+ ReadKeyFramesAsCompressed ( iFrameType, pKeyFrames, ObjectNode. TotalFrames );
203
170
204
171
if ( !bUnknownSequence )
205
172
{
@@ -210,10 +177,10 @@ void CClientIFP::ReadIFPVersion2( bool anp3)
210
177
211
178
CopySequencesWithDummies ( pAnimManager, pAnimationHierarchy, MapOfSequences );
212
179
213
- *(DWORD *)ifpAnimation.pSequencesMemory = cIFPSequences + wUnknownSequences;
180
+ *(DWORD *)ifpAnimation.pSequencesMemory = m_kcIFPSequences + wUnknownSequences;
214
181
215
182
// This order is very important. As we need support for all 32 bones, we must change the total sequences count
216
- pAnimationHierarchy->SetNumSequences ( cIFPSequences + wUnknownSequences );
183
+ pAnimationHierarchy->SetNumSequences ( m_kcIFPSequences + wUnknownSequences );
217
184
218
185
if ( !pAnimationHierarchy->isRunningCompressed ( ) )
219
186
{
@@ -227,7 +194,7 @@ void CClientIFP::ReadIFPVersion2( bool anp3)
227
194
void CClientIFP::CopySequencesWithDummies ( CAnimManager * pAnimManager, std::unique_ptr < CAnimBlendHierarchy > & pAnimationHierarchy, std::map < std::string, CAnimBlendSequenceSAInterface > & mapOfSequences )
228
195
{
229
196
std::map < std::string, CAnimBlendSequenceSAInterface >::iterator it;
230
- for (size_t SequenceIndex = 0 ; SequenceIndex < cIFPSequences ; SequenceIndex++)
197
+ for (size_t SequenceIndex = 0 ; SequenceIndex < m_kcIFPSequences ; SequenceIndex++)
231
198
{
232
199
std::string BoneName = BoneNames[SequenceIndex];
233
200
DWORD BoneID = BoneIds[SequenceIndex];
@@ -304,7 +271,7 @@ void CClientIFP::ReadIFPVersion1 ( )
304
271
pAnimHierarchy->m_nAnimBlockId = 0;
305
272
pAnimHierarchy->field_B = 0;
306
273
307
- const unsigned short TotalSequences = cIFPSequences + pAnimHierarchy->m_nSeqCount;
274
+ const unsigned short TotalSequences = m_kcIFPSequences + pAnimHierarchy->m_nSeqCount;
308
275
ifpAnimation.pSequencesMemory = ( char * ) operator new ( 12 * TotalSequences + 4 ); // Allocate memory for sequences ( 12 * seq_count + 4 )
309
276
310
277
pAnimHierarchy->m_pSequences = ( _CAnimBlendSequence * )( ifpAnimation.pSequencesMemory+ 4 );
@@ -363,7 +330,7 @@ void CClientIFP::ReadIFPVersion1 ( )
363
330
_CAnimBlendSequence * pUnkownSequence = nullptr;
364
331
if (bUnknownSequence)
365
332
{
366
- size_t UnkownSequenceIndex = cIFPSequences + wUnknownSequences;
333
+ size_t UnkownSequenceIndex = m_kcIFPSequences + wUnknownSequences;
367
334
pUnkownSequence = (_CAnimBlendSequence*)((BYTE*)pAnimHierarchy->m_pSequences + (sizeof(_CAnimBlendSequence) * UnkownSequenceIndex));
368
335
369
336
_CAnimBlendSequence_Constructor ( pUnkownSequence );
@@ -394,11 +361,11 @@ void CClientIFP::ReadIFPVersion1 ( )
394
361
bool bIsRoot = FrameType != IFP_FrameType::KR00;
395
362
if (bUnknownSequence)
396
363
{
397
- OLD__CAnimBlendSequence_SetNumFrames ( pUnkownSequence, Anim.Frames, bIsRoot, pAnimHierarchy->m_bRunningCompressed , pKeyFrames );
364
+ OLD__CAnimBlendSequence_SetNumFrames ( pUnkownSequence, Anim.Frames, bIsRoot, m_kbAllKeyFramesCompressed , pKeyFrames );
398
365
}
399
366
else
400
367
{
401
- OLD__CAnimBlendSequence_SetNumFrames ( &Sequence, Anim.Frames, bIsRoot, pAnimHierarchy->m_bRunningCompressed , pKeyFrames );
368
+ OLD__CAnimBlendSequence_SetNumFrames ( &Sequence, Anim.Frames, bIsRoot, m_kbAllKeyFramesCompressed , pKeyFrames );
402
369
}
403
370
404
371
if (FrameType == IFP_FrameType::KRTS)
@@ -426,7 +393,7 @@ void CClientIFP::ReadIFPVersion1 ( )
426
393
}
427
394
428
395
std::map < std::string, _CAnimBlendSequence >::iterator it;
429
- for (size_t SequenceIndex = 0; SequenceIndex < cIFPSequences ; SequenceIndex++)
396
+ for (size_t SequenceIndex = 0; SequenceIndex < m_kcIFPSequences ; SequenceIndex++)
430
397
{
431
398
std::string BoneName = BoneNames[SequenceIndex];
432
399
DWORD BoneID = BoneIds[SequenceIndex];
@@ -446,10 +413,10 @@ void CClientIFP::ReadIFPVersion1 ( )
446
413
}
447
414
}
448
415
449
- *(DWORD *)ifpAnimation.pSequencesMemory = cIFPSequences + wUnknownSequences;
416
+ *(DWORD *)ifpAnimation.pSequencesMemory = m_kcIFPSequences + wUnknownSequences;
450
417
451
418
// This order is very important. As we need support for all 32 bones, we must change the total sequences count
452
- pAnimHierarchy->m_nSeqCount = cIFPSequences + wUnknownSequences;
419
+ pAnimHierarchy->m_nSeqCount = m_kcIFPSequences + wUnknownSequences;
453
420
454
421
//ofs << std::endl << std::endl;
455
422
@@ -463,6 +430,38 @@ void CClientIFP::ReadIFPVersion1 ( )
463
430
}
464
431
465
432
433
+ void CClientIFP::ReadKeyFramesAsCompressed ( IFP_FrameType iFrameType, BYTE * pKeyFrames, int32_t iFrames )
434
+ {
435
+ switch ( iFrameType )
436
+ {
437
+ case IFP_FrameType::KRTS:
438
+ {
439
+ ReadKrtsFramesAsCompressed ( pKeyFrames, iFrames );
440
+ break ;
441
+ }
442
+ case IFP_FrameType::KRT0:
443
+ {
444
+ ReadKrt0FramesAsCompressed ( pKeyFrames, iFrames );
445
+ break ;
446
+ }
447
+ case IFP_FrameType::KR00:
448
+ {
449
+ ReadKr00FramesAsCompressed ( pKeyFrames, iFrames );
450
+ break ;
451
+ }
452
+ case IFP_FrameType::KR00_COMPRESSED:
453
+ {
454
+ ReadKr00CompressedFrames ( pKeyFrames, iFrames );
455
+ break ;
456
+ }
457
+ case IFP_FrameType::KRT0_COMPRESSED:
458
+ {
459
+ ReadKrt0CompressedFrames ( pKeyFrames, iFrames );
460
+ break ;
461
+ }
462
+ }
463
+ }
464
+
466
465
void CClientIFP::ReadKrtsFramesAsCompressed ( BYTE * pKeyFrames, int32_t TotalFrames )
467
466
{
468
467
for (int32_t FrameIndex = 0 ; FrameIndex < TotalFrames; FrameIndex++)
@@ -526,20 +525,42 @@ void CClientIFP::ReadKr00FramesAsCompressed ( BYTE * pKeyFrames, int32_t TotalF
526
525
}
527
526
}
528
527
528
+ void CClientIFP::ReadKr00CompressedFrames ( BYTE * pKeyFrames, int32_t TotalFrames )
529
+ {
530
+ size_t iSizeInBytes = sizeof ( IFP_Compressed_KR00 ) * TotalFrames;
531
+ readBytes ( pKeyFrames, iSizeInBytes );
532
+ }
529
533
530
- size_t CClientIFP::GetSizeOfCompressedFrame ( IFP_FrameType FrameType )
534
+ void CClientIFP::ReadKrt0CompressedFrames ( BYTE * pKeyFrames, int32_t TotalFrames )
531
535
{
532
- if (FrameType == IFP_FrameType::KRTS)
533
- {
534
- return sizeof (IFP_Compressed_KRT0);
535
- }
536
- else if (FrameType == IFP_FrameType::KRT0)
537
- {
538
- return sizeof (IFP_Compressed_KRT0);
539
- }
540
- else if (FrameType == IFP_FrameType::KR00)
541
- {
542
- return sizeof (IFP_Compressed_KR00);
536
+ size_t iSizeInBytes = sizeof ( IFP_Compressed_KRT0 ) * TotalFrames;
537
+ readBytes ( pKeyFrames, iSizeInBytes );
538
+ }
539
+
540
+ size_t CClientIFP::GetSizeOfCompressedFrame ( IFP_FrameType iFrameType )
541
+ {
542
+ switch ( iFrameType )
543
+ {
544
+ case IFP_FrameType::KRTS:
545
+ {
546
+ return sizeof ( IFP_Compressed_KRT0 );
547
+ }
548
+ case IFP_FrameType::KRT0:
549
+ {
550
+ return sizeof ( IFP_Compressed_KRT0 );
551
+ }
552
+ case IFP_FrameType::KR00:
553
+ {
554
+ return sizeof ( IFP_Compressed_KR00 );
555
+ }
556
+ case IFP_FrameType::KR00_COMPRESSED:
557
+ {
558
+ return sizeof ( IFP_Compressed_KR00 );
559
+ }
560
+ case IFP_FrameType::KRT0_COMPRESSED:
561
+ {
562
+ return sizeof ( IFP_Compressed_KRT0 );
563
+ }
543
564
}
544
565
return 0 ;
545
566
}
@@ -1077,6 +1098,22 @@ constexpr void CClientIFP::RoundSize ( uint32_t & u32Size )
1077
1098
}
1078
1099
}
1079
1100
1101
+ constexpr bool CClientIFP::isKeyFramesTypeRoot ( IFP_FrameType iFrameType )
1102
+ {
1103
+ switch ( iFrameType )
1104
+ {
1105
+ case IFP_FrameType::KR00:
1106
+ {
1107
+ return false ;
1108
+ }
1109
+ case IFP_FrameType::KR00_COMPRESSED:
1110
+ {
1111
+ return false ;
1112
+ }
1113
+ }
1114
+ return true ;
1115
+ }
1116
+
1080
1117
void CClientIFP::ParseSequenceObject ( Object & ObjectNode, std::string & CorrectBoneName )
1081
1118
{
1082
1119
std::string BoneName = convertStringToMapKey ( ObjectNode.Name );
0 commit comments