Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks
Which means that reduz' beloved style which we all became used to will now be changed automatically to remove the first empty line. This makes us lean closer to 1TBS (the one true brace style) instead of hybridating it with some Allman-inspired spacing. There's still the case of braces around single-statement blocks that needs to be addressed (but clang-format can't help with that, but clang-tidy may if we agree about it). Part of #33027.
This commit is contained in:
@@ -38,16 +38,13 @@
|
||||
(elements[row1][col1] * elements[row2][col2] - elements[row1][col2] * elements[row2][col1])
|
||||
|
||||
void Basis::from_z(const Vector3 &p_z) {
|
||||
|
||||
if (Math::abs(p_z.z) > Math_SQRT12) {
|
||||
|
||||
// choose p in y-z plane
|
||||
real_t a = p_z[1] * p_z[1] + p_z[2] * p_z[2];
|
||||
real_t k = 1.0 / Math::sqrt(a);
|
||||
elements[0] = Vector3(0, -p_z[2] * k, p_z[1] * k);
|
||||
elements[1] = Vector3(a * k, -p_z[0] * elements[0][2], p_z[0] * elements[0][1]);
|
||||
} else {
|
||||
|
||||
// choose p in x-y plane
|
||||
real_t a = p_z.x * p_z.x + p_z.y * p_z.y;
|
||||
real_t k = 1.0 / Math::sqrt(a);
|
||||
@@ -58,7 +55,6 @@ void Basis::from_z(const Vector3 &p_z) {
|
||||
}
|
||||
|
||||
void Basis::invert() {
|
||||
|
||||
real_t co[3] = {
|
||||
cofac(1, 1, 2, 2), cofac(1, 2, 2, 0), cofac(1, 0, 2, 1)
|
||||
};
|
||||
@@ -76,7 +72,6 @@ void Basis::invert() {
|
||||
}
|
||||
|
||||
void Basis::orthonormalize() {
|
||||
|
||||
// Gram-Schmidt Process
|
||||
|
||||
Vector3 x = get_axis(0);
|
||||
@@ -95,7 +90,6 @@ void Basis::orthonormalize() {
|
||||
}
|
||||
|
||||
Basis Basis::orthonormalized() const {
|
||||
|
||||
Basis c = *this;
|
||||
c.orthonormalize();
|
||||
return c;
|
||||
@@ -120,7 +114,6 @@ bool Basis::is_rotation() const {
|
||||
}
|
||||
|
||||
bool Basis::is_symmetric() const {
|
||||
|
||||
if (!Math::is_equal_approx_ratio(elements[0][1], elements[1][0], UNIT_EPSILON))
|
||||
return false;
|
||||
if (!Math::is_equal_approx_ratio(elements[0][2], elements[2][0], UNIT_EPSILON))
|
||||
@@ -132,7 +125,6 @@ bool Basis::is_symmetric() const {
|
||||
}
|
||||
|
||||
Basis Basis::diagonalize() {
|
||||
|
||||
//NOTE: only implemented for symmetric matrices
|
||||
//with the Jacobi iterative method method
|
||||
#ifdef MATH_CHECKS
|
||||
@@ -193,21 +185,18 @@ Basis Basis::diagonalize() {
|
||||
}
|
||||
|
||||
Basis Basis::inverse() const {
|
||||
|
||||
Basis inv = *this;
|
||||
inv.invert();
|
||||
return inv;
|
||||
}
|
||||
|
||||
void Basis::transpose() {
|
||||
|
||||
SWAP(elements[0][1], elements[1][0]);
|
||||
SWAP(elements[0][2], elements[2][0]);
|
||||
SWAP(elements[1][2], elements[2][1]);
|
||||
}
|
||||
|
||||
Basis Basis::transposed() const {
|
||||
|
||||
Basis tr = *this;
|
||||
tr.transpose();
|
||||
return tr;
|
||||
@@ -216,7 +205,6 @@ Basis Basis::transposed() const {
|
||||
// Multiplies the matrix from left by the scaling matrix: M -> S.M
|
||||
// See the comment for Basis::rotated for further explanation.
|
||||
void Basis::scale(const Vector3 &p_scale) {
|
||||
|
||||
elements[0][0] *= p_scale.x;
|
||||
elements[0][1] *= p_scale.x;
|
||||
elements[0][2] *= p_scale.x;
|
||||
@@ -260,7 +248,6 @@ Basis Basis::scaled_local(const Vector3 &p_scale) const {
|
||||
}
|
||||
|
||||
Vector3 Basis::get_scale_abs() const {
|
||||
|
||||
return Vector3(
|
||||
Vector3(elements[0][0], elements[1][0], elements[2][0]).length(),
|
||||
Vector3(elements[0][1], elements[1][1], elements[2][1]).length(),
|
||||
@@ -341,7 +328,6 @@ void Basis::rotate_local(const Vector3 &p_axis, real_t p_phi) {
|
||||
*this = rotated_local(p_axis, p_phi);
|
||||
}
|
||||
Basis Basis::rotated_local(const Vector3 &p_axis, real_t p_phi) const {
|
||||
|
||||
return (*this) * Basis(p_axis, p_phi);
|
||||
}
|
||||
|
||||
@@ -430,7 +416,6 @@ void Basis::get_rotation_axis_angle_local(Vector3 &p_axis, real_t &p_angle) cons
|
||||
// the angles in the decomposition R = X(a1).Y(a2).Z(a3) where Z(a) rotates
|
||||
// around the z-axis by a and so on.
|
||||
Vector3 Basis::get_euler_xyz() const {
|
||||
|
||||
// Euler angles in XYZ convention.
|
||||
// See https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix
|
||||
//
|
||||
@@ -474,7 +459,6 @@ Vector3 Basis::get_euler_xyz() const {
|
||||
// and similar for other axes.
|
||||
// The current implementation uses XYZ convention (Z is the first rotation).
|
||||
void Basis::set_euler_xyz(const Vector3 &p_euler) {
|
||||
|
||||
real_t c, s;
|
||||
|
||||
c = Math::cos(p_euler.x);
|
||||
@@ -497,7 +481,6 @@ void Basis::set_euler_xyz(const Vector3 &p_euler) {
|
||||
// as in first-Z, then-X, last-Y. The angles for X, Y, and Z rotations are returned
|
||||
// as the x, y, and z components of a Vector3 respectively.
|
||||
Vector3 Basis::get_euler_yxz() const {
|
||||
|
||||
/* checking this is a bad idea, because obtaining from scaled transform is a valid use case
|
||||
#ifdef MATH_CHECKS
|
||||
ERR_FAIL_COND(!is_rotation());
|
||||
@@ -546,7 +529,6 @@ Vector3 Basis::get_euler_yxz() const {
|
||||
// and similar for other axes.
|
||||
// The current implementation uses YXZ convention (Z is the first rotation).
|
||||
void Basis::set_euler_yxz(const Vector3 &p_euler) {
|
||||
|
||||
real_t c, s;
|
||||
|
||||
c = Math::cos(p_euler.x);
|
||||
@@ -566,12 +548,10 @@ void Basis::set_euler_yxz(const Vector3 &p_euler) {
|
||||
}
|
||||
|
||||
bool Basis::is_equal_approx(const Basis &p_basis) const {
|
||||
|
||||
return elements[0].is_equal_approx(p_basis.elements[0]) && elements[1].is_equal_approx(p_basis.elements[1]) && elements[2].is_equal_approx(p_basis.elements[2]);
|
||||
}
|
||||
|
||||
bool Basis::is_equal_approx_ratio(const Basis &a, const Basis &b, real_t p_epsilon) const {
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
if (!Math::is_equal_approx_ratio(a.elements[i][j], b.elements[i][j], p_epsilon))
|
||||
@@ -583,7 +563,6 @@ bool Basis::is_equal_approx_ratio(const Basis &a, const Basis &b, real_t p_epsil
|
||||
}
|
||||
|
||||
bool Basis::operator==(const Basis &p_matrix) const {
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
if (elements[i][j] != p_matrix.elements[i][j])
|
||||
@@ -595,17 +574,13 @@ bool Basis::operator==(const Basis &p_matrix) const {
|
||||
}
|
||||
|
||||
bool Basis::operator!=(const Basis &p_matrix) const {
|
||||
|
||||
return (!(*this == p_matrix));
|
||||
}
|
||||
|
||||
Basis::operator String() const {
|
||||
|
||||
String mtx;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
|
||||
for (int j = 0; j < 3; j++) {
|
||||
|
||||
if (i != 0 || j != 0)
|
||||
mtx += ", ";
|
||||
|
||||
@@ -617,7 +592,6 @@ Basis::operator String() const {
|
||||
}
|
||||
|
||||
Quat Basis::get_quat() const {
|
||||
|
||||
#ifdef MATH_CHECKS
|
||||
ERR_FAIL_COND_V_MSG(!is_rotation(), Quat(), "Basis must be normalized in order to be casted to a Quaternion. Use get_rotation_quat() or call orthonormalized() instead.");
|
||||
#endif
|
||||
@@ -681,12 +655,10 @@ static const Basis _ortho_bases[24] = {
|
||||
};
|
||||
|
||||
int Basis::get_orthogonal_index() const {
|
||||
|
||||
//could be sped up if i come up with a way
|
||||
Basis orth = *this;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
|
||||
real_t v = orth[i][j];
|
||||
if (v > 0.5)
|
||||
v = 1.0;
|
||||
@@ -700,7 +672,6 @@ int Basis::get_orthogonal_index() const {
|
||||
}
|
||||
|
||||
for (int i = 0; i < 24; i++) {
|
||||
|
||||
if (_ortho_bases[i] == orth)
|
||||
return i;
|
||||
}
|
||||
@@ -709,7 +680,6 @@ int Basis::get_orthogonal_index() const {
|
||||
}
|
||||
|
||||
void Basis::set_orthogonal_index(int p_index) {
|
||||
|
||||
//there only exist 24 orthogonal bases in r3
|
||||
ERR_FAIL_INDEX(p_index, 24);
|
||||
|
||||
@@ -794,7 +764,6 @@ void Basis::get_axis_angle(Vector3 &r_axis, real_t &r_angle) const {
|
||||
}
|
||||
|
||||
void Basis::set_quat(const Quat &p_quat) {
|
||||
|
||||
real_t d = p_quat.length_squared();
|
||||
real_t s = 2.0 / d;
|
||||
real_t xs = p_quat.x * s, ys = p_quat.y * s, zs = p_quat.z * s;
|
||||
@@ -866,7 +835,6 @@ void Basis::set_diagonal(const Vector3 &p_diag) {
|
||||
}
|
||||
|
||||
Basis Basis::slerp(const Basis &target, const real_t &t) const {
|
||||
|
||||
//consider scale
|
||||
Quat from(*this);
|
||||
Quat to(target);
|
||||
@@ -880,7 +848,6 @@ Basis Basis::slerp(const Basis &target, const real_t &t) const {
|
||||
}
|
||||
|
||||
void Basis::rotate_sh(real_t *p_values) {
|
||||
|
||||
// code by John Hable
|
||||
// http://filmicworlds.com/blog/simple-and-fast-spherical-harmonic-rotation/
|
||||
// this code is Public Domain
|
||||
|
||||
Reference in New Issue
Block a user