mirror of https://github.com/AxioDL/zeus.git
Warning avoidance
This commit is contained in:
parent
d135dee556
commit
b1b4903cb1
|
@ -191,24 +191,27 @@ public:
|
|||
{
|
||||
float sinT = std::sin(theta);
|
||||
float cosT = std::cos(theta);
|
||||
return CMatrix3f(TVectorUnion{1.f, 0.f, 0.f, 0.f}, TVectorUnion{0.f, cosT, sinT, 0.f},
|
||||
TVectorUnion{0.f, -sinT, cosT, 0.f});
|
||||
return CMatrix3f(TVectorUnion{{1.f, 0.f, 0.f, 0.f}},
|
||||
TVectorUnion{{0.f, cosT, sinT, 0.f}},
|
||||
TVectorUnion{{0.f, -sinT, cosT, 0.f}});
|
||||
}
|
||||
|
||||
static inline CMatrix3f RotateY(float theta)
|
||||
{
|
||||
float sinT = std::sin(theta);
|
||||
float cosT = std::cos(theta);
|
||||
return CMatrix3f(TVectorUnion{cosT, 0.f, -sinT, 0.f}, TVectorUnion{0.f, 1.f, 0.f, 0.f},
|
||||
TVectorUnion{sinT, 0.f, cosT, 0.f});
|
||||
return CMatrix3f(TVectorUnion{{cosT, 0.f, -sinT, 0.f}},
|
||||
TVectorUnion{{0.f, 1.f, 0.f, 0.f}},
|
||||
TVectorUnion{{sinT, 0.f, cosT, 0.f}});
|
||||
}
|
||||
|
||||
static inline CMatrix3f RotateZ(float theta)
|
||||
{
|
||||
float sinT = std::sin(theta);
|
||||
float cosT = std::cos(theta);
|
||||
return CMatrix3f(TVectorUnion{cosT, sinT, 0.f, 0.f}, TVectorUnion{-sinT, cosT, 0.f, 0.f},
|
||||
TVectorUnion{0.f, 0.f, 1.f, 0.f});
|
||||
return CMatrix3f(TVectorUnion{{cosT, sinT, 0.f, 0.f}},
|
||||
TVectorUnion{{-sinT, cosT, 0.f, 0.f}},
|
||||
TVectorUnion{{0.f, 0.f, 1.f, 0.f}});
|
||||
}
|
||||
|
||||
float determinant() const
|
||||
|
@ -228,7 +231,7 @@ public:
|
|||
};
|
||||
};
|
||||
|
||||
static CMatrix3f operator*(const CMatrix3f& lhs, const CMatrix3f& rhs)
|
||||
static inline CMatrix3f operator*(const CMatrix3f& lhs, const CMatrix3f& rhs)
|
||||
{
|
||||
#if __SSE__
|
||||
unsigned i;
|
||||
|
|
|
@ -80,24 +80,27 @@ public:
|
|||
{
|
||||
float sinT = std::sin(theta);
|
||||
float cosT = std::cos(theta);
|
||||
return CTransform(CMatrix3f(TVectorUnion{1.f, 0.f, 0.f, 0.f}, TVectorUnion{0.f, cosT, sinT, 0.f},
|
||||
TVectorUnion{0.f, -sinT, cosT, 0.f}));
|
||||
return CTransform(CMatrix3f(TVectorUnion{{1.f, 0.f, 0.f, 0.f}},
|
||||
TVectorUnion{{0.f, cosT, sinT, 0.f}},
|
||||
TVectorUnion{{0.f, -sinT, cosT, 0.f}}));
|
||||
}
|
||||
|
||||
static inline CTransform RotateY(float theta)
|
||||
{
|
||||
float sinT = std::sin(theta);
|
||||
float cosT = std::cos(theta);
|
||||
return CTransform(CMatrix3f(TVectorUnion{cosT, 0.f, -sinT, 0.f}, TVectorUnion{0.f, 1.f, 0.f, 0.f},
|
||||
TVectorUnion{sinT, 0.f, cosT, 0.f}));
|
||||
return CTransform(CMatrix3f(TVectorUnion{{cosT, 0.f, -sinT, 0.f}},
|
||||
TVectorUnion{{0.f, 1.f, 0.f, 0.f}},
|
||||
TVectorUnion{{sinT, 0.f, cosT, 0.f}}));
|
||||
}
|
||||
|
||||
static inline CTransform RotateZ(float theta)
|
||||
{
|
||||
float sinT = std::sin(theta);
|
||||
float cosT = std::cos(theta);
|
||||
return CTransform(CMatrix3f(TVectorUnion{cosT, sinT, 0.f, 0.f}, TVectorUnion{-sinT, cosT, 0.f, 0.f},
|
||||
TVectorUnion{0.f, 0.f, 1.f, 0.f}));
|
||||
return CTransform(CMatrix3f(TVectorUnion{{cosT, sinT, 0.f, 0.f}},
|
||||
TVectorUnion{{-sinT, cosT, 0.f, 0.f}},
|
||||
TVectorUnion{{0.f, 0.f, 1.f, 0.f}}));
|
||||
}
|
||||
|
||||
inline void rotateLocalX(float theta)
|
||||
|
@ -161,20 +164,24 @@ public:
|
|||
|
||||
static inline CTransform Scale(const CVector3f& factor)
|
||||
{
|
||||
return CTransform(CMatrix3f(TVectorUnion{factor.x, 0.f, 0.f, 0.f}, TVectorUnion{0.f, factor.y, 0.f, 0.f},
|
||||
TVectorUnion{0.f, 0.f, factor.z, 0.f}));
|
||||
return CTransform(CMatrix3f(TVectorUnion{{factor.x, 0.f, 0.f, 0.f}},
|
||||
TVectorUnion{{0.f, factor.y, 0.f, 0.f}},
|
||||
TVectorUnion{{0.f, 0.f, factor.z, 0.f}}));
|
||||
}
|
||||
|
||||
static inline CTransform Scale(float x, float y, float z)
|
||||
{
|
||||
return CTransform(
|
||||
CMatrix3f(TVectorUnion{x, 0.f, 0.f, 0.f}, TVectorUnion{0.f, y, 0.f, 0.f}, TVectorUnion{0.f, 0.f, z, 0.f}));
|
||||
CMatrix3f(TVectorUnion{{x, 0.f, 0.f, 0.f}},
|
||||
TVectorUnion{{0.f, y, 0.f, 0.f}},
|
||||
TVectorUnion{{0.f, 0.f, z, 0.f}}));
|
||||
}
|
||||
|
||||
static inline CTransform Scale(float factor)
|
||||
{
|
||||
return CTransform(CMatrix3f(TVectorUnion{factor, 0.f, 0.f, 0.f}, TVectorUnion{0.f, factor, 0.f, 0.f},
|
||||
TVectorUnion{0.f, 0.f, factor, 0.f}));
|
||||
return CTransform(CMatrix3f(TVectorUnion{{factor, 0.f, 0.f, 0.f}},
|
||||
TVectorUnion{{0.f, factor, 0.f, 0.f}},
|
||||
TVectorUnion{{0.f, 0.f, factor, 0.f}}));
|
||||
}
|
||||
|
||||
inline CTransform multiplyIgnoreTranslation(const CTransform& xfrm)
|
||||
|
|
|
@ -63,10 +63,10 @@ public:
|
|||
CVector3d(double x, double y, double z)
|
||||
{
|
||||
#if __AVX__
|
||||
TDblVectorUnion splat{x, y, z, 0.0};
|
||||
TDblVectorUnion splat{{x, y, z, 0.0}};
|
||||
mVec256 = splat.mVec256;
|
||||
#elif __SSE__
|
||||
TDblVectorUnion splat{x, y, z, 0.0};
|
||||
TDblVectorUnion splat{{x, y, z, 0.0}};
|
||||
mVec128[0] = splat.mVec128[0];
|
||||
mVec128[1] = splat.mVec128[1];
|
||||
#else
|
||||
|
@ -136,10 +136,10 @@ public:
|
|||
void splat(double xyz)
|
||||
{
|
||||
#if __AVX__
|
||||
TDblVectorUnion splat = {xyz, xyz, xyz, 0.0};
|
||||
TDblVectorUnion splat = {{xyz, xyz, xyz, 0.0}};
|
||||
mVec256 = splat.mVec256;
|
||||
#elif __SSE__
|
||||
TDblVectorUnion splat = {xyz, xyz, xyz, 0.0};
|
||||
TDblVectorUnion splat = {{xyz, xyz, xyz, 0.0}};
|
||||
mVec128[0] = splat.mVec128[0];
|
||||
mVec128[1] = splat.mVec128[1];
|
||||
#else
|
||||
|
@ -227,10 +227,10 @@ public:
|
|||
static inline CVector3d operator+(double lhs, const CVector3d& rhs)
|
||||
{
|
||||
#if __AVX__
|
||||
TDblVectorUnion splat{lhs, lhs, lhs, 0};
|
||||
TDblVectorUnion splat{{lhs, lhs, lhs, 0}};
|
||||
return _mm256_add_pd(splat.mVec256, rhs.mVec256);
|
||||
#elif __SSE__
|
||||
TDblVectorUnion splat{lhs, lhs, lhs, 0};
|
||||
TDblVectorUnion splat{{lhs, lhs, lhs, 0}};
|
||||
splat.mVec128[0] = _mm_add_pd(splat.mVec128[0], rhs.mVec128[0]);
|
||||
splat.mVec128[1] = _mm_add_pd(splat.mVec128[1], rhs.mVec128[1]);
|
||||
return {splat.mVec128};
|
||||
|
@ -242,10 +242,10 @@ static inline CVector3d operator+(double lhs, const CVector3d& rhs)
|
|||
static inline CVector3d operator-(double lhs, const CVector3d& rhs)
|
||||
{
|
||||
#if __AVX__
|
||||
TDblVectorUnion splat{lhs, lhs, lhs, 0};
|
||||
TDblVectorUnion splat{{lhs, lhs, lhs, 0}};
|
||||
return _mm256_sub_pd(splat.mVec256, rhs.mVec256);
|
||||
#elif __SSE__
|
||||
TDblVectorUnion splat{lhs, lhs, lhs, 0};
|
||||
TDblVectorUnion splat{{lhs, lhs, lhs, 0}};
|
||||
splat.mVec128[0] = _mm_sub_pd(splat.mVec128[0], rhs.mVec128[0]);
|
||||
splat.mVec128[1] = _mm_sub_pd(splat.mVec128[1], rhs.mVec128[1]);
|
||||
return {splat.mVec128};
|
||||
|
@ -257,10 +257,10 @@ static inline CVector3d operator-(double lhs, const CVector3d& rhs)
|
|||
static inline CVector3d operator*(double lhs, const CVector3d& rhs)
|
||||
{
|
||||
#if __AVX__
|
||||
TDblVectorUnion splat{lhs, lhs, lhs, 0};
|
||||
TDblVectorUnion splat{{lhs, lhs, lhs, 0}};
|
||||
return _mm256_mul_pd(splat.mVec256, rhs.mVec256);
|
||||
#elif __SSE__
|
||||
TDblVectorUnion splat{lhs, lhs, lhs, 0};
|
||||
TDblVectorUnion splat{{lhs, lhs, lhs, 0}};
|
||||
splat.mVec128[0] = _mm_mul_pd(splat.mVec128[0], rhs.mVec128[0]);
|
||||
splat.mVec128[1] = _mm_mul_pd(splat.mVec128[1], rhs.mVec128[1]);
|
||||
return {splat.mVec128};
|
||||
|
@ -272,10 +272,10 @@ static inline CVector3d operator*(double lhs, const CVector3d& rhs)
|
|||
static inline CVector3d operator/(double lhs, const CVector3d& rhs)
|
||||
{
|
||||
#if __AVX__
|
||||
TDblVectorUnion splat{lhs, lhs, lhs, 0};
|
||||
TDblVectorUnion splat{{lhs, lhs, lhs, 0}};
|
||||
return _mm256_div_pd(splat.mVec256, rhs.mVec256);
|
||||
#elif __SSE__
|
||||
TDblVectorUnion splat{lhs, lhs, lhs, 0};
|
||||
TDblVectorUnion splat{{lhs, lhs, lhs, 0}};
|
||||
splat.mVec128[0] = _mm_div_pd(splat.mVec128[0], rhs.mVec128[0]);
|
||||
splat.mVec128[1] = _mm_div_pd(splat.mVec128[1], rhs.mVec128[1]);
|
||||
return {splat.mVec128};
|
||||
|
|
|
@ -31,18 +31,18 @@ int main()
|
|||
CAABox test3{{-50, -50, -50}, {50, 50, 50}};
|
||||
CAABox test4{{-50, -50, -105}, {50, 50, 105}};
|
||||
CVector3f point(-90, 67, -105);
|
||||
CVector3f closestPoint = test.closestPointAlongVector(point);
|
||||
CVector3d doubleVec(100, -100, -200);
|
||||
test.closestPointAlongVector(point);
|
||||
CVector3d(100, -100, -200);
|
||||
zeus::CAABox aabb1{208.9f, -83.9f, 17.7f, 211.9f, -80.9f, 25.7f};
|
||||
zeus::CVector3f center1 = aabb1.center();
|
||||
zeus::CVector3f extents1 = aabb1.extents() * 2.f;
|
||||
aabb1.center();
|
||||
aabb1.extents() * 2.f;
|
||||
zeus::CAABox aabb2{211.8f, -81.4f, 22.3f, 212.8f, -80.4f, 25.0f};
|
||||
zeus::CVector3f center2 = aabb2.center();
|
||||
zeus::CVector3f extents2 = aabb2.extents() * 2.f;
|
||||
aabb2.center();
|
||||
aabb2.extents() * 2.f;
|
||||
|
||||
zeus::CAABox diffAABB = aabb1.booleanIntersection(aabb2);
|
||||
zeus::CVector3f centerDiff = aabb2.center();
|
||||
zeus::CVector3f extentsDiff = aabb2.extents() * 2.f;
|
||||
aabb1.booleanIntersection(aabb2);
|
||||
aabb2.center();
|
||||
aabb2.extents() * 2.f;
|
||||
|
||||
assert(t.isEqu(t));
|
||||
assert(test.inside(test));
|
||||
|
@ -67,7 +67,7 @@ int main()
|
|||
std::cout << " Test 1 " << (aabb.intersects(s1) ? "succeeded" : "failed") << std::endl;
|
||||
std::cout << " Test 2 " << (aabb.intersects(s2) ? "succeeded" : "failed") << std::endl;
|
||||
std::cout << " Test 3 " << (aabb.intersects(s3) ? "succeeded" : "failed") << std::endl;
|
||||
CLineSeg line({-89.120926f, 59.328712f, 3.265882f}, {-90.120926f, 59.328712f, 3.265882f});
|
||||
CLineSeg({-89.120926f, 59.328712f, 3.265882f}, {-90.120926f, 59.328712f, 3.265882f});
|
||||
|
||||
CColor ctest1;
|
||||
ctest1.fromHSV(0, 255 / 255.f, .5);
|
||||
|
|
Loading…
Reference in New Issue