mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-11-21 16:37:20 +01:00
Backported dome of the codestyle improvements to math types from 3fb36bf395
.
This commit is contained in:
parent
4f93164401
commit
ececc7991c
@ -1062,7 +1062,7 @@ void Basis::set_diagonal(const Vector3 &p_diag) {
|
||||
rows[2][2] = p_diag.z;
|
||||
}
|
||||
|
||||
Basis Basis::slerp(const Basis &p_to, const real_t &p_weight) const {
|
||||
Basis Basis::slerp(const Basis &p_to, const real_t p_weight) const {
|
||||
//consider scale
|
||||
Quaternion from(*this);
|
||||
Quaternion to(p_to);
|
||||
|
@ -175,8 +175,8 @@ struct _NO_DISCARD_CLASS_ Basis {
|
||||
bool is_diagonal() const;
|
||||
bool is_rotation() const;
|
||||
|
||||
Basis slerp(const Basis &p_to, const real_t &p_weight) const;
|
||||
_FORCE_INLINE_ Basis lerp(const Basis &p_to, const real_t &p_weight) const;
|
||||
Basis slerp(const Basis &p_to, const real_t p_weight) const;
|
||||
_FORCE_INLINE_ Basis lerp(const Basis &p_to, const real_t p_weight) const;
|
||||
void rotate_sh(real_t *p_values);
|
||||
|
||||
operator String() const;
|
||||
@ -393,7 +393,7 @@ real_t Basis::determinant() const {
|
||||
rows[2][0] * (rows[0][1] * rows[1][2] - rows[1][1] * rows[0][2]);
|
||||
}
|
||||
|
||||
Basis Basis::lerp(const Basis &p_to, const real_t &p_weight) const {
|
||||
Basis Basis::lerp(const Basis &p_to, const real_t p_weight) const {
|
||||
Basis b;
|
||||
b.rows[0] = rows[0].linear_interpolate(p_to.rows[0], p_weight);
|
||||
b.rows[1] = rows[1].linear_interpolate(p_to.rows[1], p_weight);
|
||||
|
@ -505,7 +505,7 @@ Color Color::operator*(const Color &p_color) const {
|
||||
a * p_color.a);
|
||||
}
|
||||
|
||||
Color Color::operator*(const real_t &rvalue) const {
|
||||
Color Color::operator*(const real_t rvalue) const {
|
||||
return Color(
|
||||
r * rvalue,
|
||||
g * rvalue,
|
||||
@ -520,7 +520,7 @@ void Color::operator*=(const Color &p_color) {
|
||||
a = a * p_color.a;
|
||||
}
|
||||
|
||||
void Color::operator*=(const real_t &rvalue) {
|
||||
void Color::operator*=(const real_t rvalue) {
|
||||
r = r * rvalue;
|
||||
g = g * rvalue;
|
||||
b = b * rvalue;
|
||||
@ -535,7 +535,7 @@ Color Color::operator/(const Color &p_color) const {
|
||||
a / p_color.a);
|
||||
}
|
||||
|
||||
Color Color::operator/(const real_t &rvalue) const {
|
||||
Color Color::operator/(const real_t rvalue) const {
|
||||
return Color(
|
||||
r / rvalue,
|
||||
g / rvalue,
|
||||
@ -550,7 +550,7 @@ void Color::operator/=(const Color &p_color) {
|
||||
a = a / p_color.a;
|
||||
}
|
||||
|
||||
void Color::operator/=(const real_t &rvalue) {
|
||||
void Color::operator/=(const real_t rvalue) {
|
||||
if (rvalue == 0) {
|
||||
r = 1.0;
|
||||
g = 1.0;
|
||||
|
@ -76,14 +76,14 @@ struct _NO_DISCARD_CLASS_ Color {
|
||||
void operator-=(const Color &p_color);
|
||||
|
||||
Color operator*(const Color &p_color) const;
|
||||
Color operator*(const real_t &rvalue) const;
|
||||
Color operator*(const real_t rvalue) const;
|
||||
void operator*=(const Color &p_color);
|
||||
void operator*=(const real_t &rvalue);
|
||||
void operator*=(const real_t rvalue);
|
||||
|
||||
Color operator/(const Color &p_color) const;
|
||||
Color operator/(const real_t &rvalue) const;
|
||||
Color operator/(const real_t rvalue) const;
|
||||
void operator/=(const Color &p_color);
|
||||
void operator/=(const real_t &rvalue);
|
||||
void operator/=(const real_t rvalue);
|
||||
|
||||
bool is_equal_approx(const Color &p_color) const;
|
||||
|
||||
|
@ -170,7 +170,7 @@ Quaternion Quaternion::exp() const {
|
||||
return Quaternion(src_v.normalized(), theta);
|
||||
}
|
||||
|
||||
Quaternion Quaternion::slerp(const Quaternion &p_to, const real_t &p_weight) const {
|
||||
Quaternion Quaternion::slerp(const Quaternion &p_to, const real_t p_weight) const {
|
||||
#ifdef MATH_CHECKS
|
||||
ERR_FAIL_COND_V_MSG(!is_normalized(), Quaternion(), "The start quaternion must be normalized.");
|
||||
ERR_FAIL_COND_V_MSG(!p_to.is_normalized(), Quaternion(), "The end quaternion must be normalized.");
|
||||
@ -217,7 +217,7 @@ Quaternion Quaternion::slerp(const Quaternion &p_to, const real_t &p_weight) con
|
||||
scale0 * w + scale1 * to1.w);
|
||||
}
|
||||
|
||||
Quaternion Quaternion::slerpni(const Quaternion &p_to, const real_t &p_weight) const {
|
||||
Quaternion Quaternion::slerpni(const Quaternion &p_to, const real_t p_weight) const {
|
||||
#ifdef MATH_CHECKS
|
||||
ERR_FAIL_COND_V_MSG(!is_normalized(), Quaternion(), "The start quaternion must be normalized.");
|
||||
ERR_FAIL_COND_V_MSG(!p_to.is_normalized(), Quaternion(), "The end quaternion must be normalized.");
|
||||
@ -241,7 +241,7 @@ Quaternion Quaternion::slerpni(const Quaternion &p_to, const real_t &p_weight) c
|
||||
invFactor * from.w + newFactor * p_to.w);
|
||||
}
|
||||
|
||||
Quaternion Quaternion::cubic_slerp(const Quaternion &p_b, const Quaternion &p_pre_a, const Quaternion &p_post_b, const real_t &p_weight) const {
|
||||
Quaternion Quaternion::cubic_slerp(const Quaternion &p_b, const Quaternion &p_pre_a, const Quaternion &p_post_b, const real_t p_weight) const {
|
||||
#ifdef MATH_CHECKS
|
||||
ERR_FAIL_COND_V_MSG(!is_normalized(), Quaternion(), "The start quaternion must be normalized.");
|
||||
ERR_FAIL_COND_V_MSG(!p_b.is_normalized(), Quaternion(), "The end quaternion must be normalized.");
|
||||
@ -253,7 +253,7 @@ Quaternion Quaternion::cubic_slerp(const Quaternion &p_b, const Quaternion &p_pr
|
||||
return sp.slerpni(sq, t2);
|
||||
}
|
||||
|
||||
Quaternion Quaternion::spherical_cubic_interpolate(const Quaternion &p_b, const Quaternion &p_pre_a, const Quaternion &p_post_b, const real_t &p_weight) const {
|
||||
Quaternion Quaternion::spherical_cubic_interpolate(const Quaternion &p_b, const Quaternion &p_pre_a, const Quaternion &p_post_b, const real_t p_weight) const {
|
||||
#ifdef MATH_CHECKS
|
||||
ERR_FAIL_COND_V_MSG(!is_normalized(), Quaternion(), "The start quaternion must be normalized.");
|
||||
ERR_FAIL_COND_V_MSG(!p_b.is_normalized(), Quaternion(), "The end quaternion must be normalized.");
|
||||
@ -319,7 +319,7 @@ Quaternion::operator String() const {
|
||||
return "(" + String::num_real(x) + ", " + String::num_real(y) + ", " + String::num_real(z) + ", " + String::num_real(w) + ")";
|
||||
}
|
||||
|
||||
void Quaternion::set_axis_angle(const Vector3 &axis, const real_t &angle) {
|
||||
void Quaternion::set_axis_angle(const Vector3 &axis, const real_t angle) {
|
||||
#ifdef MATH_CHECKS
|
||||
ERR_FAIL_COND_MSG(!axis.is_normalized(), "The axis Vector3 must be normalized.");
|
||||
#endif
|
||||
|
@ -75,15 +75,15 @@ struct _NO_DISCARD_CLASS_ Quaternion {
|
||||
void set_euler(const Vector3 &p_euler) { set_euler_yxz(p_euler); };
|
||||
Vector3 get_euler() const { return get_euler_yxz(); };
|
||||
|
||||
Quaternion slerp(const Quaternion &p_to, const real_t &p_weight) const;
|
||||
Quaternion slerpni(const Quaternion &p_to, const real_t &p_weight) const;
|
||||
Quaternion cubic_slerp(const Quaternion &p_b, const Quaternion &p_pre_a, const Quaternion &p_post_b, const real_t &p_weight) const;
|
||||
Quaternion spherical_cubic_interpolate(const Quaternion &p_b, const Quaternion &p_pre_a, const Quaternion &p_post_b, const real_t &p_weight) const;
|
||||
Quaternion slerp(const Quaternion &p_to, const real_t p_weight) const;
|
||||
Quaternion slerpni(const Quaternion &p_to, const real_t p_weight) const;
|
||||
Quaternion cubic_slerp(const Quaternion &p_b, const Quaternion &p_pre_a, const Quaternion &p_post_b, const real_t p_weight) const;
|
||||
Quaternion spherical_cubic_interpolate(const Quaternion &p_b, const Quaternion &p_pre_a, const Quaternion &p_post_b, const real_t p_weight) const;
|
||||
|
||||
Vector3 get_axis() const;
|
||||
float get_angle() const;
|
||||
|
||||
void set_axis_angle(const Vector3 &axis, const real_t &angle);
|
||||
void set_axis_angle(const Vector3 &axis, const real_t angle);
|
||||
_FORCE_INLINE_ void get_axis_angle(Vector3 &r_axis, real_t &r_angle) const {
|
||||
r_angle = 2 * Math::acos(w);
|
||||
real_t r = ((real_t)1) / Math::sqrt(1 - w * w);
|
||||
@ -113,13 +113,13 @@ struct _NO_DISCARD_CLASS_ Quaternion {
|
||||
|
||||
_FORCE_INLINE_ void operator+=(const Quaternion &p_q);
|
||||
_FORCE_INLINE_ void operator-=(const Quaternion &p_q);
|
||||
_FORCE_INLINE_ void operator*=(const real_t &s);
|
||||
_FORCE_INLINE_ void operator/=(const real_t &s);
|
||||
_FORCE_INLINE_ void operator*=(const real_t s);
|
||||
_FORCE_INLINE_ void operator/=(const real_t s);
|
||||
_FORCE_INLINE_ Quaternion operator+(const Quaternion &q2) const;
|
||||
_FORCE_INLINE_ Quaternion operator-(const Quaternion &q2) const;
|
||||
_FORCE_INLINE_ Quaternion operator-() const;
|
||||
_FORCE_INLINE_ Quaternion operator*(const real_t &s) const;
|
||||
_FORCE_INLINE_ Quaternion operator/(const real_t &s) const;
|
||||
_FORCE_INLINE_ Quaternion operator*(const real_t s) const;
|
||||
_FORCE_INLINE_ Quaternion operator/(const real_t s) const;
|
||||
|
||||
_FORCE_INLINE_ bool operator==(const Quaternion &p_quat) const;
|
||||
_FORCE_INLINE_ bool operator!=(const Quaternion &p_quat) const;
|
||||
@ -138,7 +138,7 @@ struct _NO_DISCARD_CLASS_ Quaternion {
|
||||
z(p_z),
|
||||
w(p_w) {
|
||||
}
|
||||
Quaternion(const Vector3 &axis, const real_t &angle) {
|
||||
Quaternion(const Vector3 &axis, const real_t angle) {
|
||||
set_axis_angle(axis, angle);
|
||||
}
|
||||
|
||||
@ -211,14 +211,14 @@ void Quaternion::operator-=(const Quaternion &p_q) {
|
||||
w -= p_q.w;
|
||||
}
|
||||
|
||||
void Quaternion::operator*=(const real_t &s) {
|
||||
void Quaternion::operator*=(const real_t s) {
|
||||
x *= s;
|
||||
y *= s;
|
||||
z *= s;
|
||||
w *= s;
|
||||
}
|
||||
|
||||
void Quaternion::operator/=(const real_t &s) {
|
||||
void Quaternion::operator/=(const real_t s) {
|
||||
*this *= 1 / s;
|
||||
}
|
||||
|
||||
@ -237,11 +237,11 @@ Quaternion Quaternion::operator-() const {
|
||||
return Quaternion(-q2.x, -q2.y, -q2.z, -q2.w);
|
||||
}
|
||||
|
||||
Quaternion Quaternion::operator*(const real_t &s) const {
|
||||
Quaternion Quaternion::operator*(const real_t s) const {
|
||||
return Quaternion(x * s, y * s, z * s, w * s);
|
||||
}
|
||||
|
||||
Quaternion Quaternion::operator/(const real_t &s) const {
|
||||
Quaternion Quaternion::operator/(const real_t s) const {
|
||||
return *this * (1 / s);
|
||||
}
|
||||
|
||||
|
@ -66,10 +66,10 @@ Vector2i Vector2i::operator*(const Vector2i &p_v1) const {
|
||||
return Vector2i(x * p_v1.x, y * p_v1.y);
|
||||
};
|
||||
|
||||
Vector2i Vector2i::operator*(const int &rvalue) const {
|
||||
Vector2i Vector2i::operator*(const int rvalue) const {
|
||||
return Vector2i(x * rvalue, y * rvalue);
|
||||
};
|
||||
void Vector2i::operator*=(const int &rvalue) {
|
||||
void Vector2i::operator*=(const int rvalue) {
|
||||
x *= rvalue;
|
||||
y *= rvalue;
|
||||
};
|
||||
@ -78,11 +78,11 @@ Vector2i Vector2i::operator/(const Vector2i &p_v1) const {
|
||||
return Vector2i(x / p_v1.x, y / p_v1.y);
|
||||
};
|
||||
|
||||
Vector2i Vector2i::operator/(const int &rvalue) const {
|
||||
Vector2i Vector2i::operator/(const int rvalue) const {
|
||||
return Vector2i(x / rvalue, y / rvalue);
|
||||
};
|
||||
|
||||
void Vector2i::operator/=(const int &rvalue) {
|
||||
void Vector2i::operator/=(const int rvalue) {
|
||||
x /= rvalue;
|
||||
y /= rvalue;
|
||||
};
|
||||
|
@ -98,14 +98,14 @@ struct _NO_DISCARD_CLASS_ Vector2i {
|
||||
void operator-=(const Vector2i &p_v);
|
||||
Vector2i operator*(const Vector2i &p_v1) const;
|
||||
|
||||
Vector2i operator*(const int &rvalue) const;
|
||||
void operator*=(const int &rvalue);
|
||||
Vector2i operator*(const int rvalue) const;
|
||||
void operator*=(const int rvalue);
|
||||
|
||||
Vector2i operator/(const Vector2i &p_v1) const;
|
||||
|
||||
Vector2i operator/(const int &rvalue) const;
|
||||
Vector2i operator/(const int rvalue) const;
|
||||
|
||||
void operator/=(const int &rvalue);
|
||||
void operator/=(const int rvalue);
|
||||
|
||||
Vector2i operator-() const;
|
||||
bool operator<(const Vector2i &p_vec2) const { return (x == p_vec2.x) ? (y < p_vec2.y) : (x < p_vec2.x); }
|
||||
|
Loading…
Reference in New Issue
Block a user