Skip to content

Commit 6b63596

Browse files
committed
PTRB: Auto convert TVector2/3/4 endianness
1 parent 6d818fa commit 6b63596

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

Toshi/Source/Plugins/PTRB.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
#include <File/TTSF.h>
1010
#include <Toshi/TString8.h>
1111
#include <Toshi/T2String8.h>
12+
#include <Math/TVector2.h>
13+
#include <Math/TVector3.h>
14+
#include <Math/TVector4.h>
1215

1316
// TODO: replace STL classes with native TOSHI classes
1417
#include <vector>
@@ -716,6 +719,36 @@ class PTRB
716719
return CONVERTENDIANESS( m_eEndianess, a_numValue );
717720
}
718721

722+
template <>
723+
Toshi::TVector2 ConvertEndianess( Toshi::TVector2 a_vec )
724+
{
725+
return Toshi::TVector2(
726+
CONVERTENDIANESS( m_eEndianess, a_vec.x ),
727+
CONVERTENDIANESS( m_eEndianess, a_vec.y )
728+
);
729+
}
730+
731+
template <>
732+
Toshi::TVector3 ConvertEndianess( Toshi::TVector3 a_vec )
733+
{
734+
return Toshi::TVector3(
735+
CONVERTENDIANESS( m_eEndianess, a_vec.x ),
736+
CONVERTENDIANESS( m_eEndianess, a_vec.y ),
737+
CONVERTENDIANESS( m_eEndianess, a_vec.z )
738+
);
739+
}
740+
741+
template <>
742+
Toshi::TVector4 ConvertEndianess( Toshi::TVector4 a_vec )
743+
{
744+
return Toshi::TVector4(
745+
CONVERTENDIANESS( m_eEndianess, a_vec.x ),
746+
CONVERTENDIANESS( m_eEndianess, a_vec.y ),
747+
CONVERTENDIANESS( m_eEndianess, a_vec.z ),
748+
CONVERTENDIANESS( m_eEndianess, a_vec.w )
749+
);
750+
}
751+
719752
PTRBSymbols* GetSymbols() { return &m_SYMB; }
720753
PTRBSections* GetSections() { return &m_SECT; }
721754
Endianess GetEndianess() const { return m_eEndianess; }

0 commit comments

Comments
 (0)