mirror of https://github.com/AxioDL/zeus.git
constexpr fixes
This commit is contained in:
parent
82a3a0def9
commit
fc33e18b4a
|
@ -48,19 +48,28 @@ public:
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] CQuaternion operator+(const CQuaternion& q) const { return mSimd + q.mSimd; }
|
[[nodiscard]] constexpr CQuaternion operator+(const CQuaternion& q) const { return mSimd + q.mSimd; }
|
||||||
|
|
||||||
[[nodiscard]] CQuaternion operator-(const CQuaternion& q) const { return mSimd - q.mSimd; }
|
[[nodiscard]] constexpr CQuaternion operator-(const CQuaternion& q) const { return mSimd - q.mSimd; }
|
||||||
|
|
||||||
[[nodiscard]] CQuaternion operator*(const CQuaternion& q) const;
|
[[nodiscard]] constexpr CQuaternion operator*(const CQuaternion& q) const {
|
||||||
|
return CQuaternion(w() * q.w() - CVector3f(x(), y(), z()).dot({q.x(), q.y(), q.z()}),
|
||||||
|
y() * q.z() - z() * q.y() + w() * q.x() + x() * q.w(),
|
||||||
|
z() * q.x() - x() * q.z() + w() * q.y() + y() * q.w(),
|
||||||
|
x() * q.y() - y() * q.x() + w() * q.z() + z() * q.w());
|
||||||
|
}
|
||||||
|
|
||||||
[[nodiscard]] CQuaternion operator/(const CQuaternion& q) const;
|
[[nodiscard]] constexpr CQuaternion operator/(const CQuaternion& q) const {
|
||||||
|
CQuaternion p(q);
|
||||||
|
p.invert();
|
||||||
|
return *this * p;
|
||||||
|
}
|
||||||
|
|
||||||
[[nodiscard]] CQuaternion operator*(float scale) const { return mSimd * simd<float>(scale); }
|
[[nodiscard]] constexpr CQuaternion operator*(float scale) const { return mSimd * simd<float>(scale); }
|
||||||
|
|
||||||
[[nodiscard]] CQuaternion operator/(float scale) const { return mSimd / simd<float>(scale); }
|
[[nodiscard]] constexpr CQuaternion operator/(float scale) const { return mSimd / simd<float>(scale); }
|
||||||
|
|
||||||
[[nodiscard]] CQuaternion operator-() const { return -mSimd; }
|
[[nodiscard]] constexpr CQuaternion operator-() const { return -mSimd; }
|
||||||
|
|
||||||
const CQuaternion& operator+=(const CQuaternion& q) {
|
const CQuaternion& operator+=(const CQuaternion& q) {
|
||||||
mSimd += q.mSimd;
|
mSimd += q.mSimd;
|
||||||
|
@ -211,9 +220,9 @@ public:
|
||||||
*/
|
*/
|
||||||
class CNUQuaternion {
|
class CNUQuaternion {
|
||||||
public:
|
public:
|
||||||
CNUQuaternion() : mSimd(1.f, 0.f, 0.f, 0.f) {}
|
constexpr CNUQuaternion() : mSimd(1.f, 0.f, 0.f, 0.f) {}
|
||||||
|
|
||||||
CNUQuaternion(float wi, float xi, float yi, float zi) : mSimd(wi, xi, yi, zi) {}
|
constexpr CNUQuaternion(float wi, float xi, float yi, float zi) : mSimd(wi, xi, yi, zi) {}
|
||||||
|
|
||||||
CNUQuaternion(float win, const zeus::CVector3f& vec) : mSimd(vec.mSimd.shuffle<0, 0, 1, 2>()) { w() = win; }
|
CNUQuaternion(float win, const zeus::CVector3f& vec) : mSimd(vec.mSimd.shuffle<0, 0, 1, 2>()) { w() = win; }
|
||||||
|
|
||||||
|
@ -241,7 +250,12 @@ public:
|
||||||
return mSimd * simd<float>(magDiv);
|
return mSimd * simd<float>(magDiv);
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] CNUQuaternion operator*(const CNUQuaternion& q) const;
|
[[nodiscard]] constexpr CNUQuaternion operator*(const CNUQuaternion& q) const {
|
||||||
|
return CNUQuaternion(w() * q.w() - CVector3f(x(), y(), z()).dot({q.x(), q.y(), q.z()}),
|
||||||
|
y() * q.z() - z() * q.y() + w() * q.x() + x() * q.w(),
|
||||||
|
z() * q.x() - x() * q.z() + w() * q.y() + y() * q.w(),
|
||||||
|
x() * q.y() - y() * q.x() + w() * q.z() + z() * q.w());
|
||||||
|
}
|
||||||
|
|
||||||
[[nodiscard]] CNUQuaternion operator*(float f) const { return mSimd * simd<float>(f); }
|
[[nodiscard]] CNUQuaternion operator*(float f) const { return mSimd * simd<float>(f); }
|
||||||
|
|
||||||
|
|
|
@ -46,23 +46,23 @@ public:
|
||||||
return mSimd[0] >= rhs.mSimd[0] && mSimd[1] >= rhs.mSimd[1];
|
return mSimd[0] >= rhs.mSimd[0] && mSimd[1] >= rhs.mSimd[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] CVector2d operator+(const CVector2d& rhs) const { return mSimd + rhs.mSimd; }
|
[[nodiscard]] constexpr CVector2d operator+(const CVector2d& rhs) const { return mSimd + rhs.mSimd; }
|
||||||
|
|
||||||
[[nodiscard]] CVector2d operator-(const CVector2d& rhs) const { return mSimd - rhs.mSimd; }
|
[[nodiscard]] constexpr CVector2d operator-(const CVector2d& rhs) const { return mSimd - rhs.mSimd; }
|
||||||
|
|
||||||
[[nodiscard]] CVector2d operator-() const { return -mSimd; }
|
[[nodiscard]] constexpr CVector2d operator-() const { return -mSimd; }
|
||||||
|
|
||||||
[[nodiscard]] CVector2d operator*(const CVector2d& rhs) const { return mSimd * rhs.mSimd; }
|
[[nodiscard]] constexpr CVector2d operator*(const CVector2d& rhs) const { return mSimd * rhs.mSimd; }
|
||||||
|
|
||||||
[[nodiscard]] CVector2d operator/(const CVector2d& rhs) const { return mSimd / rhs.mSimd; }
|
[[nodiscard]] constexpr CVector2d operator/(const CVector2d& rhs) const { return mSimd / rhs.mSimd; }
|
||||||
|
|
||||||
[[nodiscard]] CVector2d operator+(double val) const { return mSimd + simd<double>(val); }
|
[[nodiscard]] constexpr CVector2d operator+(double val) const { return mSimd + simd<double>(val); }
|
||||||
|
|
||||||
[[nodiscard]] CVector2d operator-(double val) const { return mSimd - simd<double>(val); }
|
[[nodiscard]] constexpr CVector2d operator-(double val) const { return mSimd - simd<double>(val); }
|
||||||
|
|
||||||
[[nodiscard]] CVector2d operator*(double val) const { return mSimd * simd<double>(val); }
|
[[nodiscard]] constexpr CVector2d operator*(double val) const { return mSimd * simd<double>(val); }
|
||||||
|
|
||||||
[[nodiscard]] CVector2d operator/(double val) const {
|
[[nodiscard]] constexpr CVector2d operator/(double val) const {
|
||||||
double ooval = 1.0 / val;
|
double ooval = 1.0 / val;
|
||||||
return mSimd * simd<double>(ooval);
|
return mSimd * simd<double>(ooval);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,23 +46,23 @@ public:
|
||||||
return mSimd[0] >= rhs.mSimd[0] && mSimd[1] >= rhs.mSimd[1];
|
return mSimd[0] >= rhs.mSimd[0] && mSimd[1] >= rhs.mSimd[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] CVector2f operator+(const CVector2f& rhs) const { return mSimd + rhs.mSimd; }
|
[[nodiscard]] constexpr CVector2f operator+(const CVector2f& rhs) const { return mSimd + rhs.mSimd; }
|
||||||
|
|
||||||
[[nodiscard]] CVector2f operator-(const CVector2f& rhs) const { return mSimd - rhs.mSimd; }
|
[[nodiscard]] constexpr CVector2f operator-(const CVector2f& rhs) const { return mSimd - rhs.mSimd; }
|
||||||
|
|
||||||
[[nodiscard]] CVector2f operator-() const { return -mSimd; }
|
[[nodiscard]] constexpr CVector2f operator-() const { return -mSimd; }
|
||||||
|
|
||||||
[[nodiscard]] CVector2f operator*(const CVector2f& rhs) const { return mSimd * rhs.mSimd; }
|
[[nodiscard]] constexpr CVector2f operator*(const CVector2f& rhs) const { return mSimd * rhs.mSimd; }
|
||||||
|
|
||||||
[[nodiscard]] CVector2f operator/(const CVector2f& rhs) const { return mSimd / rhs.mSimd; }
|
[[nodiscard]] constexpr CVector2f operator/(const CVector2f& rhs) const { return mSimd / rhs.mSimd; }
|
||||||
|
|
||||||
[[nodiscard]] CVector2f operator+(float val) const { return mSimd + simd<float>(val); }
|
[[nodiscard]] constexpr CVector2f operator+(float val) const { return mSimd + simd<float>(val); }
|
||||||
|
|
||||||
[[nodiscard]] CVector2f operator-(float val) const { return mSimd - simd<float>(val); }
|
[[nodiscard]] constexpr CVector2f operator-(float val) const { return mSimd - simd<float>(val); }
|
||||||
|
|
||||||
[[nodiscard]] CVector2f operator*(float val) const { return mSimd * simd<float>(val); }
|
[[nodiscard]] constexpr CVector2f operator*(float val) const { return mSimd * simd<float>(val); }
|
||||||
|
|
||||||
[[nodiscard]] CVector2f operator/(float val) const {
|
[[nodiscard]] constexpr CVector2f operator/(float val) const {
|
||||||
float ooval = 1.f / val;
|
float ooval = 1.f / val;
|
||||||
return mSimd * simd<float>(ooval);
|
return mSimd * simd<float>(ooval);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,13 +43,13 @@ public:
|
||||||
|
|
||||||
void zeroOut() { mSimd = zeus::simd<double>(0.0); }
|
void zeroOut() { mSimd = zeus::simd<double>(0.0); }
|
||||||
|
|
||||||
[[nodiscard]] CVector3d operator+(const CVector3d& rhs) const { return mSimd + rhs.mSimd; }
|
[[nodiscard]] constexpr CVector3d operator+(const CVector3d& rhs) const { return mSimd + rhs.mSimd; }
|
||||||
|
|
||||||
[[nodiscard]] CVector3d operator-(const CVector3d& rhs) const { return mSimd - rhs.mSimd; }
|
[[nodiscard]] constexpr CVector3d operator-(const CVector3d& rhs) const { return mSimd - rhs.mSimd; }
|
||||||
|
|
||||||
[[nodiscard]] CVector3d operator*(const CVector3d& rhs) const { return mSimd * rhs.mSimd; }
|
[[nodiscard]] constexpr CVector3d operator*(const CVector3d& rhs) const { return mSimd * rhs.mSimd; }
|
||||||
|
|
||||||
[[nodiscard]] CVector3d operator/(const CVector3d& rhs) const { return mSimd / rhs.mSimd; }
|
[[nodiscard]] constexpr CVector3d operator/(const CVector3d& rhs) const { return mSimd / rhs.mSimd; }
|
||||||
|
|
||||||
[[nodiscard]] simd<double>::reference operator[](size_t idx) {
|
[[nodiscard]] simd<double>::reference operator[](size_t idx) {
|
||||||
assert(idx < 3);
|
assert(idx < 3);
|
||||||
|
|
|
@ -49,23 +49,23 @@ public:
|
||||||
[[nodiscard]] simd<float>::mask_type operator<(const CVector3f& rhs) const { return mSimd < rhs.mSimd; }
|
[[nodiscard]] simd<float>::mask_type operator<(const CVector3f& rhs) const { return mSimd < rhs.mSimd; }
|
||||||
[[nodiscard]] simd<float>::mask_type operator<=(const CVector3f& rhs) const { return mSimd <= rhs.mSimd; }
|
[[nodiscard]] simd<float>::mask_type operator<=(const CVector3f& rhs) const { return mSimd <= rhs.mSimd; }
|
||||||
|
|
||||||
[[nodiscard]] CVector3f operator+(const CVector3f& rhs) const { return mSimd + rhs.mSimd; }
|
[[nodiscard]] constexpr CVector3f operator+(const CVector3f& rhs) const { return mSimd + rhs.mSimd; }
|
||||||
|
|
||||||
[[nodiscard]] CVector3f operator-(const CVector3f& rhs) const { return mSimd - rhs.mSimd; }
|
[[nodiscard]] constexpr CVector3f operator-(const CVector3f& rhs) const { return mSimd - rhs.mSimd; }
|
||||||
|
|
||||||
[[nodiscard]] CVector3f operator-() const { return -mSimd; }
|
[[nodiscard]] constexpr CVector3f operator-() const { return -mSimd; }
|
||||||
|
|
||||||
[[nodiscard]] CVector3f operator*(const CVector3f& rhs) const { return mSimd * rhs.mSimd; }
|
[[nodiscard]] constexpr CVector3f operator*(const CVector3f& rhs) const { return mSimd * rhs.mSimd; }
|
||||||
|
|
||||||
[[nodiscard]] CVector3f operator/(const CVector3f& rhs) const { return mSimd / rhs.mSimd; }
|
[[nodiscard]] constexpr CVector3f operator/(const CVector3f& rhs) const { return mSimd / rhs.mSimd; }
|
||||||
|
|
||||||
[[nodiscard]] CVector3f operator+(float val) const { return mSimd + val; }
|
[[nodiscard]] constexpr CVector3f operator+(float val) const { return mSimd + val; }
|
||||||
|
|
||||||
[[nodiscard]] CVector3f operator-(float val) const { return mSimd - val; }
|
[[nodiscard]] constexpr CVector3f operator-(float val) const { return mSimd - val; }
|
||||||
|
|
||||||
[[nodiscard]] CVector3f operator*(float val) const { return mSimd * val; }
|
[[nodiscard]] constexpr CVector3f operator*(float val) const { return mSimd * val; }
|
||||||
|
|
||||||
[[nodiscard]] CVector3f operator/(float val) const { return mSimd / val; }
|
[[nodiscard]] constexpr CVector3f operator/(float val) const { return mSimd / val; }
|
||||||
|
|
||||||
const CVector3f& operator+=(const CVector3f& rhs) {
|
const CVector3f& operator+=(const CVector3f& rhs) {
|
||||||
mSimd += rhs.mSimd;
|
mSimd += rhs.mSimd;
|
||||||
|
|
|
@ -69,23 +69,23 @@ public:
|
||||||
return eq_mask[0] && eq_mask[1] && eq_mask[2] && eq_mask[3];
|
return eq_mask[0] && eq_mask[1] && eq_mask[2] && eq_mask[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] CVector4d operator+(const CVector4d& rhs) const { return mSimd + rhs.mSimd; }
|
[[nodiscard]] constexpr CVector4d operator+(const CVector4d& rhs) const { return mSimd + rhs.mSimd; }
|
||||||
|
|
||||||
[[nodiscard]] CVector4d operator-(const CVector4d& rhs) const { return mSimd - rhs.mSimd; }
|
[[nodiscard]] constexpr CVector4d operator-(const CVector4d& rhs) const { return mSimd - rhs.mSimd; }
|
||||||
|
|
||||||
[[nodiscard]] CVector4d operator-() const { return -mSimd; }
|
[[nodiscard]] constexpr CVector4d operator-() const { return -mSimd; }
|
||||||
|
|
||||||
[[nodiscard]] CVector4d operator*(const CVector4d& rhs) const { return mSimd * rhs.mSimd; }
|
[[nodiscard]] constexpr CVector4d operator*(const CVector4d& rhs) const { return mSimd * rhs.mSimd; }
|
||||||
|
|
||||||
[[nodiscard]] CVector4d operator/(const CVector4d& rhs) const { return mSimd / rhs.mSimd; }
|
[[nodiscard]] constexpr CVector4d operator/(const CVector4d& rhs) const { return mSimd / rhs.mSimd; }
|
||||||
|
|
||||||
[[nodiscard]] CVector4d operator+(double val) const { return mSimd + zeus::simd<double>(val); }
|
[[nodiscard]] constexpr CVector4d operator+(double val) const { return mSimd + zeus::simd<double>(val); }
|
||||||
|
|
||||||
[[nodiscard]] CVector4d operator-(double val) const { return mSimd - zeus::simd<double>(val); }
|
[[nodiscard]] constexpr CVector4d operator-(double val) const { return mSimd - zeus::simd<double>(val); }
|
||||||
|
|
||||||
[[nodiscard]] CVector4d operator*(double val) const { return mSimd * zeus::simd<double>(val); }
|
[[nodiscard]] constexpr CVector4d operator*(double val) const { return mSimd * zeus::simd<double>(val); }
|
||||||
|
|
||||||
[[nodiscard]] CVector4d operator/(double val) const {
|
[[nodiscard]] constexpr CVector4d operator/(double val) const {
|
||||||
double ooval = 1.0 / val;
|
double ooval = 1.0 / val;
|
||||||
return mSimd * zeus::simd<double>(ooval);
|
return mSimd * zeus::simd<double>(ooval);
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,23 +69,23 @@ public:
|
||||||
return eq_mask[0] && eq_mask[1] && eq_mask[2] && eq_mask[3];
|
return eq_mask[0] && eq_mask[1] && eq_mask[2] && eq_mask[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] CVector4f operator+(const CVector4f& rhs) const { return mSimd + rhs.mSimd; }
|
[[nodiscard]] constexpr CVector4f operator+(const CVector4f& rhs) const { return mSimd + rhs.mSimd; }
|
||||||
|
|
||||||
[[nodiscard]] CVector4f operator-(const CVector4f& rhs) const { return mSimd - rhs.mSimd; }
|
[[nodiscard]] constexpr CVector4f operator-(const CVector4f& rhs) const { return mSimd - rhs.mSimd; }
|
||||||
|
|
||||||
[[nodiscard]] CVector4f operator-() const { return -mSimd; }
|
[[nodiscard]] constexpr CVector4f operator-() const { return -mSimd; }
|
||||||
|
|
||||||
[[nodiscard]] CVector4f operator*(const CVector4f& rhs) const { return mSimd * rhs.mSimd; }
|
[[nodiscard]] constexpr CVector4f operator*(const CVector4f& rhs) const { return mSimd * rhs.mSimd; }
|
||||||
|
|
||||||
[[nodiscard]] CVector4f operator/(const CVector4f& rhs) const { return mSimd / rhs.mSimd; }
|
[[nodiscard]] constexpr CVector4f operator/(const CVector4f& rhs) const { return mSimd / rhs.mSimd; }
|
||||||
|
|
||||||
[[nodiscard]] CVector4f operator+(float val) const { return mSimd + zeus::simd<float>(val); }
|
[[nodiscard]] constexpr CVector4f operator+(float val) const { return mSimd + zeus::simd<float>(val); }
|
||||||
|
|
||||||
[[nodiscard]] CVector4f operator-(float val) const { return mSimd - zeus::simd<float>(val); }
|
[[nodiscard]] constexpr CVector4f operator-(float val) const { return mSimd - zeus::simd<float>(val); }
|
||||||
|
|
||||||
[[nodiscard]] CVector4f operator*(float val) const { return mSimd * zeus::simd<float>(val); }
|
[[nodiscard]] constexpr CVector4f operator*(float val) const { return mSimd * zeus::simd<float>(val); }
|
||||||
|
|
||||||
[[nodiscard]] CVector4f operator/(float val) const {
|
[[nodiscard]] constexpr CVector4f operator/(float val) const {
|
||||||
float ooval = 1.f / val;
|
float ooval = 1.f / val;
|
||||||
return mSimd * zeus::simd<float>(ooval);
|
return mSimd * zeus::simd<float>(ooval);
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,25 +79,6 @@ void CQuaternion::fromVector3f(const CVector3f& vec) {
|
||||||
mSimd.copy_from(f);
|
mSimd.copy_from(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
CQuaternion CQuaternion::operator*(const CQuaternion& q) const {
|
|
||||||
return CQuaternion(w() * q.w() - CVector3f(x(), y(), z()).dot({q.x(), q.y(), q.z()}),
|
|
||||||
y() * q.z() - z() * q.y() + w() * q.x() + x() * q.w(),
|
|
||||||
z() * q.x() - x() * q.z() + w() * q.y() + y() * q.w(),
|
|
||||||
x() * q.y() - y() * q.x() + w() * q.z() + z() * q.w());
|
|
||||||
}
|
|
||||||
|
|
||||||
CNUQuaternion CNUQuaternion::operator*(const CNUQuaternion& q) const {
|
|
||||||
return CNUQuaternion(w() * q.w() - CVector3f(x(), y(), z()).dot({q.x(), q.y(), q.z()}),
|
|
||||||
y() * q.z() - z() * q.y() + w() * q.x() + x() * q.w(),
|
|
||||||
z() * q.x() - x() * q.z() + w() * q.y() + y() * q.w(),
|
|
||||||
x() * q.y() - y() * q.x() + w() * q.z() + z() * q.w());
|
|
||||||
}
|
|
||||||
|
|
||||||
CQuaternion CQuaternion::operator/(const CQuaternion& q) const {
|
|
||||||
CQuaternion p(q);
|
|
||||||
p.invert();
|
|
||||||
return *this * p;
|
|
||||||
}
|
|
||||||
|
|
||||||
const CQuaternion& CQuaternion::operator*=(const CQuaternion& q) {
|
const CQuaternion& CQuaternion::operator*=(const CQuaternion& q) {
|
||||||
CQuaternion orig = *this;
|
CQuaternion orig = *this;
|
||||||
|
|
Loading…
Reference in New Issue