Skip to content

Commit

Permalink
Backported dome of the codestyle improvements to math types from godo…
Browse files Browse the repository at this point in the history
  • Loading branch information
Relintai committed Apr 6, 2024
1 parent 4f93164 commit ececc79
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion core/math/basis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions core/math/basis.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions core/math/color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand All @@ -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,
Expand All @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions core/math/color.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
10 changes: 5 additions & 5 deletions core/math/quaternion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down Expand Up @@ -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.");
Expand All @@ -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.");
Expand All @@ -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.");
Expand Down Expand Up @@ -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
Expand Down
28 changes: 14 additions & 14 deletions core/math/quaternion.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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);
}

Expand Down Expand Up @@ -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;
}

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

Expand Down
8 changes: 4 additions & 4 deletions core/math/vector2i.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand All @@ -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;
};
Expand Down
8 changes: 4 additions & 4 deletions core/math/vector2i.h
Original file line number Diff line number Diff line change
Expand Up @@ -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); }
Expand Down

0 comments on commit ececc79

Please sign in to comment.