#include "ehs/io/mdl/AnimBone.h" #include namespace ehs { AnimBone::AnimBone() : boneId(0xFF) { } AnimBone::AnimBone(const UInt_8 boneId) : boneId(boneId) { } AnimBone::AnimBone(const UInt_8 boneId, const UInt_64 size) : boneId(boneId), keyFrames(size) { } AnimBone::AnimBone(const UInt_8 boneId, Array keyFrames) : boneId(boneId), keyFrames(std::move(keyFrames)) { } AnimBone::AnimBone(const AnimBone& anim) : boneId(anim.boneId), keyFrames(anim.keyFrames) { } AnimBone::AnimBone(AnimBone&& anim) noexcept : boneId(anim.boneId), keyFrames(std::move(anim.keyFrames)) { anim.boneId = 0xFF; } AnimBone& AnimBone::operator=(AnimBone&& anim) noexcept { if (this == &anim) return *this; boneId = anim.boneId; keyFrames = std::move(anim.keyFrames); anim.boneId = 0xFF; return *this; } AnimBone& AnimBone::operator=(const AnimBone& anim) { if (this == &anim) return *this; boneId = anim.boneId; keyFrames = anim.keyFrames; return *this; } UInt_8 AnimBone::GetBoneId() const { return boneId; } Array AnimBone::GetKeyFrames() const { return keyFrames; } Array& AnimBone::GetKeyFrames() { return keyFrames; } float AnimBone::GetPrevAndNext(KeyFrame& prev, KeyFrame& next, const float elapsed) const { prev = keyFrames[0]; next = keyFrames[0]; for (UInt_64 i = 1; i < keyFrames.Size(); ++i) { next = keyFrames[i]; if (keyFrames[i].GetTimeStamp() > elapsed) break; prev = keyFrames[i]; } return (elapsed - prev.GetTimeStamp()) / (next.GetTimeStamp() - prev.GetTimeStamp()); } }