Initialize variables in ModelTypes

This commit is contained in:
sukibaby
2024-08-07 00:52:04 -07:00
committed by teejusb
parent b30bf85399
commit a1c316cfc7
2 changed files with 48 additions and 45 deletions
+2 -2
View File
@@ -303,7 +303,7 @@ bool msAnimation::LoadMilkshapeAsciiBones( RString sAniName, RString sPath )
if (sscanf (sLine, "%f %f %f %f", &fTime, &Position[0], &Position[1], &Position[2]) != 4) if (sscanf (sLine, "%f %f %f %f", &fTime, &Position[0], &Position[1], &Position[2]) != 4)
THROW; THROW;
msPositionKey key; msPositionKey key = {};
key.fTime = fTime; key.fTime = fTime;
key.Position = RageVector3( Position[0], Position[1], Position[2] ); key.Position = RageVector3( Position[0], Position[1], Position[2] );
Bone.PositionKeys[j] = key; Bone.PositionKeys[j] = key;
@@ -328,7 +328,7 @@ bool msAnimation::LoadMilkshapeAsciiBones( RString sAniName, RString sPath )
THROW; THROW;
Rotation = RadianToDegree(Rotation); Rotation = RadianToDegree(Rotation);
msRotationKey key; msRotationKey key = {};
key.fTime = fTime; key.fTime = fTime;
Rotation = RageVector3( Rotation[0], Rotation[1], Rotation[2] ); Rotation = RageVector3( Rotation[0], Rotation[1], Rotation[2] );
RageQuatFromHPR( &key.Rotation, Rotation ); RageQuatFromHPR( &key.Rotation, Rotation );
+43 -40
View File
@@ -8,31 +8,29 @@
#include <cstdint> #include <cstdint>
#include <vector> #include <vector>
struct msTriangle struct msTriangle
{ {
std::uint16_t nVertexIndices[3]; std::uint16_t nVertexIndices[3];
}; };
struct msMesh struct msMesh
{ {
RString sName; RString sName;
std::int8_t nMaterialIndex; std::int8_t nMaterialIndex;
std::vector<RageModelVertex> Vertices; std::vector<RageModelVertex> Vertices;
// OPTIMIZATION: If all verts in a mesh are transformed by the same bone, // OPTIMIZATION: If all verts in a mesh are transformed by the same bone,
// then send the transform to the graphics card for the whole mesh instead // then send the transform to the graphics card for the whole mesh instead
// of transforming each vertex on the CPU; // of transforming each vertex on the CPU;
std::int8_t m_iBoneIndex; // -1 = no bone std::int8_t m_iBoneIndex; // -1 = no bone
std::vector<msTriangle> Triangles; std::vector<msTriangle> Triangles;
}; };
class RageTexture; class RageTexture;
// merge this into Sprite?
class AnimatedTexture class AnimatedTexture
{ {
public: public:
@@ -40,50 +38,47 @@ public:
~AnimatedTexture(); ~AnimatedTexture();
void LoadBlank(); void LoadBlank();
void Load( const RString &sTexOrIniFile ); void Load(const RString &sTexOrIniFile);
void Unload(); void Unload();
void Update( float fDelta ); void Update(float fDelta);
RageTexture* GetCurrentTexture(); RageTexture* GetCurrentTexture();
int GetNumStates() const; int GetNumStates() const;
void SetState( int iNewState ); void SetState(int iNewState);
float GetAnimationLengthSeconds() const; float GetAnimationLengthSeconds() const;
void SetSecondsIntoAnimation( float fSeconds ); void SetSecondsIntoAnimation(float fSeconds);
float GetSecondsIntoAnimation() const; float GetSecondsIntoAnimation() const;
RageVector2 GetTextureTranslate(); RageVector2 GetTextureTranslate();
bool m_bSphereMapped; bool m_bSphereMapped;
BlendMode m_BlendMode; BlendMode m_BlendMode;
bool NeedsNormals() const { return m_bSphereMapped; } bool NeedsNormals() const { return m_bSphereMapped; }
private: private:
RageVector2 m_vTexOffset; RageVector2 m_vTexOffset;
RageVector2 m_vTexVelocity; RageVector2 m_vTexVelocity;
int m_iCurState; int m_iCurState;
float m_fSecsIntoFrame; float m_fSecsIntoFrame;
struct AnimatedTextureState struct AnimatedTextureState
{ {
AnimatedTextureState( AnimatedTextureState(RageTexture* pTexture_, float fDelaySecs_, RageVector2 vTranslate_)
RageTexture* pTexture_, : pTexture(pTexture_), fDelaySecs(fDelaySecs_), vTranslate(vTranslate_)
float fDelaySecs_, {
RageVector2 vTranslate_ }
):
pTexture(pTexture_), fDelaySecs(fDelaySecs_),
vTranslate(vTranslate_) {}
RageTexture* pTexture; RageTexture* pTexture;
float fDelaySecs; float fDelaySecs;
RageVector2 vTranslate; RageVector2 vTranslate;
}; };
std::vector<AnimatedTextureState> vFrames; std::vector<AnimatedTextureState> vFrames;
}; };
struct msMaterial struct msMaterial
{ {
int nFlags; int nFlags;
RString sName; RString sName;
RageColor Ambient; RageColor Ambient;
RageColor Diffuse; RageColor Diffuse;
@@ -102,47 +97,55 @@ struct msPositionKey
{ {
float fTime; float fTime;
RageVector3 Position; RageVector3 Position;
msPositionKey() : fTime(0.0f) {}
}; };
struct msRotationKey struct msRotationKey
{ {
float fTime; float fTime;
RageVector4 Rotation; RageVector4 Rotation;
msRotationKey() : fTime(0.0f) {}
}; };
struct msBone struct msBone
{ {
int nFlags; int nFlags;
RString sName; RString sName;
RString sParentName; RString sParentName;
RageVector3 Position; RageVector3 Position;
RageVector3 Rotation; RageVector3 Rotation;
std::vector<msPositionKey> PositionKeys; std::vector<msPositionKey> PositionKeys;
std::vector<msRotationKey> RotationKeys; std::vector<msRotationKey> RotationKeys;
msBone() : nFlags(0) {}
}; };
struct msAnimation struct msAnimation
{ {
int FindBoneByName( const RString &sName ) const int FindBoneByName( const RString &sName ) const
{ {
for( unsigned i=0; i<Bones.size(); i++ ) for (unsigned i = 0; i < Bones.size(); i++)
if( Bones[i].sName == sName ) {
if (Bones[i].sName == sName)
return i; return i;
}
return -1; return -1;
} }
bool LoadMilkshapeAsciiBones( RString sAniName, RString sPath ); bool LoadMilkshapeAsciiBones( RString sAniName, RString sPath );
std::vector<msBone> Bones; std::vector<msBone> Bones;
int nTotalFrames; int nTotalFrames = 0;
}; };
struct myBone_t struct myBone_t
{ {
RageMatrix m_Relative; RageMatrix m_Relative;
RageMatrix m_Absolute; RageMatrix m_Absolute;
RageMatrix m_Final; RageMatrix m_Final;
}; };
#endif #endif