mirror of https://github.com/AxioDL/zeus.git
General: Mark member functions as const where applicable
These don't modify internal member state, so they can be const.
This commit is contained in:
parent
050e86aae8
commit
f6854d8e82
|
@ -46,6 +46,6 @@ public:
|
|||
|
||||
bool OBBIntersectsBox(const COBBox& other) const;
|
||||
|
||||
bool AABoxIntersectsBox(const CAABox& other) { return OBBIntersectsBox(FromAABox(other, CTransform())); }
|
||||
bool AABoxIntersectsBox(const CAABox& other) const { return OBBIntersectsBox(FromAABox(other, CTransform())); }
|
||||
};
|
||||
} // namespace zeus
|
||||
|
|
|
@ -199,7 +199,7 @@ public:
|
|||
z() = i.z();
|
||||
}
|
||||
|
||||
CRelAngle angleFrom(const zeus::CQuaternion& other);
|
||||
CRelAngle angleFrom(const zeus::CQuaternion& other) const;
|
||||
|
||||
simd<float>::reference operator[](size_t idx) {
|
||||
assert(idx < 4);
|
||||
|
|
|
@ -52,14 +52,14 @@ public:
|
|||
|
||||
static CTransform Translate(float x, float y, float z) { return Translate({x, y, z}); }
|
||||
|
||||
CTransform operator+(const CVector3f& other) { return CTransform(basis, origin + other); }
|
||||
CTransform operator+(const CVector3f& other) const { return CTransform(basis, origin + other); }
|
||||
|
||||
CTransform& operator+=(const CVector3f& other) {
|
||||
origin += other;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CTransform operator-(const CVector3f& other) { return CTransform(basis, origin - other); }
|
||||
CTransform operator-(const CVector3f& other) const { return CTransform(basis, origin - other); }
|
||||
|
||||
CTransform& operator-=(const CVector3f& other) {
|
||||
origin -= other;
|
||||
|
|
|
@ -172,7 +172,7 @@ public:
|
|||
|
||||
bool isZero() const { return magSquared() <= FLT_EPSILON; }
|
||||
|
||||
bool isEqu(const CVector2f& other, float epsilon = FLT_EPSILON) {
|
||||
bool isEqu(const CVector2f& other, float epsilon = FLT_EPSILON) const {
|
||||
const CVector2f diffVec = other - *this;
|
||||
return (diffVec.x() <= epsilon && diffVec.y() <= epsilon);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ public:
|
|||
|
||||
constexpr CVector3d(double x, double y, double z) : mSimd(x, y, z) {}
|
||||
|
||||
CVector3f asCVector3f() { return mSimd; }
|
||||
CVector3f asCVector3f() const { return mSimd; }
|
||||
|
||||
double magSquared() const { return mSimd.dot3(mSimd); }
|
||||
|
||||
|
@ -41,7 +41,7 @@ public:
|
|||
|
||||
double dot(const CVector3d& rhs) const { return mSimd.dot3(rhs.mSimd); }
|
||||
|
||||
CVector3d asNormalized() {
|
||||
CVector3d asNormalized() const {
|
||||
double mag = magnitude();
|
||||
mag = 1.0 / mag;
|
||||
return mSimd * zeus::simd<double>(mag);
|
||||
|
|
|
@ -180,7 +180,7 @@ public:
|
|||
return v;
|
||||
}
|
||||
|
||||
bool isEqu(const CVector3f& other, float epsilon = FLT_EPSILON) {
|
||||
bool isEqu(const CVector3f& other, float epsilon = FLT_EPSILON) const {
|
||||
const CVector3f diffVec = other - *this;
|
||||
return (diffVec.x() <= epsilon && diffVec.y() <= epsilon && diffVec.z() <= epsilon);
|
||||
}
|
||||
|
|
|
@ -166,7 +166,7 @@ public:
|
|||
std::fabs(w()) >= FLT_EPSILON;
|
||||
}
|
||||
|
||||
bool isEqu(const CVector4f& other, float epsilon = FLT_EPSILON) {
|
||||
bool isEqu(const CVector4f& other, float epsilon = FLT_EPSILON) const {
|
||||
const CVector4f diffVec = other - *this;
|
||||
return (diffVec.x() <= epsilon && diffVec.y() <= epsilon && diffVec.z() <= epsilon && diffVec.w() <= epsilon);
|
||||
}
|
||||
|
|
|
@ -226,7 +226,7 @@ CQuaternion CQuaternion::buildEquivalent() const {
|
|||
return CQuaternion::fromAxisAngle(CUnitVector3f(mSimd.shuffle<1, 2, 3, 3>()), tmp + 2.0 * M_PI);
|
||||
}
|
||||
|
||||
CRelAngle CQuaternion::angleFrom(const zeus::CQuaternion& other) {
|
||||
CRelAngle CQuaternion::angleFrom(const zeus::CQuaternion& other) const {
|
||||
return std::acos(zeus::clamp(-1.f, dot(other), 1.f));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue