Merge pull request #22 from lioncash/anim2

CAnimation: Minor clean up
This commit is contained in:
LC 2020-06-11 10:52:59 -04:00 committed by GitHub
commit 8babcc13bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 24 deletions

View File

@ -6,16 +6,7 @@
CAnimation::CAnimation(CResourceEntry *pEntry /*= 0*/) CAnimation::CAnimation(CResourceEntry *pEntry /*= 0*/)
: CResource(pEntry) : CResource(pEntry)
, mDuration(0.f)
, mTickInterval(0.0333333f)
, mNumKeys(0)
{ {
for (uint32 iBone = 0; iBone < 100; iBone++)
{
mBoneInfo[iBone].TranslationChannelIdx = 0xFF;
mBoneInfo[iBone].RotationChannelIdx = 0xFF;
mBoneInfo[iBone].ScaleChannelIdx = 0xFF;
}
} }
CDependencyTree* CAnimation::BuildDependencyTree() const CDependencyTree* CAnimation::BuildDependencyTree() const

View File

@ -6,6 +6,7 @@
#include "Core/Resource/Animation/CAnimEventData.h" #include "Core/Resource/Animation/CAnimEventData.h"
#include <Common/Math/CQuaternion.h> #include <Common/Math/CQuaternion.h>
#include <Common/Math/CVector3f.h> #include <Common/Math/CVector3f.h>
#include <array>
#include <vector> #include <vector>
class CAnimation : public CResource class CAnimation : public CResource
@ -13,13 +14,13 @@ class CAnimation : public CResource
DECLARE_RESOURCE_TYPE(Animation) DECLARE_RESOURCE_TYPE(Animation)
friend class CAnimationLoader; friend class CAnimationLoader;
typedef std::vector<CVector3f> TScaleChannel; using TScaleChannel = std::vector<CVector3f>;
typedef std::vector<CQuaternion> TRotationChannel; using TRotationChannel = std::vector<CQuaternion>;
typedef std::vector<CVector3f> TTranslationChannel; using TTranslationChannel = std::vector<CVector3f>;
float mDuration; float mDuration = 0.0f;
float mTickInterval; float mTickInterval = 0.0333333f;
uint32 mNumKeys; uint32 mNumKeys = 0;
std::vector<TScaleChannel> mScaleChannels; std::vector<TScaleChannel> mScaleChannels;
std::vector<TRotationChannel> mRotationChannels; std::vector<TRotationChannel> mRotationChannels;
@ -27,24 +28,24 @@ class CAnimation : public CResource
struct SBoneChannelInfo struct SBoneChannelInfo
{ {
uint8 ScaleChannelIdx; uint8 ScaleChannelIdx = 0xFF;
uint8 RotationChannelIdx; uint8 RotationChannelIdx = 0xFF;
uint8 TranslationChannelIdx; uint8 TranslationChannelIdx = 0xFF;
}; };
SBoneChannelInfo mBoneInfo[100]; std::array<SBoneChannelInfo, 100> mBoneInfo;
TResPtr<CAnimEventData> mpEventData; TResPtr<CAnimEventData> mpEventData;
public: public:
CAnimation(CResourceEntry *pEntry = 0); CAnimation(CResourceEntry *pEntry = 0);
CDependencyTree* BuildDependencyTree() const; CDependencyTree* BuildDependencyTree() const override;
void EvaluateTransform(float Time, uint32 BoneID, CVector3f *pOutTranslation, CQuaternion *pOutRotation, CVector3f *pOutScale) const; void EvaluateTransform(float Time, uint32 BoneID, CVector3f *pOutTranslation, CQuaternion *pOutRotation, CVector3f *pOutScale) const;
bool HasTranslation(uint32 BoneID) const; bool HasTranslation(uint32 BoneID) const;
inline float Duration() const { return mDuration; } float Duration() const { return mDuration; }
inline uint32 NumKeys() const { return mNumKeys; } uint32 NumKeys() const { return mNumKeys; }
inline float TickInterval() const { return mTickInterval; } float TickInterval() const { return mTickInterval; }
inline CAnimEventData* EventData() const { return mpEventData; } CAnimEventData* EventData() const { return mpEventData; }
}; };
#endif // CANIMATION_H #endif // CANIMATION_H