OpenBarnyard
 
Loading...
Searching...
No Matches
AToshiAnimationInterface.cpp
Go to the documentation of this file.
1#include "pch.h"
4
5//-----------------------------------------------------------------------------
6// Enables memory debugging.
7// Note: Should be the last include!
8//-----------------------------------------------------------------------------
10
12
13// $Barnyard: FUNCTION 00582690
14static AToshiAnimationRef* GetAnimationRef( T2DList<AToshiAnimationRef>& a_rList, const TPString8& a_strAnimationName )
15{
16 T2_FOREACH( a_rList, it )
17 {
18 if ( it->GetNamedAnimation()->GetName() == a_strAnimationName )
19 return it;
20 }
21
22 return TNULL;
23}
24
25// $Barnyard: FUNCTION 00582730
26static TBOOL GetAnimationTransition( T2DList<AToshiAnimationRef>& a_rList, const TPString8& a_strAnimationName, AToshiAnimationRef*& a_rpAnimRef, ANamedAnimationTransition*& a_rpTransition )
27{
28 T2_FOREACH( a_rList, it )
29 {
30 ANamedAnimationTransition* pTransition = it->GetNamedAnimation()->GetTransitionSet().FindTransition( a_strAnimationName );
31
32 if ( pTransition )
33 {
34 a_rpAnimRef = it;
35 a_rpTransition = pTransition;
36 return TTRUE;
37 }
38 }
39
40 return TFALSE;
41}
42
43// $Barnyard: FUNCTION 00583360
45 : m_pSkeletonInstance( TNULL )
46 , m_fTime( 0.0f )
47 , m_Unk2( 0 )
48 , m_eFlags( 0 )
49{
50}
51
52// $Barnyard: FUNCTION 00583390
54{
55 DestroyAnimReferences();
56}
57
58// $Barnyard: FUNCTION 00583440
59void AToshiAnimationInterface::Update( TFLOAT a_fDeltaTime, AnimEventList& a_rEventList )
60{
61 TFLOAT fOldTime = m_fTime;
62 m_fTime += a_fDeltaTime;
63
64 UpdateAnimations( m_llAnimRefs, a_fDeltaTime, a_rEventList );
65 UpdateAnimations( m_llOverlayAnimRefs, a_fDeltaTime, a_rEventList );
66
67 if ( fOldTime == 0.0f || m_fTime == 0.0f )
68 {
69 // Some animation has just started playing, update flags
70
71 if ( IsAllStatic() )
72 m_eFlags |= 1;
73 else
74 m_eFlags &= ~1;
75 }
76}
77
78// $Barnyard: FUNCTION 00583780
79AToshiAnimationRef* AToshiAnimationInterface::PlayAnim( const TPString8& a_strName, TFLOAT a_fWeight, TBOOL a_bStartNewAnimation )
80{
81 // Check if this animation is not already playing
82 AToshiAnimationRef* pAnimRef = FindAnimationRef( a_strName );
83 pAnimRef = FindAnimationRef( a_strName ); // ???
84
85 if ( pAnimRef )
86 {
87 // Get internal (exported) name of the playing animation
88 TPString8 strPlayingName = pAnimRef->GetNamedAnimation()->GetExportedName();
89 ANamedAnimation* pNamedAnimation = GetAnimationSet()->GetNamedAnimation( a_strName );
90 TVALIDPTR( pNamedAnimation );
91
92 TPString8 strAnimationName = pNamedAnimation->GetExportedName();
93
94 if ( strAnimationName == strPlayingName )
95 {
96 // This animation is already playing
97 return pAnimRef;
98 }
99 }
100
101 // Get info about the animation and play it
102 ANamedAnimation* pNamedAnimation = GetAnimationSet()->GetNamedAnimation( a_strName );
103 TVALIDPTR( pNamedAnimation );
104
105 // Adjust playing parameters
106 TFLOAT fWeight = ( a_fWeight < 0.0f ) ? pNamedAnimation->GetDefaultWeight() : a_fWeight;
107
108 // Create overlay animation
109 if ( pNamedAnimation->IsOverlay() )
110 return CreateOverlayAnimationRef( pNamedAnimation, fWeight );
111
112 // Create new animation if there are no other animations
113 if ( m_llAnimRefs.IsEmpty() || m_llAnimRefs.Begin() == TNULL )
114 return CreateAnimationRef( m_llAnimRefs, pNamedAnimation, fWeight, TNULL );
115
116 // Create new animation if client asked
117 if ( a_bStartNewAnimation )
118 return CreateAnimationRef( m_llAnimRefs, pNamedAnimation, fWeight, TNULL );
119
120 // Client didn't require starting new animation and some animations are already playing...
121 ANamedAnimationTransition* pTransition;
122 TBOOL bHasTransition = GetAnimationTransition( m_llAnimRefs, a_strName, pAnimRef, pTransition );
123
124 if ( bHasTransition )
125 {
126 // Transition of this animation already exists
127 SetAnimationTransition( *pAnimRef, pTransition );
128 pAnimRef->SetWeight( fWeight );
129
130 StopAnim( *pAnimRef );
131 return TNULL;
132 }
133
134 // There's currently no transition of this animation
135 pAnimRef = m_llAnimRefs.Head();
136 ANamedAnimation* pCurrentAnimation = pAnimRef->GetNamedAnimation();
137
138 // Set transition settings
139 m_oAnimTransition.SetManaged( !pCurrentAnimation->IsFinishManual() );
140 m_oAnimTransition.SetBlendInTime( pNamedAnimation->GetDefaultBlendInTime() );
141 m_oAnimTransition.SetBlendOutTime( pCurrentAnimation->GetDefaultBlendOutTime() );
142 m_oAnimTransition.SetAnimationName( pNamedAnimation->GetName() );
143 SetAnimationTransition( *pAnimRef, &m_oAnimTransition );
144
145 pAnimRef->SetWeight( fWeight );
146 StopAnim( *pAnimRef );
147
148 return TNULL;
149}
150
151// $Barnyard: FUNCTION 00582d30
152TAnimation* AToshiAnimationInterface::PlayAnimImpl( ANamedAnimation* a_pNamedAnimation, TFLOAT a_fWeight, ANamedAnimationTransition* a_pTransition, AToshiAnimationRef& a_rAnimationRef )
153{
154 TVALIDPTR( a_pNamedAnimation );
155
156 m_fTime = 0.0f;
157
158 TFLOAT fBlendInTime = ( a_pTransition ) ? a_pTransition->GetBlendInTime() : a_pNamedAnimation->GetDefaultBlendInTime();
159 TFLOAT fBlendOutTime = a_pNamedAnimation->GetDefaultBlendOutTime();
160
161 ANamedAnimationTransition* pDestTransition = a_pNamedAnimation->GetTransitionSet().GetDestTransition();
162 if ( pDestTransition ) fBlendOutTime = pDestTransition->GetBlendOutTime();
163
164 TAnimation* pAnimation = m_pSkeletonInstance->AddAnimation( a_pNamedAnimation->GetSequenceId(), a_fWeight, fBlendInTime );
165 TVALIDPTR( pAnimation );
166
167 pAnimation->SetBlendOutSpeed( fBlendOutTime );
168 pAnimation->SetSpeed( a_pNamedAnimation->GetSpeed() * ( ( a_pNamedAnimation->IsReversed() ) ? -1.0f : 1.0f ) );
169
170 if ( !a_pNamedAnimation->IsLooped() )
171 pAnimation->ChangeToManaged( pAnimation->GetBlendOutSpeed() );
172
173 a_rAnimationRef.m_pNamedAnimation = a_pNamedAnimation;
174 a_rAnimationRef.m_pTransition = TNULL;
175 a_rAnimationRef.m_bWasEverUpdated = TFALSE;
176 a_rAnimationRef.m_iBreakpointIndex = 0;
177 a_rAnimationRef.m_fWeight = a_fWeight;
178
179 return pAnimation;
180}
181
182// $Barnyard: FUNCTION 00583080
183void AToshiAnimationInterface::UpdateAnimations( Toshi::T2DList<AToshiAnimationRef>& a_rList, TFLOAT a_fDeltaTime, AnimEventList& a_rEventList )
184{
185 auto it = a_rList.Begin();
186
187 while ( TTRUE )
188 {
189 // Look for an animation that is about to end/is already over
190 while ( TTRUE )
191 {
192 if ( it == a_rList.End() ) return;
193
194 TAnimation* pAnimation = ( !it->GetNamedAnimation() ) ? TNULL : m_pSkeletonInstance->GetAnimation( it->GetNamedAnimation()->GetSequenceId() );
195 UpdateAnimation( a_fDeltaTime, *it, pAnimation, a_rEventList );
196
197 // Has this animation ended?
198 if ( !pAnimation || pAnimation->GetState() == TAnimation::STATE_BLENDING_OUT )
199 break;
200
201 // It hasn't ended, go for a next one
202 ++it;
203 }
204
205 // Found an animation that is over
206 m_fTime = 0.0f;
207
208 AToshiAnimationRef* pAnimRef = it;
209 ANamedAnimation* pNamedAnimation = pAnimRef->GetNamedAnimation();
210 TVALIDPTR( pNamedAnimation );
211
212 // Create the event object
213 AnimEvent& animEvent = a_rEventList.Push();
214 animEvent.SetSimpleEvent( ANIMEVENT_TYPE_END, pNamedAnimation->IsOverlay(), pNamedAnimation->GetName(), 0.0f );
215
216 // Start transition if any is set
217 if ( pNamedAnimation )
218 {
219 ANamedAnimationTransition* pTransition = pAnimRef->GetTransition();
220
221 // If no transition is set to this animref, use default transition specified for this animation
222 if ( !pTransition )
223 pTransition = pAnimRef->GetNamedAnimation()->GetTransitionSet().GetDestTransition();
224
225 if ( pTransition )
226 {
227 ANamedAnimation* pTransitionAnimation = m_pAnimationSet->GetNamedAnimation( pTransition->GetAnimationName() );
228 TVALIDPTR( pTransitionAnimation );
229
230 if ( !( pTransitionAnimation->GetFlags() & ANamedAnimation::FLAGS_NO_ANIM_REF ) )
231 {
232 // Do the transition
233 AToshiAnimationRef* pAnimRef = g_oAnimationRefPool.NewObject();
234 TAnimation* pAnimation = PlayAnimImpl( pTransitionAnimation, pAnimRef->m_fWeight, pTransition, *pAnimRef );
235 pAnimation->UpdateTime( a_fDeltaTime );
236 a_rList.PushBack( pAnimRef );
237 }
238 }
239 }
240
241 // Destroy this animation and remove it from the list
242 it = a_rList.Erase( it );
243 g_oAnimationRefPool.DeleteObject( pAnimRef );
244 }
245}
246
247// $Barnyard: FUNCTION 005827a0
248void AToshiAnimationInterface::UpdateAnimation( TFLOAT a_fDeltaTime, AToshiAnimationRef& a_rAnimRef, Toshi::TAnimation* a_pAnimation, AnimEventList& a_rEventList )
249{
250 ANamedAnimation* pNamedAnimation = a_rAnimRef.GetNamedAnimation();
251 TVALIDPTR( pNamedAnimation );
252
253 if ( !a_rAnimRef.m_bWasEverUpdated )
254 {
255 // Create initial ANIMEVENT_TYPE_STARTED event for this animation since it's the first time updating it
256
257 AnimEvent& animEvent = a_rEventList.Push();
258 animEvent.SetSimpleEvent( ANIMEVENT_TYPE_START, pNamedAnimation->IsOverlay(), pNamedAnimation->GetName(), 0.0f );
259
260 a_rAnimRef.m_bWasEverUpdated = TTRUE;
261 }
262
263 // Don't want to update animations with zero progression
264 if ( a_pAnimation && a_pAnimation->GetSpeed() == 0.0f )
265 return;
266
267 // Update breakpoints information
268 TBOOL bIsReverse = ( a_pAnimation != TNULL && a_pAnimation->GetSpeed() < 0.0f );
269
270 if ( !bIsReverse )
271 {
272 // Normal playing
273 UpdateAnimationBreakpoints( a_rAnimRef, a_pAnimation, a_rEventList );
274 }
275 else
276 {
277 // Reverse playing
278 UpdateAnimationBreakpointsReverse( a_rAnimRef, a_pAnimation, a_rEventList );
279 }
280}
281
282void AToshiAnimationInterface::UpdateAnimationBreakpoints( AToshiAnimationRef& a_rAnimRef, Toshi::TAnimation* a_pAnimation, AnimEventList& a_rEventList )
283{
284 ANamedAnimation* pNamedAnimation = a_rAnimRef.GetNamedAnimation();
285 TVALIDPTR( pNamedAnimation );
286
287 TINT iCurrentBreakpoint = a_rAnimRef.m_iBreakpointIndex;
288 TINT iNumBreakpoints = pNamedAnimation->GetBreakpoints().Size();
289 TAnimation* pAnimation = m_pSkeletonInstance->GetAnimation( pNamedAnimation->GetSequenceId() );
290
291 // Reset breakpoint index if necessary
292 if ( pAnimation && pAnimation->IsManaged() && a_rAnimRef.m_iBreakpointIndex >= iNumBreakpoints )
293 a_rAnimRef.m_iBreakpointIndex = 0;
294
295 TFLOAT fCurrentAnimTime = ( !a_pAnimation ) ? pNamedAnimation->GetDuration() : a_pAnimation->GetSeqTime();
296 TFLOAT fPreviousAnimTime = a_rAnimRef.m_fTime;
297
298 if ( iCurrentBreakpoint < iNumBreakpoints || ( pAnimation && pAnimation->IsManaged() ) )
299 {
300 TFLOAT fAnimDeltaTime = fCurrentAnimTime - fPreviousAnimTime;
301
302 // Normalize time if the animation restarted
303 if ( fAnimDeltaTime < 0.0f )
304 fAnimDeltaTime += pNamedAnimation->GetDuration();
305
306 for ( TINT i = 0; iCurrentBreakpoint < iNumBreakpoints && i < iNumBreakpoints && ( !pAnimation || pAnimation->IsManaged() ); i++ )
307 {
308 AAnimationBreakpoint* pBreakpoint = pNamedAnimation->GetBreakpoints()[ iCurrentBreakpoint ];
309 TFLOAT fTimeToBreakpoint = fCurrentAnimTime - pBreakpoint->GetTime();
310
311 if ( a_pAnimation && fTimeToBreakpoint < 0.0f )
312 {
313 // If animation didn't start from the beginning, or we already fetched this breakpoint, skip...
314 if ( !pAnimation || !pAnimation->IsManaged() || fCurrentAnimTime >= fPreviousAnimTime || fPreviousAnimTime >= pBreakpoint->GetTime() )
315 break;
316
317 // The animation did start from the beginning, so need to normalize the time value
318 fTimeToBreakpoint += pNamedAnimation->GetDuration();
319 }
320
321 // If we already activated that breakpoint before, skip...
322 if ( fAnimDeltaTime < fTimeToBreakpoint )
323 break;
324
325 // Create the event object
326 AnimEvent& animEvent = a_rEventList.Push();
327 animEvent.SetBreakpointEvent( pBreakpoint, pNamedAnimation->IsOverlay(), pNamedAnimation->GetName(), TMath::Max( fTimeToBreakpoint, 0.0f ) );
328
329 iCurrentBreakpoint++;
330 if ( iCurrentBreakpoint >= iNumBreakpoints )
331 {
332 iCurrentBreakpoint = 0;
333
334 if ( fPreviousAnimTime < fCurrentAnimTime )
335 break;
336 }
337 }
338
339 a_rAnimRef.m_iBreakpointIndex = iCurrentBreakpoint;
340 }
341
342 a_rAnimRef.m_fTime = fCurrentAnimTime;
343}
344
345void AToshiAnimationInterface::UpdateAnimationBreakpointsReverse( AToshiAnimationRef& a_rAnimRef, Toshi::TAnimation* a_pAnimation, AnimEventList& a_rEventList )
346{
347 ANamedAnimation* pNamedAnimation = a_rAnimRef.GetNamedAnimation();
348 TVALIDPTR( pNamedAnimation );
349
350 TINT iCurrentBreakpoint = a_rAnimRef.m_iBreakpointIndex;
351 TINT iNumBreakpoints = pNamedAnimation->GetBreakpoints().Size();
352 TAnimation* pAnimation = m_pSkeletonInstance->GetAnimation( pNamedAnimation->GetSequenceId() );
353
354 // Reset breakpoint index if necessary
355 if ( pAnimation && pAnimation->IsManaged() && a_rAnimRef.m_iBreakpointIndex < 0 )
356 a_rAnimRef.m_iBreakpointIndex = iNumBreakpoints - 1;
357
358 TFLOAT fCurrentAnimTime = ( !a_pAnimation ) ? 0.0f : a_pAnimation->GetSeqTime();
359 TFLOAT fPreviousAnimTime = a_rAnimRef.m_fTime;
360
361 if ( iCurrentBreakpoint > 0 || ( pAnimation && pAnimation->IsManaged() ) )
362 {
363 TFLOAT fAnimDeltaTime = fPreviousAnimTime - fCurrentAnimTime;
364 TINT iPrevBreakpoint = iCurrentBreakpoint - 1;
365
366 // Normalize time if the animation restarted
367 if ( fAnimDeltaTime < 0.0f )
368 fAnimDeltaTime += pNamedAnimation->GetDuration();
369
370 TINT iBreakpoint = iPrevBreakpoint;
371 if ( pAnimation && pAnimation->IsManaged() && iPrevBreakpoint <= -1 )
372 {
373 iPrevBreakpoint = iNumBreakpoints - 1;
374 iBreakpoint = iPrevBreakpoint;
375 }
376
377 for ( TINT i = 0; i < iNumBreakpoints && iPrevBreakpoint > -1 || ( pAnimation && pAnimation->IsManaged() ); i++ )
378 {
379 iPrevBreakpoint = iCurrentBreakpoint;
380
381 AAnimationBreakpoint* pBreakpoint = pNamedAnimation->GetBreakpoints()[ iBreakpoint ];
382 TFLOAT fTimeToBreakpoint = pBreakpoint->GetTime() - fCurrentAnimTime;
383
384 if ( pAnimation && fTimeToBreakpoint < 0.0f )
385 {
386 // If animation didn't start from the beginning, or we already fetched this breakpoint, skip...
387 if ( !pAnimation || !pAnimation->IsManaged() || fCurrentAnimTime <= fPreviousAnimTime || fPreviousAnimTime <= pBreakpoint->GetTime() )
388 break;
389
390 // The animation did start from the beginning, so need to normalize the time value
391 fTimeToBreakpoint += pNamedAnimation->GetDuration();
392 }
393
394 // If we already activated that breakpoint before, skip...
395 if ( fAnimDeltaTime < fTimeToBreakpoint )
396 break;
397
398 // Create the event object
399 AnimEvent& animEvent = a_rEventList.Push();
400 animEvent.SetBreakpointEvent( pBreakpoint, pNamedAnimation->IsOverlay(), pNamedAnimation->GetName(), TMath::Max( fTimeToBreakpoint, 0.0f ) );
401
402 iCurrentBreakpoint--;
403
404 if ( pAnimation && pAnimation->IsManaged() )
405 {
406 if ( iCurrentBreakpoint < 0 )
407 iCurrentBreakpoint = iNumBreakpoints - 1;
408
409 if ( iPrevBreakpoint == iNumBreakpoints - 1 && fCurrentAnimTime < fPreviousAnimTime )
410 break;
411 }
412 }
413
414 a_rAnimRef.m_iBreakpointIndex = iCurrentBreakpoint;
415 }
416
417 a_rAnimRef.m_fTime = fCurrentAnimTime;
418}
419
420// $Barnyard: FUNCTION 00582de0
421TBOOL AToshiAnimationInterface::IsAllStatic()
422{
423 if ( m_Unk2 != 0 )
424 return TFALSE;
425
426 T2_FOREACH( m_llAnimRefs, it )
427 {
428 if ( it->GetNamedAnimation() && !it->GetNamedAnimation()->IsStatic() )
429 return TFALSE;
430 }
431
432 T2_FOREACH( m_llOverlayAnimRefs, it )
433 {
434 if ( it->GetNamedAnimation() && !it->GetNamedAnimation()->IsStatic() )
435 return TFALSE;
436 }
437
438 return TTRUE;
439}
440
441// $Barnyard: FUNCTION 00583520
443{
444 ANamedAnimation* pNamedAnimation = a_rcAnimationRef.m_pNamedAnimation;
445 if ( !pNamedAnimation ) return TFALSE;
446
447 TAnimation* pAnimation = m_pSkeletonInstance->GetAnimation( a_rcAnimationRef.GetSequenceId() );
448 if ( !pAnimation ) return TFALSE;
449
450 ANamedAnimationTransition* pTransition = a_rcAnimationRef.m_pTransition;
451
452 if ( !pNamedAnimation || ( !pTransition && ( pTransition = pNamedAnimation->GetTransitionSet().GetDestTransition(), pTransition == TNULL ) ) )
453 {
454 if ( !pNamedAnimation->IsFinishManual() )
455 {
456 pAnimation->ChangeToManaged( pAnimation->GetBlendOutSpeed() );
457 return TTRUE;
458 }
459 }
460 else
461 {
462 if ( pTransition->IsManaged() )
463 {
464 pAnimation->ChangeToManaged( pAnimation->GetBlendOutSpeed() );
465 return TTRUE;
466 }
467
468 // Yeah, that's how this thing is in the original.
469 if ( pTransition->IsManaged() != TFALSE )
470 {
471 return TTRUE;
472 }
473 }
474
475 // It will never get here
476 TASSERT( TFALSE );
477 pAnimation->RemoveAnimation( pAnimation->GetBlendOutSpeed() );
478 return TTRUE;
479}
480
481// $Barnyard: FUNCTION 00582520
483{
484 ANamedAnimation* pNamedAnimation = a_rcAnimationRef.m_pNamedAnimation;
485 if ( !pNamedAnimation ) return TFALSE;
486
487 if ( TAnimation* pAnimation = m_pSkeletonInstance->GetAnimation( a_rcAnimationRef.GetSequenceId() ) )
488 {
489 if ( a_pTransition->IsManaged() )
490 pAnimation->ChangeToManaged( pAnimation->GetBlendOutSpeed() );
491 else
492 pAnimation->RemoveAnimation( pAnimation->GetBlendOutSpeed() );
493
494 return TTRUE;
495 }
496
497 return TFALSE;
498}
499
500// $Barnyard: FUNCTION 005836e0
502{
503 DestroyAnimReferences();
504
505 TVALIDPTR( m_pSkeletonInstance );
506 m_pSkeletonInstance->RemoveAllAnimations();
507}
508
509// $Barnyard: FUNCTION 005835c0
511{
512 a_rAnimationRef.m_pTransition = a_pTransition;
513 ANamedAnimation* pNamedAnimation = a_rAnimationRef.m_pNamedAnimation;
514
515 if ( pNamedAnimation )
516 {
517 if ( TAnimation* pAnimation = m_pSkeletonInstance->GetAnimation( a_rAnimationRef.GetSequenceId() ) )
518 {
519 pAnimation->SetBlendOutSpeed( a_pTransition ? a_pTransition->GetBlendOutTime() : 0.0f );
520 return TTRUE;
521 }
522 }
523
524 return TTRUE;
525}
526
527// $Barnyard: FUNCTION 00470970
532
534{
535 AToshiAnimationRef* pAnimRef = TNULL;
536
537 pAnimRef = GetAnimationRef( m_llAnimRefs, a_strName );
538 if ( !pAnimRef ) pAnimRef = GetAnimationRef( m_llOverlayAnimRefs, a_strName );
539
540 return pAnimRef;
541}
542
543// $Barnyard: FUNCTION 005831d0
545{
546 if ( !GetAnimationRef( m_llAnimRefs, a_pAnimation->GetName() ) &&
547 !GetAnimationRef( m_llOverlayAnimRefs, a_pAnimation->GetName() ) &&
548 !( a_pAnimation->GetFlags() & ANamedAnimation::FLAGS_NO_ANIM_REF ) )
549 {
550 AToshiAnimationRef* pAnimRef = g_oAnimationRefPool.NewObject();
551 PlayAnimImpl( a_pAnimation, a_fWeight, a_pTransition, *pAnimRef );
552 a_rList.PushBack( pAnimRef );
553
554 return pAnimRef;
555 }
556
557 return TNULL;
558}
559
560// $Barnyard: FUNCTION 00583610
562{
563 AToshiAnimationRef* pAnimRef;
564 ANamedAnimationTransition* pTransition = TNULL;
565 GetAnimationTransition( m_llAnimRefs, a_pAnimation->GetName(), pAnimRef, pTransition );
566
567 return CreateAnimationRef( m_llOverlayAnimRefs, a_pAnimation, a_fWeight, pTransition );
568}
569
570// $Barnyard: FUNCTION 00582220
572{
573 return ( a_rAnimRef.GetNamedAnimation() ) ? m_pSkeletonInstance->GetAnimation( a_rAnimRef.GetSequenceId() ) : TNULL;
574}
575
576void AToshiAnimationInterface::DestroyAnimReferences()
577{
578 while ( !m_llAnimRefs.IsEmpty() )
579 {
580 T2DList<AToshiAnimationRef>::Iterator itAnimRef = m_llAnimRefs.Begin();
581 m_llAnimRefs.Erase( itAnimRef );
582
583 g_oAnimationRefPool.DeleteObject( itAnimRef );
584 }
585
586 while ( !m_llOverlayAnimRefs.IsEmpty() )
587 {
588 T2DList<AToshiAnimationRef>::Iterator itAnimRef = m_llOverlayAnimRefs.Begin();
589 m_llOverlayAnimRefs.Erase( itAnimRef );
590
591 g_oAnimationRefPool.DeleteObject( itAnimRef );
592 }
593}
594
596{
597 m_pNamedAnimation = TNULL;
598 m_fWeight = 1.0f;
599 m_fTime = 0.0f;
600 m_pTransition = TNULL;
601 m_bWasEverUpdated = TFALSE;
602 m_iBreakpointIndex = 0;
603}
604
608
609// $Barnyard: FUNCTION 005802f0
610void AToshiAnimationInterface::AnimEvent::SetSimpleEvent( ANIMEVENT_TYPE a_eType, TBOOL a_bIsOverlay, const Toshi::TPString8& a_strAnimationName, TFLOAT a_fTimeToBreakpoint )
611{
612 eType = a_eType;
613 bIsOverlay = a_bIsOverlay;
614 strAnimationName = a_strAnimationName;
616 a_fTimeToBreakpoint = fTimeFromBreakpoint;
617}
618
619// $Barnyard: FUNCTION 00580280
620void AToshiAnimationInterface::AnimEvent::SetBreakpointEvent( AAnimationBreakpoint* a_pBreakpoint, TBOOL a_bIsOverlay, const Toshi::TPString8& a_strAnimationName, TFLOAT a_fTimeFromBreakpoint )
621{
623 bIsOverlay = a_bIsOverlay;
624 strAnimationName = a_strAnimationName;
625 pNextBreakpoint = a_pBreakpoint;
626 a_fTimeFromBreakpoint = fTimeFromBreakpoint;
627}
628
629// T2ObjectPool<AToshiAnimationRef, 100>::NewObject
630// $Barnyard: FUNCTION 00582660
#define TASSERT(X,...)
Definition Defines.h:138
#define TOSHI_NAMESPACE_USING
Definition Defines.h:46
#define TVALIDPTR(PTR)
Definition Defines.h:139
#define T2_FOREACH(vecName, iteratorName)
Definition T2Iterator.h:4
float TFLOAT
Definition Typedefs.h:4
#define TNULL
Definition Typedefs.h:23
int TINT
Definition Typedefs.h:7
#define TFALSE
Definition Typedefs.h:24
#define TTRUE
Definition Typedefs.h:25
bool TBOOL
Definition Typedefs.h:6
Toshi::T2ObjectPool< AToshiAnimationRef, 100 > g_oAnimationRefPool
Toshi::TRef< ANamedAnimationSet > ANamedAnimationSetRef
TFORCEINLINE const T & Max(const T &a, const T &b)
TFLOAT GetBlendOutSpeed() const
Definition TAnimation.h:73
void ChangeToManaged(TFLOAT a_fBlendOutSpeed)
TBOOL UpdateTime(TFLOAT a_fDeltaTime)
void RemoveAnimation(TFLOAT a_fVal)
TFLOAT SetSpeed(TFLOAT a_fSpeed)
Definition TAnimation.h:51
@ STATE_BLENDING_OUT
Definition TAnimation.h:40
State GetState() const
Definition TAnimation.h:59
TBOOL IsManaged() const
Definition TAnimation.h:61
void SetBlendOutSpeed(TFLOAT a_fBlendOutSpeed)
Definition TAnimation.h:54
Iterator Begin() const
Definition T2DList.h:181
void PushBack(T *pItem)
Definition T2DList.h:249
Toshi::T2Iterator< T, Node > Iterator
Definition T2DList.h:156
const Toshi::TPString8 & GetAnimationName()
ANamedAnimationTransition * GetDestTransition()
TFLOAT GetDefaultBlendOutTime() const
TBOOL IsFinishManual() const
FLAGS GetFlags() const
TFLOAT GetSpeed() const
TINT16 GetSequenceId() const
ANamedAnimationTransitionSet & GetTransitionSet()
TBOOL IsLooped() const
const Toshi::TPString8 & GetExportedName() const
TBOOL IsReversed() const
TFLOAT GetDuration() const
SortedBreakpointList & GetBreakpoints()
TFLOAT GetDefaultWeight() const
TFLOAT GetDefaultBlendInTime() const
const Toshi::TPString8 & GetName() const
TBOOL IsOverlay() const
ANamedAnimationTransition * GetTransition() const
void SetWeight(TFLOAT a_fWeight)
ANamedAnimation * GetNamedAnimation() const
AToshiAnimationRef * FindAnimationRef(const Toshi::TPString8 &a_strName)
Toshi::TAnimation * GetAnimation(const AToshiAnimationRef &a_rAnimRef)
TBOOL SetAnimationTransition(AToshiAnimationRef &a_rAnimationRef, ANamedAnimationTransition *a_pTransition)
TBOOL StopAnim(const AToshiAnimationRef &a_rAnimationRef)
AToshiAnimationRef * CreateOverlayAnimationRef(ANamedAnimation *a_pAnimation, TFLOAT a_fWeight)
void Update(TFLOAT a_fDeltaTime, AnimEventList &a_rEventList)
ANamedAnimationSetRef GetAnimationSet()
AToshiAnimationRef * CreateAnimationRef(Toshi::T2DList< AToshiAnimationRef > &a_rList, ANamedAnimation *a_pAnimation, TFLOAT a_fWeight, ANamedAnimationTransition *a_pTransition)
AToshiAnimationRef * PlayAnim(const Toshi::TPString8 &a_strName, TFLOAT a_fWeight, TBOOL a_bCreateNewRef)
void SetBreakpointEvent(AAnimationBreakpoint *a_pBreakpoint, TBOOL a_bIsOverlay, const Toshi::TPString8 &a_strAnimationName, TFLOAT a_fTimeToBreakpoint)
void SetSimpleEvent(ANIMEVENT_TYPE a_eType, TBOOL a_bIsOverlay, const Toshi::TPString8 &a_strAnimationName, TFLOAT a_fTimeToBreakpoint)