/* =============== UI_RunLerpFrame =============== */ static void UI_RunLerpFrame( playerInfo_t *ci, lerpFrame_t *lf, int newAnimation ) { int f; animation_t *anim; // see if the animation sequence is switching if ( newAnimation != lf->animationNumber || !lf->animation ) { UI_SetLerpFrameAnimation( ci, lf, newAnimation ); } // if we have passed the current frame, move it to // oldFrame and calculate a new frame if ( dp_realtime >= lf->frameTime ) { lf->oldFrame = lf->frame; lf->oldFrameTime = lf->frameTime; // get the next frame based on the animation anim = lf->animation; if ( dp_realtime < lf->animationTime ) { lf->frameTime = lf->animationTime; // initial lerp } else { lf->frameTime = lf->oldFrameTime + anim->frameLerp; } f = ( lf->frameTime - lf->animationTime ) / anim->frameLerp; if ( f >= anim->numFrames ) { f -= anim->numFrames; if ( anim->loopFrames ) { f %= anim->loopFrames; f += anim->numFrames - anim->loopFrames; } else { f = anim->numFrames - 1; // the animation is stuck at the end, so it // can immediately transition to another sequence lf->frameTime = dp_realtime; } } lf->frame = anim->firstFrame + f; if ( dp_realtime > lf->frameTime ) { lf->frameTime = dp_realtime; } } if ( lf->frameTime > dp_realtime + 200 ) { lf->frameTime = dp_realtime; } if ( lf->oldFrameTime > dp_realtime ) { lf->oldFrameTime = dp_realtime; } // calculate current lerp value if ( lf->frameTime == lf->oldFrameTime ) { lf->backlerp = 0; } else { lf->backlerp = 1.0 - (float)( dp_realtime - lf->oldFrameTime ) / ( lf->frameTime - lf->oldFrameTime ); } }
/* * UI_RunLerpFrame */ static void UI_RunLerpFrame(Playerinfo *ci, Lerpframe *lf, int newAnimation) { int f; Anim *anim; /* see if the animation sequence is switching */ if(newAnimation != lf->animationNumber || !lf->animation) UI_SetLerpFrameAnimation(ci, lf, newAnimation); /* if we have passed the current frame, move it to * oldFrame and calculate a new frame */ if(dp_realtime >= lf->frameTime){ lf->oldFrame = lf->frame; lf->oldFrameTime = lf->frameTime; /* get the next frame based on the animation */ anim = lf->animation; if(dp_realtime < lf->animationTime) lf->frameTime = lf->animationTime; /* initial lerp */ else lf->frameTime = lf->oldFrameTime + anim->frameLerp; f = (lf->frameTime - lf->animationTime) / anim->frameLerp; if(f >= anim->numFrames){ f -= anim->numFrames; if(anim->loopFrames){ f %= anim->loopFrames; f += anim->numFrames - anim->loopFrames; }else{ f = anim->numFrames - 1; /* the animation is stuck at the end, so it * can immediately transition to another sequence */ lf->frameTime = dp_realtime; } } lf->frame = anim->firstFrame + f; if(dp_realtime > lf->frameTime) lf->frameTime = dp_realtime; } if(lf->frameTime > dp_realtime + 200) lf->frameTime = dp_realtime; if(lf->oldFrameTime > dp_realtime) lf->oldFrameTime = dp_realtime; /* calculate current lerp value */ if(lf->frameTime == lf->oldFrameTime) lf->backlerp = 0; else lf->backlerp = 1.0 - (float)(dp_realtime - lf->oldFrameTime) / (lf->frameTime - lf->oldFrameTime); }