summaryrefslogtreecommitdiffstats
path: root/core/math/vector3.h
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2020-05-14 13:23:58 +0200
committerRémi Verschelde <rverschelde@gmail.com>2020-05-14 16:54:55 +0200
commit0be6d925dc3c6413bce7a3ccb49631b8e4a6e67a (patch)
treea27e497da7104dd0a64f98a04fa3067668735e91 /core/math/vector3.h
parent710b34b70227becdc652b4ae027fe0ac47409642 (diff)
downloadredot-engine-0be6d925dc3c6413bce7a3ccb49631b8e4a6e67a.tar.gz
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.
Diffstat (limited to 'core/math/vector3.h')
-rw-r--r--core/math/vector3.h42
1 files changed, 0 insertions, 42 deletions
diff --git a/core/math/vector3.h b/core/math/vector3.h
index 7131063e04..5fc412628f 100644
--- a/core/math/vector3.h
+++ b/core/math/vector3.h
@@ -38,7 +38,6 @@
class Basis;
struct Vector3 {
-
enum Axis {
AXIS_X,
AXIS_Y,
@@ -56,12 +55,10 @@ struct Vector3 {
};
_FORCE_INLINE_ const real_t &operator[](int p_axis) const {
-
return coord[p_axis];
}
_FORCE_INLINE_ real_t &operator[](int p_axis) {
-
return coord[p_axis];
}
@@ -166,7 +163,6 @@ struct Vector3 {
};
Vector3 Vector3::cross(const Vector3 &p_b) const {
-
Vector3 ret(
(y * p_b.z) - (z * p_b.y),
(z * p_b.x) - (x * p_b.z),
@@ -176,37 +172,30 @@ Vector3 Vector3::cross(const Vector3 &p_b) const {
}
real_t Vector3::dot(const Vector3 &p_b) const {
-
return x * p_b.x + y * p_b.y + z * p_b.z;
}
Vector3 Vector3::abs() const {
-
return Vector3(Math::abs(x), Math::abs(y), Math::abs(z));
}
Vector3 Vector3::sign() const {
-
return Vector3(SGN(x), SGN(y), SGN(z));
}
Vector3 Vector3::floor() const {
-
return Vector3(Math::floor(x), Math::floor(y), Math::floor(z));
}
Vector3 Vector3::ceil() const {
-
return Vector3(Math::ceil(x), Math::ceil(y), Math::ceil(z));
}
Vector3 Vector3::round() const {
-
return Vector3(Math::round(x), Math::round(y), Math::round(z));
}
Vector3 Vector3::lerp(const Vector3 &p_b, real_t p_t) const {
-
return Vector3(
x + (p_t * (p_b.x - x)),
y + (p_t * (p_b.y - y)),
@@ -219,12 +208,10 @@ Vector3 Vector3::slerp(const Vector3 &p_b, real_t p_t) const {
}
real_t Vector3::distance_to(const Vector3 &p_b) const {
-
return (p_b - *this).length();
}
real_t Vector3::distance_squared_to(const Vector3 &p_b) const {
-
return (p_b - *this).length_squared();
}
@@ -241,7 +228,6 @@ Vector3 Vector3::project(const Vector3 &p_b) const {
}
real_t Vector3::angle_to(const Vector3 &p_b) const {
-
return Math::atan2(cross(p_b).length(), dot(p_b));
}
@@ -254,7 +240,6 @@ Vector3 Vector3::direction_to(const Vector3 &p_b) const {
/* Operators */
Vector3 &Vector3::operator+=(const Vector3 &p_v) {
-
x += p_v.x;
y += p_v.y;
z += p_v.z;
@@ -262,36 +247,30 @@ Vector3 &Vector3::operator+=(const Vector3 &p_v) {
}
Vector3 Vector3::operator+(const Vector3 &p_v) const {
-
return Vector3(x + p_v.x, y + p_v.y, z + p_v.z);
}
Vector3 &Vector3::operator-=(const Vector3 &p_v) {
-
x -= p_v.x;
y -= p_v.y;
z -= p_v.z;
return *this;
}
Vector3 Vector3::operator-(const Vector3 &p_v) const {
-
return Vector3(x - p_v.x, y - p_v.y, z - p_v.z);
}
Vector3 &Vector3::operator*=(const Vector3 &p_v) {
-
x *= p_v.x;
y *= p_v.y;
z *= p_v.z;
return *this;
}
Vector3 Vector3::operator*(const Vector3 &p_v) const {
-
return Vector3(x * p_v.x, y * p_v.y, z * p_v.z);
}
Vector3 &Vector3::operator/=(const Vector3 &p_v) {
-
x /= p_v.x;
y /= p_v.y;
z /= p_v.z;
@@ -299,12 +278,10 @@ Vector3 &Vector3::operator/=(const Vector3 &p_v) {
}
Vector3 Vector3::operator/(const Vector3 &p_v) const {
-
return Vector3(x / p_v.x, y / p_v.y, z / p_v.z);
}
Vector3 &Vector3::operator*=(real_t p_scalar) {
-
x *= p_scalar;
y *= p_scalar;
z *= p_scalar;
@@ -312,17 +289,14 @@ Vector3 &Vector3::operator*=(real_t p_scalar) {
}
_FORCE_INLINE_ Vector3 operator*(real_t p_scalar, const Vector3 &p_vec) {
-
return p_vec * p_scalar;
}
Vector3 Vector3::operator*(real_t p_scalar) const {
-
return Vector3(x * p_scalar, y * p_scalar, z * p_scalar);
}
Vector3 &Vector3::operator/=(real_t p_scalar) {
-
x /= p_scalar;
y /= p_scalar;
z /= p_scalar;
@@ -330,27 +304,22 @@ Vector3 &Vector3::operator/=(real_t p_scalar) {
}
Vector3 Vector3::operator/(real_t p_scalar) const {
-
return Vector3(x / p_scalar, y / p_scalar, z / p_scalar);
}
Vector3 Vector3::operator-() const {
-
return Vector3(-x, -y, -z);
}
bool Vector3::operator==(const Vector3 &p_v) const {
-
return x == p_v.x && y == p_v.y && z == p_v.z;
}
bool Vector3::operator!=(const Vector3 &p_v) const {
-
return x != p_v.x || y != p_v.y || z != p_v.z;
}
bool Vector3::operator<(const Vector3 &p_v) const {
-
if (Math::is_equal_approx(x, p_v.x)) {
if (Math::is_equal_approx(y, p_v.y))
return z < p_v.z;
@@ -362,7 +331,6 @@ bool Vector3::operator<(const Vector3 &p_v) const {
}
bool Vector3::operator>(const Vector3 &p_v) const {
-
if (Math::is_equal_approx(x, p_v.x)) {
if (Math::is_equal_approx(y, p_v.y))
return z > p_v.z;
@@ -374,7 +342,6 @@ bool Vector3::operator>(const Vector3 &p_v) const {
}
bool Vector3::operator<=(const Vector3 &p_v) const {
-
if (Math::is_equal_approx(x, p_v.x)) {
if (Math::is_equal_approx(y, p_v.y))
return z <= p_v.z;
@@ -386,7 +353,6 @@ bool Vector3::operator<=(const Vector3 &p_v) const {
}
bool Vector3::operator>=(const Vector3 &p_v) const {
-
if (Math::is_equal_approx(x, p_v.x)) {
if (Math::is_equal_approx(y, p_v.y))
return z >= p_v.z;
@@ -398,17 +364,14 @@ bool Vector3::operator>=(const Vector3 &p_v) const {
}
_FORCE_INLINE_ Vector3 vec3_cross(const Vector3 &p_a, const Vector3 &p_b) {
-
return p_a.cross(p_b);
}
_FORCE_INLINE_ real_t vec3_dot(const Vector3 &p_a, const Vector3 &p_b) {
-
return p_a.dot(p_b);
}
real_t Vector3::length() const {
-
real_t x2 = x * x;
real_t y2 = y * y;
real_t z2 = z * z;
@@ -417,7 +380,6 @@ real_t Vector3::length() const {
}
real_t Vector3::length_squared() const {
-
real_t x2 = x * x;
real_t y2 = y * y;
real_t z2 = z * z;
@@ -426,7 +388,6 @@ real_t Vector3::length_squared() const {
}
void Vector3::normalize() {
-
real_t lengthsq = length_squared();
if (lengthsq == 0) {
x = y = z = 0;
@@ -439,7 +400,6 @@ void Vector3::normalize() {
}
Vector3 Vector3::normalized() const {
-
Vector3 v = *this;
v.normalize();
return v;
@@ -451,12 +411,10 @@ bool Vector3::is_normalized() const {
}
Vector3 Vector3::inverse() const {
-
return Vector3(1.0 / x, 1.0 / y, 1.0 / z);
}
void Vector3::zero() {
-
x = y = z = 0;
}