@@ -9,6 +9,7 @@ CClientIFP::CClientIFP ( class CClientManager* pManager, ElementID ID ) : CClien
9
9
m_pIFPAnimations = std::make_shared < CIFPAnimations > ();
10
10
m_pAnimManager = g_pGame->GetAnimManager ( );
11
11
m_bVersion1 = false ;
12
+ m_u32Hashkey = 0 ;
12
13
}
13
14
14
15
CClientIFP::~CClientIFP ( void )
@@ -24,6 +25,7 @@ bool CClientIFP::LoadIFP ( const char* szFilePath, const SString & strBlockName
24
25
25
26
if ( LoadIFPFile ( szFilePath ) )
26
27
{
28
+ m_u32Hashkey = g_pGame->GetKeyGen ()->GetUppercaseKey ( strBlockName );
27
29
return true ;
28
30
}
29
31
return false ;
@@ -246,7 +248,6 @@ void CClientIFP::ReadSequenceVersion2 ( Object & ObjectNode )
246
248
if ( strCorrectBoneName.size ( ) == 0 )
247
249
{
248
250
strCorrectBoneName = GetCorrectBoneNameFromName ( BoneName );
249
- printf (" yes, size is zero\n " );
250
251
}
251
252
}
252
253
@@ -260,7 +261,7 @@ bool CClientIFP::ReadSequenceKeyFrames ( std::unique_ptr < CAnimBlendSequence >
260
261
{
261
262
BYTE * pKeyFrames = m_pAnimManager->AllocateKeyFramesMemory ( iCompressedFrameSize * iFrames );
262
263
pAnimationSequence->SetKeyFrames ( iFrames, IsKeyFramesTypeRoot ( iFrameType ), m_kbAllKeyFramesCompressed, pKeyFrames );
263
- ReadKeyFramesAsCompressed ( iFrameType, pKeyFrames , iFrames );
264
+ ReadKeyFramesAsCompressed ( pAnimationSequence, iFrameType , iFrames );
264
265
return true ;
265
266
}
266
267
return false ;
@@ -313,112 +314,97 @@ void CClientIFP::ReadAnimationHeaderVersion2 ( Animation & AnimationNode, bool b
313
314
}
314
315
}
315
316
316
- void CClientIFP::ReadKeyFramesAsCompressed ( IFP_FrameType iFrameType, BYTE * pKeyFrames , int32_t iFrames )
317
+ void CClientIFP::ReadKeyFramesAsCompressed ( std::unique_ptr < CAnimBlendSequence > & pAnimationSequence, IFP_FrameType iFrameType , int32_t iFrames )
317
318
{
318
319
switch ( iFrameType )
319
320
{
320
321
case IFP_FrameType::KRTS:
321
322
{
322
- ReadKrtsFramesAsCompressed ( pKeyFrames , iFrames );
323
+ ReadKrtsFramesAsCompressed ( pAnimationSequence , iFrames );
323
324
break ;
324
325
}
325
326
case IFP_FrameType::KRT0:
326
327
{
327
- ReadKrt0FramesAsCompressed ( pKeyFrames , iFrames );
328
+ ReadKrt0FramesAsCompressed ( pAnimationSequence , iFrames );
328
329
break ;
329
330
}
330
331
case IFP_FrameType::KR00:
331
332
{
332
- ReadKr00FramesAsCompressed ( pKeyFrames , iFrames );
333
+ ReadKr00FramesAsCompressed ( pAnimationSequence , iFrames );
333
334
break ;
334
335
}
335
336
case IFP_FrameType::KR00_COMPRESSED:
336
337
{
337
- ReadKr00CompressedFrames ( pKeyFrames , iFrames );
338
+ ReadCompressedFrames < IFP_Compressed_KR00 > ( pAnimationSequence , iFrames );
338
339
break ;
339
340
}
340
341
case IFP_FrameType::KRT0_COMPRESSED:
341
342
{
342
- ReadKrt0CompressedFrames ( pKeyFrames , iFrames );
343
+ ReadCompressedFrames < IFP_Compressed_KRT0 > ( pAnimationSequence , iFrames );
343
344
break ;
344
345
}
345
346
}
346
347
}
347
348
348
- void CClientIFP::ReadKrtsFramesAsCompressed ( BYTE * pKeyFrames , int32_t TotalFrames )
349
+ void CClientIFP::ReadKrtsFramesAsCompressed ( std::unique_ptr < CAnimBlendSequence > & pAnimationSequence , int32_t TotalFrames )
349
350
{
350
- for (int32_t FrameIndex = 0 ; FrameIndex < TotalFrames; FrameIndex++)
351
+ for ( int32_t FrameIndex = 0 ; FrameIndex < TotalFrames; FrameIndex++ )
351
352
{
352
- IFP_Compressed_KRT0 * CompressedKrt0 = (IFP_Compressed_KRT0 *)((BYTE*)pKeyFrames + sizeof (IFP_Compressed_KRT0) * FrameIndex);
353
-
353
+ IFP_Compressed_KRT0 * CompressedKrt0 = static_cast < IFP_Compressed_KRT0 * > ( pAnimationSequence->GetKeyFrame ( FrameIndex, sizeof ( IFP_Compressed_KRT0 ) ) );
354
354
IFP_KRTS Krts;
355
- ReadBuffer < IFP_KRTS >( &Krts);
355
+ ReadBuffer < IFP_KRTS > ( &Krts );
356
356
357
- CompressedKrt0->Rotation .X = static_cast < int16_t > ( (( -Krts.Rotation .X ) * 4096 .0f ) );
358
- CompressedKrt0->Rotation .Y = static_cast < int16_t > ( (( -Krts.Rotation .Y ) * 4096 .0f ) );
359
- CompressedKrt0->Rotation .Z = static_cast < int16_t > ( (( -Krts.Rotation .Z ) * 4096 .0f ) );
360
- CompressedKrt0->Rotation .W = static_cast < int16_t > ( (Krts.Rotation .W * 4096 .0f ) );
357
+ CompressedKrt0->Rotation .X = static_cast < int16_t > ( ( ( -Krts.Rotation .X ) * 4096 .0f ) );
358
+ CompressedKrt0->Rotation .Y = static_cast < int16_t > ( ( ( -Krts.Rotation .Y ) * 4096 .0f ) );
359
+ CompressedKrt0->Rotation .Z = static_cast < int16_t > ( ( ( -Krts.Rotation .Z ) * 4096 .0f ) );
360
+ CompressedKrt0->Rotation .W = static_cast < int16_t > ( ( Krts.Rotation .W * 4096 .0f ) );
361
361
362
- CompressedKrt0->Time = static_cast < int16_t > ( (Krts.Time * 60 .0f + 0 .5f ) );
362
+ CompressedKrt0->Time = static_cast < int16_t > ( ( Krts.Time * 60 .0f + 0 .5f ) );
363
363
364
- CompressedKrt0->Translation .X = static_cast < int16_t > ( (Krts.Translation .X * 1024 .0f ) );
365
- CompressedKrt0->Translation .Y = static_cast < int16_t > ( (Krts.Translation .Y * 1024 .0f ) );
366
- CompressedKrt0->Translation .Z = static_cast < int16_t > ( (Krts.Translation .Z * 1024 .0f ) );
364
+ CompressedKrt0->Translation .X = static_cast < int16_t > ( ( Krts.Translation .X * 1024 .0f ) );
365
+ CompressedKrt0->Translation .Y = static_cast < int16_t > ( ( Krts.Translation .Y * 1024 .0f ) );
366
+ CompressedKrt0->Translation .Z = static_cast < int16_t > ( ( Krts.Translation .Z * 1024 .0f ) );
367
367
}
368
368
}
369
369
370
- void CClientIFP::ReadKrt0FramesAsCompressed ( BYTE * pKeyFrames , int32_t TotalFrames )
370
+ void CClientIFP::ReadKrt0FramesAsCompressed ( std::unique_ptr < CAnimBlendSequence > & pAnimationSequence , int32_t TotalFrames )
371
371
{
372
- for (int32_t FrameIndex = 0 ; FrameIndex < TotalFrames; FrameIndex++)
372
+ for ( int32_t FrameIndex = 0 ; FrameIndex < TotalFrames; FrameIndex++ )
373
373
{
374
- IFP_Compressed_KRT0 * CompressedKrt0 = (IFP_Compressed_KRT0 *)((BYTE*)pKeyFrames + sizeof (IFP_Compressed_KRT0) * FrameIndex);
375
-
374
+ IFP_Compressed_KRT0 * CompressedKrt0 = static_cast < IFP_Compressed_KRT0 * > ( pAnimationSequence->GetKeyFrame ( FrameIndex, sizeof ( IFP_Compressed_KRT0 ) ) );
376
375
IFP_KRT0 Krt0;
377
376
ReadBuffer < IFP_KRT0 > ( &Krt0 );
378
377
379
- CompressedKrt0->Rotation .X = static_cast < int16_t > ( (( -Krt0.Rotation .X ) * 4096 .0f ) );
380
- CompressedKrt0->Rotation .Y = static_cast < int16_t > ( (( -Krt0.Rotation .Y ) * 4096 .0f ) );
381
- CompressedKrt0->Rotation .Z = static_cast < int16_t > ( (( -Krt0.Rotation .Z ) * 4096 .0f ) );
382
- CompressedKrt0->Rotation .W = static_cast < int16_t > ( (Krt0.Rotation .W * 4096 .0f ) );
378
+ CompressedKrt0->Rotation .X = static_cast < int16_t > ( ( ( -Krt0.Rotation .X ) * 4096 .0f ) );
379
+ CompressedKrt0->Rotation .Y = static_cast < int16_t > ( ( ( -Krt0.Rotation .Y ) * 4096 .0f ) );
380
+ CompressedKrt0->Rotation .Z = static_cast < int16_t > ( ( ( -Krt0.Rotation .Z ) * 4096 .0f ) );
381
+ CompressedKrt0->Rotation .W = static_cast < int16_t > ( ( Krt0.Rotation .W * 4096 .0f ) );
383
382
384
- CompressedKrt0->Time = static_cast < int16_t > ( (Krt0.Time * 60 .0f + 0 .5f ) );
383
+ CompressedKrt0->Time = static_cast < int16_t > ( ( Krt0.Time * 60 .0f + 0 .5f ) );
385
384
386
- CompressedKrt0->Translation .X = static_cast < int16_t > ( (Krt0.Translation .X * 1024 .0f ) );
387
- CompressedKrt0->Translation .Y = static_cast < int16_t > ( (Krt0.Translation .Y * 1024 .0f ) );
388
- CompressedKrt0->Translation .Z = static_cast < int16_t > ( (Krt0.Translation .Z * 1024 .0f ) );
385
+ CompressedKrt0->Translation .X = static_cast < int16_t > ( ( Krt0.Translation .X * 1024 .0f ) );
386
+ CompressedKrt0->Translation .Y = static_cast < int16_t > ( ( Krt0.Translation .Y * 1024 .0f ) );
387
+ CompressedKrt0->Translation .Z = static_cast < int16_t > ( ( Krt0.Translation .Z * 1024 .0f ) );
389
388
}
390
389
}
391
390
392
- void CClientIFP::ReadKr00FramesAsCompressed ( BYTE * pKeyFrames , int32_t TotalFrames )
391
+ void CClientIFP::ReadKr00FramesAsCompressed ( std::unique_ptr < CAnimBlendSequence > & pAnimationSequence , int32_t TotalFrames )
393
392
{
394
- for (int32_t FrameIndex = 0 ; FrameIndex < TotalFrames; FrameIndex++)
393
+ for ( int32_t FrameIndex = 0 ; FrameIndex < TotalFrames; FrameIndex++ )
395
394
{
396
- IFP_Compressed_KR00 * CompressedKr00 = (IFP_Compressed_KR00 *)((BYTE*)pKeyFrames + sizeof (IFP_Compressed_KR00) * FrameIndex);
397
-
395
+ IFP_Compressed_KR00 * CompressedKr00 = static_cast < IFP_Compressed_KR00 * > ( pAnimationSequence->GetKeyFrame ( FrameIndex, sizeof ( IFP_Compressed_KR00 ) ) );
398
396
IFP_KR00 Kr00;
399
397
ReadBuffer < IFP_KR00 > ( &Kr00 );
400
398
401
- CompressedKr00->Rotation .X = static_cast < int16_t > ( (( -Kr00.Rotation .X ) * 4096 .0f ) );
402
- CompressedKr00->Rotation .Y = static_cast < int16_t > ( (( -Kr00.Rotation .Y ) * 4096 .0f ) );
403
- CompressedKr00->Rotation .Z = static_cast < int16_t > ( (( -Kr00.Rotation .Z ) * 4096 .0f ) );
404
- CompressedKr00->Rotation .W = static_cast < int16_t > ( (Kr00.Rotation .W * 4096 .0f ) );
399
+ CompressedKr00->Rotation .X = static_cast < int16_t > ( ( ( -Kr00.Rotation .X ) * 4096 .0f ) );
400
+ CompressedKr00->Rotation .Y = static_cast < int16_t > ( ( ( -Kr00.Rotation .Y ) * 4096 .0f ) );
401
+ CompressedKr00->Rotation .Z = static_cast < int16_t > ( ( ( -Kr00.Rotation .Z ) * 4096 .0f ) );
402
+ CompressedKr00->Rotation .W = static_cast < int16_t > ( ( Kr00.Rotation .W * 4096 .0f ) );
405
403
406
404
CompressedKr00->Time = static_cast < int16_t > ( (Kr00.Time * 60 .0f + 0 .5f ) );
407
405
}
408
406
}
409
407
410
- inline void CClientIFP::ReadKr00CompressedFrames ( BYTE * pKeyFrames, int32_t TotalFrames )
411
- {
412
- size_t iSizeInBytes = sizeof ( IFP_Compressed_KR00 ) * TotalFrames;
413
- ReadBytes ( pKeyFrames, iSizeInBytes );
414
- }
415
-
416
- inline void CClientIFP::ReadKrt0CompressedFrames ( BYTE * pKeyFrames, int32_t TotalFrames )
417
- {
418
- size_t iSizeInBytes = sizeof ( IFP_Compressed_KRT0 ) * TotalFrames;
419
- ReadBytes ( pKeyFrames, iSizeInBytes );
420
- }
421
-
422
408
size_t CClientIFP::GetSizeOfCompressedFrame ( IFP_FrameType iFrameType )
423
409
{
424
410
switch ( iFrameType )
0 commit comments