mirror of https://github.com/AxioDL/zeus.git
Add operator[] asserts
This commit is contained in:
parent
c5f9137df8
commit
bad3038132
|
@ -417,6 +417,7 @@ public:
|
||||||
|
|
||||||
inline float operator[](size_t idx) const
|
inline float operator[](size_t idx) const
|
||||||
{
|
{
|
||||||
|
assert(idx < 6);
|
||||||
if (idx < 3)
|
if (idx < 3)
|
||||||
return min[idx];
|
return min[idx];
|
||||||
else
|
else
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <athena/FileWriter.hpp>
|
#include <athena/FileWriter.hpp>
|
||||||
#endif
|
#endif
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#undef min
|
#undef min
|
||||||
#undef max
|
#undef max
|
||||||
|
@ -275,8 +276,8 @@ public:
|
||||||
inline float magnitude() const { return std::sqrt(magSquared()); }
|
inline float magnitude() const { return std::sqrt(magSquared()); }
|
||||||
static inline CColor lerp(const CColor& a, const CColor& b, float t) { return (a + (b - a) * t); }
|
static inline CColor lerp(const CColor& a, const CColor& b, float t) { return (a + (b - a) * t); }
|
||||||
static inline CColor nlerp(const CColor& a, const CColor& b, float t) { return lerp(a, b, t).normalized(); }
|
static inline CColor nlerp(const CColor& a, const CColor& b, float t) { return lerp(a, b, t).normalized(); }
|
||||||
inline float& operator[](const size_t& idx) { return (&r)[idx]; }
|
inline float& operator[](const size_t& idx) { assert(idx < 4); return (&r)[idx]; }
|
||||||
inline const float& operator[](const size_t& idx) const { return (&r)[idx]; }
|
inline const float& operator[](const size_t& idx) const { assert(idx < 4); return (&r)[idx]; }
|
||||||
inline void splat(float rgb, float a)
|
inline void splat(float rgb, float a)
|
||||||
{
|
{
|
||||||
#if __SSE__
|
#if __SSE__
|
||||||
|
|
|
@ -57,8 +57,8 @@ public:
|
||||||
|
|
||||||
const CVector3f& normal() const { return vec; }
|
const CVector3f& normal() const { return vec; }
|
||||||
|
|
||||||
inline float& operator[](size_t idx) { return p[idx]; }
|
inline float& operator[](size_t idx) { assert(idx < 4); return p[idx]; }
|
||||||
inline const float& operator[](size_t idx) const { return p[idx]; }
|
inline const float& operator[](size_t idx) const { assert(idx < 4); return p[idx]; }
|
||||||
|
|
||||||
union {
|
union {
|
||||||
struct
|
struct
|
||||||
|
|
|
@ -283,8 +283,8 @@ public:
|
||||||
|
|
||||||
CRelAngle angleFrom(const zeus::CQuaternion& other);
|
CRelAngle angleFrom(const zeus::CQuaternion& other);
|
||||||
|
|
||||||
inline float& operator[](size_t idx) { return (&w)[idx]; }
|
inline float& operator[](size_t idx) { assert(idx < 4); return (&w)[idx]; }
|
||||||
inline const float& operator[](size_t idx) const { return (&w)[idx]; }
|
inline const float& operator[](size_t idx) const { assert(idx < 4); return (&w)[idx]; }
|
||||||
|
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
|
@ -336,8 +336,8 @@ public:
|
||||||
CNUQuaternion operator*(float f) const;
|
CNUQuaternion operator*(float f) const;
|
||||||
const CNUQuaternion& operator+=(const CNUQuaternion& q);
|
const CNUQuaternion& operator+=(const CNUQuaternion& q);
|
||||||
|
|
||||||
inline float& operator[](size_t idx) { return (&w)[idx]; }
|
inline float& operator[](size_t idx) { assert(idx < 4); return (&w)[idx]; }
|
||||||
inline const float& operator[](size_t idx) const { return (&w)[idx]; }
|
inline const float& operator[](size_t idx) const { assert(idx < 4); return (&w)[idx]; }
|
||||||
|
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
|
|
|
@ -347,8 +347,8 @@ public:
|
||||||
return (diffVec.x <= epsilon && diffVec.y <= epsilon);
|
return (diffVec.x <= epsilon && diffVec.y <= epsilon);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline float& operator[](size_t idx) { return (&x)[idx]; }
|
inline float& operator[](size_t idx) { assert(idx < 2); return (&x)[idx]; }
|
||||||
inline const float& operator[](size_t idx) const { return (&x)[idx]; }
|
inline const float& operator[](size_t idx) const { assert(idx < 2); return (&x)[idx]; }
|
||||||
|
|
||||||
static const CVector2f skOne;
|
static const CVector2f skOne;
|
||||||
static const CVector2f skNegOne;
|
static const CVector2f skNegOne;
|
||||||
|
|
|
@ -185,8 +185,8 @@ public:
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double& operator[](size_t idx) { return v[idx]; }
|
inline double& operator[](size_t idx) { assert(idx < 3); return v[idx]; }
|
||||||
inline const double& operator[](size_t idx) const { return v[idx]; }
|
inline const double& operator[](size_t idx) const { assert(idx < 3); return v[idx]; }
|
||||||
|
|
||||||
union {
|
union {
|
||||||
struct
|
struct
|
||||||
|
|
|
@ -375,8 +375,8 @@ public:
|
||||||
return (diffVec.x <= epsilon && diffVec.y <= epsilon && diffVec.z <= epsilon);
|
return (diffVec.x <= epsilon && diffVec.y <= epsilon && diffVec.z <= epsilon);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline float& operator[](size_t idx) { return (&x)[idx]; }
|
inline float& operator[](size_t idx) { assert(idx < 3); return (&x)[idx]; }
|
||||||
inline const float& operator[](size_t idx) const { return (&x)[idx]; }
|
inline const float& operator[](size_t idx) const { assert(idx < 3); return (&x)[idx]; }
|
||||||
|
|
||||||
static const CVector3f skOne;
|
static const CVector3f skOne;
|
||||||
static const CVector3f skNegOne;
|
static const CVector3f skNegOne;
|
||||||
|
|
|
@ -376,8 +376,8 @@ public:
|
||||||
return (diffVec.x <= epsilon && diffVec.y <= epsilon && diffVec.z <= epsilon && diffVec.w <= epsilon);
|
return (diffVec.x <= epsilon && diffVec.y <= epsilon && diffVec.z <= epsilon && diffVec.w <= epsilon);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline float& operator[](size_t idx) { return (&x)[idx]; }
|
inline float& operator[](size_t idx) { assert(idx < 4); return (&x)[idx]; }
|
||||||
inline const float& operator[](size_t idx) const { return (&x)[idx]; }
|
inline const float& operator[](size_t idx) const { assert(idx < 4); return (&x)[idx]; }
|
||||||
|
|
||||||
static const CVector4f skOne;
|
static const CVector4f skOne;
|
||||||
static const CVector4f skNegOne;
|
static const CVector4f skNegOne;
|
||||||
|
|
Loading…
Reference in New Issue