misaligment fixes

This commit is contained in:
nillerusr
2022-05-15 21:09:59 +03:00
parent 1218fa659c
commit 3a73624b7e
39 changed files with 7592 additions and 6056 deletions

View File

@@ -149,7 +149,7 @@ class Quaternion64
{
public:
// Construction/destruction:
Quaternion64(void);
Quaternion64(void) {};
Quaternion64(vec_t X, vec_t Y, vec_t Z);
// assignment
@@ -197,7 +197,7 @@ class Quaternion48
{
public:
// Construction/destruction:
Quaternion48(void);
Quaternion48(void) {};
Quaternion48(vec_t X, vec_t Y, vec_t Z);
// assignment

View File

@@ -34,7 +34,7 @@ enum LightType_OptimizationFlags_t
struct LightDesc_t
{
LightType_t m_Type; //< MATERIAL_LIGHT_xxx
Vector m_Color; //< color+intensity
Vector m_Color; //< color+intensity
Vector m_Position; //< light source center position
Vector m_Direction; //< for SPOT, direction it is pointing
float m_Range; //< distance range for light.0=infinite
@@ -60,6 +60,7 @@ public:
LightDesc_t(void)
{
m_Type = MATERIAL_LIGHT_DISABLE;
}
// constructors for various useful subtypes

View File

@@ -23,6 +23,10 @@
#include "tier0/dbg.h"
#include "mathlib/math_pfns.h"
#ifdef __arm__
#include "sse2neon.h"
#endif
// forward declarations
class Vector;
class Vector2D;
@@ -141,10 +145,8 @@ public:
inline void Set( vec_t X, vec_t Y, vec_t Z, vec_t W );
inline void InitZero( void );
#ifndef __arm__
inline __m128 &AsM128() { return *(__m128*)&x; }
inline const __m128 &AsM128() const { return *(const __m128*)&x; }
#endif
private:
// No copy constructors allowed if we're in optimal mode
@@ -616,9 +618,7 @@ inline void Vector4DAligned::Set( vec_t X, vec_t Y, vec_t Z, vec_t W )
inline void Vector4DAligned::InitZero( void )
{
#if defined (__arm__)
x = y = z = w = 0;
#elif !defined( _X360 )
#if !defined( _X360 )
this->AsM128() = _mm_set1_ps( 0.0f );
#else
this->AsM128() = __vspltisw( 0 );
@@ -629,7 +629,7 @@ inline void Vector4DAligned::InitZero( void )
inline void Vector4DMultiplyAligned( Vector4DAligned const& a, Vector4DAligned const& b, Vector4DAligned& c )
{
Assert( a.IsValid() && b.IsValid() );
#if !defined( _X360 ) || defined (__arm__)
#if !defined( _X360 )
c.x = a.x * b.x;
c.y = a.y * b.y;
c.z = a.z * b.z;
@@ -643,7 +643,7 @@ inline void Vector4DWeightMAD( vec_t w, Vector4DAligned const& vInA, Vector4DAli
{
Assert( vInA.IsValid() && vInB.IsValid() && IsFinite(w) );
#if !defined( _X360 ) || defined (__arm__)
#if !defined( _X360 )
vOutA.x += vInA.x * w;
vOutA.y += vInA.y * w;
vOutA.z += vInA.z * w;
@@ -664,7 +664,6 @@ inline void Vector4DWeightMAD( vec_t w, Vector4DAligned const& vInA, Vector4DAli
#endif
}
#ifndef __arm__
inline void Vector4DWeightMADSSE( vec_t w, Vector4DAligned const& vInA, Vector4DAligned& vOutA, Vector4DAligned const& vInB, Vector4DAligned& vOutB )
{
Assert( vInA.IsValid() && vInB.IsValid() && IsFinite(w) );
@@ -686,7 +685,6 @@ inline void Vector4DWeightMADSSE( vec_t w, Vector4DAligned const& vInA, Vector4D
vOutB.AsM128() = __vmaddfp( vInB.AsM128(), temp, vOutB.AsM128() );
#endif
}
#endif
#endif // VECTOR4D_H

View File

@@ -423,6 +423,12 @@ void MatrixInverseTranspose( const VMatrix& src, VMatrix& dst );
//-----------------------------------------------------------------------------
inline VMatrix::VMatrix()
{
Init(
0.f, 0.f, 0.f, 0.f,
0.f, 0.f, 0.f, 0.f,
0.f, 0.f, 0.f, 0.f,
0.f, 0.f, 0.f, 0.f
);
}
inline VMatrix::VMatrix(