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)
THROW;
msPositionKey key;
msPositionKey key = {};
key.fTime = fTime;
key.Position = RageVector3( Position[0], Position[1], Position[2] );
Bone.PositionKeys[j] = key;
@@ -328,7 +328,7 @@ bool msAnimation::LoadMilkshapeAsciiBones( RString sAniName, RString sPath )
THROW;
Rotation = RadianToDegree(Rotation);
msRotationKey key;
msRotationKey key = {};
key.fTime = fTime;
Rotation = RageVector3( Rotation[0], Rotation[1], Rotation[2] );
RageQuatFromHPR( &key.Rotation, Rotation );
+46 -43
View File
@@ -8,31 +8,29 @@
#include <cstdint>
#include <vector>
struct msTriangle
{
std::uint16_t nVertexIndices[3];
std::uint16_t nVertexIndices[3];
};
struct msMesh
{
RString sName;
std::int8_t nMaterialIndex;
std::vector<RageModelVertex> Vertices;
RString sName;
std::int8_t nMaterialIndex;
std::vector<RageModelVertex> Vertices;
// 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
// of transforming each vertex on the CPU;
std::int8_t m_iBoneIndex; // -1 = no bone
std::vector<msTriangle> Triangles;
std::int8_t m_iBoneIndex; // -1 = no bone
std::vector<msTriangle> Triangles;
};
class RageTexture;
// merge this into Sprite?
class AnimatedTexture
{
public:
@@ -40,50 +38,47 @@ public:
~AnimatedTexture();
void LoadBlank();
void Load( const RString &sTexOrIniFile );
void Load(const RString &sTexOrIniFile);
void Unload();
void Update( float fDelta );
void Update(float fDelta);
RageTexture* GetCurrentTexture();
int GetNumStates() const;
void SetState( int iNewState );
void SetState(int iNewState);
float GetAnimationLengthSeconds() const;
void SetSecondsIntoAnimation( float fSeconds );
void SetSecondsIntoAnimation(float fSeconds);
float GetSecondsIntoAnimation() const;
RageVector2 GetTextureTranslate();
bool m_bSphereMapped;
BlendMode m_BlendMode;
bool m_bSphereMapped;
BlendMode m_BlendMode;
bool NeedsNormals() const { return m_bSphereMapped; }
private:
RageVector2 m_vTexOffset;
RageVector2 m_vTexVelocity;
RageVector2 m_vTexOffset;
RageVector2 m_vTexVelocity;
int m_iCurState;
float m_fSecsIntoFrame;
struct AnimatedTextureState
{
AnimatedTextureState(
RageTexture* pTexture_,
float fDelaySecs_,
RageVector2 vTranslate_
):
pTexture(pTexture_), fDelaySecs(fDelaySecs_),
vTranslate(vTranslate_) {}
AnimatedTextureState(RageTexture* pTexture_, float fDelaySecs_, RageVector2 vTranslate_)
: pTexture(pTexture_), fDelaySecs(fDelaySecs_), vTranslate(vTranslate_)
{
}
RageTexture* pTexture;
float fDelaySecs;
RageVector2 vTranslate;
float fDelaySecs;
RageVector2 vTranslate;
};
std::vector<AnimatedTextureState> vFrames;
};
struct msMaterial
{
int nFlags;
int nFlags;
RString sName;
RageColor Ambient;
RageColor Diffuse;
@@ -102,47 +97,55 @@ struct msPositionKey
{
float fTime;
RageVector3 Position;
msPositionKey() : fTime(0.0f) {}
};
struct msRotationKey
{
float fTime;
RageVector4 Rotation;
msRotationKey() : fTime(0.0f) {}
};
struct msBone
{
int nFlags;
RString sName;
RString sParentName;
RageVector3 Position;
RageVector3 Rotation;
int nFlags;
RString sName;
RString sParentName;
RageVector3 Position;
RageVector3 Rotation;
std::vector<msPositionKey> PositionKeys;
std::vector<msRotationKey> RotationKeys;
std::vector<msPositionKey> PositionKeys;
std::vector<msRotationKey> RotationKeys;
msBone() : nFlags(0) {}
};
struct msAnimation
{
int FindBoneByName( const RString &sName ) const
{
for( unsigned i=0; i<Bones.size(); i++ )
if( Bones[i].sName == sName )
for (unsigned i = 0; i < Bones.size(); i++)
{
if (Bones[i].sName == sName)
return i;
}
return -1;
}
bool LoadMilkshapeAsciiBones( RString sAniName, RString sPath );
std::vector<msBone> Bones;
int nTotalFrames;
std::vector<msBone> Bones;
int nTotalFrames = 0;
};
struct myBone_t
{
RageMatrix m_Relative;
RageMatrix m_Absolute;
RageMatrix m_Final;
RageMatrix m_Relative;
RageMatrix m_Absolute;
RageMatrix m_Final;
};
#endif