Minor improvements to CMatrix

This commit is contained in:
Silent 2017-06-25 14:17:05 +02:00
parent 1da99647b5
commit 09f3d7ca34
3 changed files with 8 additions and 12 deletions

View file

@ -80,7 +80,7 @@ public:
} }
inline CVector* GetCoords() inline CVector* GetCoords()
{ return m_pCoords ? reinterpret_cast<CVector*>(&m_pCoords->matrix.pos) : &m_transform.m_translate; } { return m_pCoords ? &m_pCoords->GetPos() : &m_transform.m_translate; }
inline CMatrix* GetMatrix() inline CMatrix* GetMatrix()
{ return m_pCoords; } { return m_pCoords; }
inline CSimpleTransform& GetTransform() inline CSimpleTransform& GetTransform()
@ -89,7 +89,7 @@ public:
{ return m_pCoords ? atan2(-m_pCoords->GetUp().x, m_pCoords->GetUp().y) : m_transform.m_heading; } { return m_pCoords ? atan2(-m_pCoords->GetUp().x, m_pCoords->GetUp().y) : m_transform.m_heading; }
inline void SetCoords(const CVector& pos) inline void SetCoords(const CVector& pos)
{ if ( m_pCoords ) { m_pCoords->matrix.pos.x = pos.x; m_pCoords->matrix.pos.y = pos.y; m_pCoords->matrix.pos.z = pos.z; } { if ( m_pCoords ) { m_pCoords->GetPos() = pos; }
else m_transform.m_translate = pos; } else m_transform.m_translate = pos; }
inline void SetHeading(float fHeading) inline void SetHeading(float fHeading)
{ if ( m_pCoords ) m_pCoords->SetRotateZOnly(fHeading); else m_transform.m_heading = fHeading; } { if ( m_pCoords ) m_pCoords->SetRotateZOnly(fHeading); else m_transform.m_heading = fHeading; }

View file

@ -102,26 +102,22 @@ public:
class CMatrix class CMatrix
{ {
public: private:
RwMatrix matrix; RwMatrix matrix;
RwMatrix* pMatrix; RwMatrix* pMatrix = nullptr;
BOOL haveRwMatrix; BOOL haveRwMatrix = FALSE;
public: public:
inline CMatrix() inline CMatrix() = default;
: pMatrix(nullptr), haveRwMatrix(FALSE)
{}
inline CMatrix(RwMatrix* pMatrix, bool bHasMatrix=false) inline CMatrix(RwMatrix* pMatrix, bool bHasMatrix=false)
: CMatrix()
{ Attach(pMatrix, bHasMatrix); } { Attach(pMatrix, bHasMatrix); }
inline CMatrix(const CMatrix& theMatrix) inline CMatrix(const CMatrix& theMatrix)
: pMatrix(nullptr), haveRwMatrix(FALSE), matrix(theMatrix.matrix) : matrix(theMatrix.matrix)
{} {}
inline CMatrix(const CVector& vecRight, const CVector& vecUp, const CVector& vecAt, const CVector& vecPos) inline CMatrix(const CVector& vecRight, const CVector& vecUp, const CVector& vecAt, const CVector& vecPos)
: CMatrix()
{ {
matrix.right.x = vecRight.x; matrix.right.x = vecRight.x;
matrix.right.y = vecRight.y; matrix.right.y = vecRight.y;

View file

@ -6,7 +6,7 @@
<SILENTPATCH_EXT>.asi</SILENTPATCH_EXT> <SILENTPATCH_EXT>.asi</SILENTPATCH_EXT>
<SILENTPATCH_FULL_NAME>SilentPatch for San Andreas</SILENTPATCH_FULL_NAME> <SILENTPATCH_FULL_NAME>SilentPatch for San Andreas</SILENTPATCH_FULL_NAME>
<SILENTPATCH_REVISION_ID>29</SILENTPATCH_REVISION_ID> <SILENTPATCH_REVISION_ID>29</SILENTPATCH_REVISION_ID>
<SILENTPATCH_BUILD_ID>3</SILENTPATCH_BUILD_ID> <SILENTPATCH_BUILD_ID>4</SILENTPATCH_BUILD_ID>
<SILENTPATCH_COPYRIGHT>2014-2017</SILENTPATCH_COPYRIGHT> <SILENTPATCH_COPYRIGHT>2014-2017</SILENTPATCH_COPYRIGHT>
</PropertyGroup> </PropertyGroup>
<PropertyGroup /> <PropertyGroup />