@@ -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 ;
@@ -471,6 +474,7 @@ void Animatable3DObjClass::Set_Animation(HAnimClass * motion, float frame, int m
471474 ModeAnim.Motion = motion;
472475 ModeAnim.PrevFrame = ModeAnim.Frame ;
473476 ModeAnim.Frame = frame;
477+ ModeAnim.LastSyncTime = WW3D::Get_Logic_Time_Milliseconds ();
474478 ModeAnim.frameRateMultiplier =1.0 ; // 020607 srj -- added
475479 ModeAnim.animDirection =1.0 ; // 020607 srj -- added
476480
@@ -939,14 +943,16 @@ float Animatable3DObjClass::Compute_Current_Frame(float *newDirection) const
939943 {
940944 frame = ModeAnim.Frame ;
941945
942- //
943- // Compute the current frame based on elapsed time.
944- //
945946 if (ModeAnim.AnimMode != ANIM_MODE_MANUAL) {
947+ //
948+ // Compute the current frame based on elapsed time.
949+ // TheSuperHackers @info Is using elapsed time because frame computation is not guaranteed to be called every render frame!
950+ //
946951 // TheSuperHackers @tweak The animation render update is now decoupled from the logic step.
947- const float frametime = WW3D::Get_Logic_Frame_Time_Seconds ();
948- const float delta = ModeAnim.Motion ->Get_Frame_Rate () * ModeAnim.frameRateMultiplier * ModeAnim.animDirection * frametime;
949- frame += delta;
952+ const float syncMilliseconds = WW3D::Get_Logic_Time_Milliseconds () - ModeAnim.LastSyncTime ;
953+ const float animMilliseconds = ModeAnim.Motion ->Get_Frame_Rate () * ModeAnim.frameRateMultiplier * ModeAnim.animDirection * syncMilliseconds;
954+ const float animSeconds = animMilliseconds * 0 .001f ;
955+ frame += animSeconds;
950956
951957 //
952958 // Wrap the frame
@@ -1042,6 +1048,7 @@ void Animatable3DObjClass::Single_Anim_Progress (void)
10421048 //
10431049 ModeAnim.PrevFrame = ModeAnim.Frame ;
10441050 ModeAnim.Frame = Compute_Current_Frame (&ModeAnim.animDirection );
1051+ ModeAnim.LastSyncTime = WW3D::Get_Logic_Time_Milliseconds ();
10451052}
10461053
10471054
0 commit comments