@@ -89,6 +89,7 @@ Animatable3DObjClass::Animatable3DObjClass(const char * htree_name) :
8989 ModeAnim.Motion =NULL ;
9090 ModeAnim.Frame =0 .0f ;
9191 ModeAnim.PrevFrame =0 .0f ;
92+ ModeAnim.LastSyncTime =WW3D::Get_Logic_Time_Milliseconds ();
9293 ModeAnim.frameRateMultiplier =1.0 ; // 020607 srj -- added
9394 ModeAnim.animDirection =1.0 ; // 020607 srj -- added
9495 ModeInterp.Motion0 =NULL ;
@@ -144,6 +145,7 @@ Animatable3DObjClass::Animatable3DObjClass(const Animatable3DObjClass & src) :
144145 ModeAnim.Motion =NULL ;
145146 ModeAnim.Frame =0 .0f ;
146147 ModeAnim.PrevFrame =0 .0f ;
148+ ModeAnim.LastSyncTime =WW3D::Get_Logic_Time_Milliseconds ();
147149 ModeAnim.frameRateMultiplier =1.0 ; // 020607 srj -- added
148150 ModeAnim.animDirection =1.0 ; // 020607 srj -- added
149151 ModeInterp.Motion0 =NULL ;
@@ -203,6 +205,7 @@ Animatable3DObjClass & Animatable3DObjClass::operator = (const Animatable3DObjCl
203205 ModeAnim.Motion = NULL ;
204206 ModeAnim.Frame = 0 .0f ;
205207 ModeAnim.PrevFrame = 0 .0f ;
208+ ModeAnim.LastSyncTime = WW3D::Get_Logic_Time_Milliseconds ();
206209 ModeAnim.frameRateMultiplier =1.0 ; // 020607 srj -- added
207210 ModeAnim.animDirection =1.0 ; // 020607 srj -- added
208211 ModeInterp.Motion0 = NULL ;
@@ -461,6 +464,7 @@ void Animatable3DObjClass::Set_Animation(HAnimClass * motion, float frame, int m
461464 ModeAnim.Motion = motion;
462465 ModeAnim.PrevFrame = ModeAnim.Frame ;
463466 ModeAnim.Frame = frame;
467+ ModeAnim.LastSyncTime = WW3D::Get_Logic_Time_Milliseconds ();
464468 ModeAnim.frameRateMultiplier =1.0 ; // 020607 srj -- added
465469 ModeAnim.animDirection =1.0 ; // 020607 srj -- added
466470
@@ -937,13 +941,14 @@ float Animatable3DObjClass::Compute_Current_Frame(float *newDirection) const
937941 {
938942 frame = ModeAnim.Frame ;
939943
940- //
941- // Compute the current frame based on elapsed time.
942- //
943944 if (ModeAnim.AnimMode != ANIM_MODE_MANUAL) {
945+ //
946+ // Compute the current frame based on elapsed time.
947+ // TheSuperHackers @info Is using elapsed time because frame computation is not guaranteed to be called every render frame!
948+ //
944949 // TheSuperHackers @tweak The animation render update is now decoupled from the logic step.
945- const float frametime = WW3D::Get_Logic_Frame_Time_Seconds () ;
946- const float delta = ModeAnim.Motion ->Get_Frame_Rate () * ModeAnim.frameRateMultiplier * ModeAnim.animDirection * frametime ;
950+ const float timeDiff = WW3D::Get_Logic_Time_Milliseconds () - ModeAnim. LastSyncTime ;
951+ const float delta = ModeAnim.Motion ->Get_Frame_Rate () * ModeAnim.frameRateMultiplier * ModeAnim.animDirection * timeDiff * 0 . 001f ;
947952 frame += delta;
948953
949954 //
@@ -1040,6 +1045,7 @@ void Animatable3DObjClass::Single_Anim_Progress (void)
10401045 //
10411046 ModeAnim.PrevFrame = ModeAnim.Frame ;
10421047 ModeAnim.Frame = Compute_Current_Frame (&ModeAnim.animDirection );
1048+ ModeAnim.LastSyncTime = WW3D::Get_Logic_Time_Milliseconds ();
10431049
10441050 //
10451051 // Force the hierarchy to be recalculated
0 commit comments