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:
Lioncash 2019-09-01 21:53:55 -04:00
parent 050e86aae8
commit f6854d8e82
8 changed files with 10 additions and 10 deletions

View File

@ -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

View File

@ -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);

View File

@ -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;

View File

@ -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);
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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));
}