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
|
||||
{
|
||||
assert(idx < 6);
|
||||
if (idx < 3)
|
||||
return min[idx];
|
||||
else
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <athena/FileWriter.hpp>
|
||||
#endif
|
||||
#include <iostream>
|
||||
#include <assert.h>
|
||||
|
||||
#undef min
|
||||
#undef max
|
||||
|
@ -275,8 +276,8 @@ public:
|
|||
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 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 const float& operator[](const size_t& idx) const { 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 { assert(idx < 4); return (&r)[idx]; }
|
||||
inline void splat(float rgb, float a)
|
||||
{
|
||||
#if __SSE__
|
||||
|
|
|
@ -57,8 +57,8 @@ public:
|
|||
|
||||
const CVector3f& normal() const { return vec; }
|
||||
|
||||
inline float& operator[](size_t idx) { return p[idx]; }
|
||||
inline const float& operator[](size_t idx) const { return p[idx]; }
|
||||
inline float& operator[](size_t idx) { assert(idx < 4); return p[idx]; }
|
||||
inline const float& operator[](size_t idx) const { assert(idx < 4); return p[idx]; }
|
||||
|
||||
union {
|
||||
struct
|
||||
|
|
|
@ -283,8 +283,8 @@ public:
|
|||
|
||||
CRelAngle angleFrom(const zeus::CQuaternion& other);
|
||||
|
||||
inline float& operator[](size_t idx) { return (&w)[idx]; }
|
||||
inline const float& operator[](size_t idx) const { return (&w)[idx]; }
|
||||
inline float& operator[](size_t idx) { assert(idx < 4); return (&w)[idx]; }
|
||||
inline const float& operator[](size_t idx) const { assert(idx < 4); return (&w)[idx]; }
|
||||
|
||||
union
|
||||
{
|
||||
|
@ -336,8 +336,8 @@ public:
|
|||
CNUQuaternion operator*(float f) const;
|
||||
const CNUQuaternion& operator+=(const CNUQuaternion& q);
|
||||
|
||||
inline float& operator[](size_t idx) { return (&w)[idx]; }
|
||||
inline const float& operator[](size_t idx) const { return (&w)[idx]; }
|
||||
inline float& operator[](size_t idx) { assert(idx < 4); return (&w)[idx]; }
|
||||
inline const float& operator[](size_t idx) const { assert(idx < 4); return (&w)[idx]; }
|
||||
|
||||
union
|
||||
{
|
||||
|
|
|
@ -347,8 +347,8 @@ public:
|
|||
return (diffVec.x <= epsilon && diffVec.y <= epsilon);
|
||||
}
|
||||
|
||||
inline float& operator[](size_t idx) { return (&x)[idx]; }
|
||||
inline const float& operator[](size_t idx) const { return (&x)[idx]; }
|
||||
inline float& operator[](size_t idx) { assert(idx < 2); return (&x)[idx]; }
|
||||
inline const float& operator[](size_t idx) const { assert(idx < 2); return (&x)[idx]; }
|
||||
|
||||
static const CVector2f skOne;
|
||||
static const CVector2f skNegOne;
|
||||
|
|
|
@ -185,8 +185,8 @@ public:
|
|||
#endif
|
||||
}
|
||||
|
||||
inline double& operator[](size_t idx) { return v[idx]; }
|
||||
inline const double& operator[](size_t idx) const { return v[idx]; }
|
||||
inline double& operator[](size_t idx) { assert(idx < 3); return v[idx]; }
|
||||
inline const double& operator[](size_t idx) const { assert(idx < 3); return v[idx]; }
|
||||
|
||||
union {
|
||||
struct
|
||||
|
|
|
@ -375,8 +375,8 @@ public:
|
|||
return (diffVec.x <= epsilon && diffVec.y <= epsilon && diffVec.z <= epsilon);
|
||||
}
|
||||
|
||||
inline float& operator[](size_t idx) { return (&x)[idx]; }
|
||||
inline const float& operator[](size_t idx) const { return (&x)[idx]; }
|
||||
inline float& operator[](size_t idx) { assert(idx < 3); return (&x)[idx]; }
|
||||
inline const float& operator[](size_t idx) const { assert(idx < 3); return (&x)[idx]; }
|
||||
|
||||
static const CVector3f skOne;
|
||||
static const CVector3f skNegOne;
|
||||
|
|
|
@ -376,8 +376,8 @@ public:
|
|||
return (diffVec.x <= epsilon && diffVec.y <= epsilon && diffVec.z <= epsilon && diffVec.w <= epsilon);
|
||||
}
|
||||
|
||||
inline float& operator[](size_t idx) { return (&x)[idx]; }
|
||||
inline const float& operator[](size_t idx) const { return (&x)[idx]; }
|
||||
inline float& operator[](size_t idx) { assert(idx < 4); return (&x)[idx]; }
|
||||
inline const float& operator[](size_t idx) const { assert(idx < 4); return (&x)[idx]; }
|
||||
|
||||
static const CVector4f skOne;
|
||||
static const CVector4f skNegOne;
|
||||
|
|
Loading…
Reference in New Issue