Skip to content

Commit

Permalink
format animator.c 2/n
Browse files Browse the repository at this point in the history
  • Loading branch information
gabekz committed Dec 5, 2023
1 parent db52705 commit 3bac26d
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions goodsack/gsk/gsk/entity/v1/builtin/animator/animator.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,27 +73,26 @@ update(gsk_Entity e)
animator->cntKeyframeIndex = 1;
return;
}
}

// LOG_INFO("Timer: %.2f", animator->timerNow);
// LOG_INFO("Timer: %.2f", animator->timerNow);

u32 cntKeyframeIndex = animator->cntKeyframeIndex;
gsk_Keyframe *cntKeyframe = cntAnimation->keyframes[cntKeyframeIndex];
u32 cntKeyframeIndex = animator->cntKeyframeIndex;
gsk_Keyframe *cntKeyframe = cntAnimation->keyframes[cntKeyframeIndex];

u32 nxtKeyframeIndex = cntKeyframeIndex + 1;
gsk_Keyframe *nxtKeyframe = cntAnimation->keyframes[nxtKeyframeIndex];
u32 nxtKeyframeIndex = cntKeyframeIndex + 1;
gsk_Keyframe *nxtKeyframe = cntAnimation->keyframes[nxtKeyframeIndex];

float ratio = (animator->timerNow - cntKeyframe->frameTime) /
(nxtKeyframe->frameTime - cntKeyframe->frameTime);
float ratio = (animator->timerNow - cntKeyframe->frameTime) /
(nxtKeyframe->frameTime - cntKeyframe->frameTime);

if (ratio >= nxtKeyframe->frameTime) {
// gsk_animation_set_keyframe(animator->cntAnimation, 0);
gsk_animation_set_keyframe_lerp(
animator->cntAnimation, nxtKeyframeIndex, ratio);
animator->cntKeyframeIndex = nxtKeyframeIndex;
}
if (ratio >= nxtKeyframe->frameTime) {
// gsk_animation_set_keyframe(animator->cntAnimation, 0);
gsk_animation_set_keyframe_lerp(
animator->cntAnimation, nxtKeyframeIndex, ratio);
animator->cntKeyframeIndex = nxtKeyframeIndex;
}

// evaluate whether timerNow is closer to current or next keyframe
// evaluate whether timerNow is closer to current or next keyframe

#endif
}
Expand Down

0 comments on commit 3bac26d

Please sign in to comment.