summaryrefslogtreecommitdiffstats
path: root/include/core/Vector2.hpp
diff options
context:
space:
mode:
authorBastiaan Olij <mux213@gmail.com>2018-11-24 09:09:41 +1100
committerBastiaan Olij <mux213@gmail.com>2018-11-24 09:09:41 +1100
commitfc20fa3fce2f30c96fa2bbf8d460817f91b90e81 (patch)
treedecd51288822651ad34fd270e68a2f2a54d0bd8d /include/core/Vector2.hpp
parent0a6f5d052a0d05e07ca1b7eab8e53bbd8450a991 (diff)
downloadredot-cpp-fc20fa3fce2f30c96fa2bbf8d460817f91b90e81.tar.gz
Implementing clang-format and applying it to all classes
Diffstat (limited to 'include/core/Vector2.hpp')
-rw-r--r--include/core/Vector2.hpp78
1 files changed, 38 insertions, 40 deletions
diff --git a/include/core/Vector2.hpp b/include/core/Vector2.hpp
index 3372f99..190217d 100644
--- a/include/core/Vector2.hpp
+++ b/include/core/Vector2.hpp
@@ -20,21 +20,20 @@ struct Vector2 {
real_t height;
};
-
- inline real_t& operator[](int p_idx) {
- return p_idx?y:x;
+ inline real_t &operator[](int p_idx) {
+ return p_idx ? y : x;
}
- inline const real_t& operator[](int p_idx) const {
- return p_idx?y:x;
+ inline const real_t &operator[](int p_idx) const {
+ return p_idx ? y : x;
}
- Vector2 operator+(const Vector2& p_v) const;
+ Vector2 operator+(const Vector2 &p_v) const;
- void operator+=(const Vector2& p_v);
+ void operator+=(const Vector2 &p_v);
- Vector2 operator-(const Vector2& p_v) const;
+ Vector2 operator-(const Vector2 &p_v) const;
- void operator-=(const Vector2& p_v);
+ void operator-=(const Vector2 &p_v);
Vector2 operator*(const Vector2 &p_v1) const;
@@ -52,13 +51,12 @@ struct Vector2 {
Vector2 operator-() const;
- bool operator==(const Vector2& p_vec2) const;
-
- bool operator!=(const Vector2& p_vec2) const;
+ bool operator==(const Vector2 &p_vec2) const;
- inline bool operator<(const Vector2& p_vec2) const { return (x==p_vec2.x)?(y<p_vec2.y):(x<p_vec2.x); }
- inline bool operator<=(const Vector2& p_vec2) const { return (x==p_vec2.x)?(y<=p_vec2.y):(x<=p_vec2.x); }
+ bool operator!=(const Vector2 &p_vec2) const;
+ inline bool operator<(const Vector2 &p_vec2) const { return (x == p_vec2.x) ? (y < p_vec2.y) : (x < p_vec2.x); }
+ inline bool operator<=(const Vector2 &p_vec2) const { return (x == p_vec2.x) ? (y <= p_vec2.y) : (x <= p_vec2.x); }
void normalize();
@@ -67,32 +65,31 @@ struct Vector2 {
real_t length() const;
real_t length_squared() const;
- real_t distance_to(const Vector2& p_vector2) const;
- real_t distance_squared_to(const Vector2& p_vector2) const;
+ real_t distance_to(const Vector2 &p_vector2) const;
+ real_t distance_squared_to(const Vector2 &p_vector2) const;
- real_t angle_to(const Vector2& p_vector2) const;
- real_t angle_to_point(const Vector2& p_vector2) const;
+ real_t angle_to(const Vector2 &p_vector2) const;
+ real_t angle_to_point(const Vector2 &p_vector2) const;
- real_t dot(const Vector2& p_other) const;
+ real_t dot(const Vector2 &p_other) const;
- real_t cross(const Vector2& p_other) const;
+ real_t cross(const Vector2 &p_other) const;
Vector2 cross(real_t p_other) const;
- Vector2 project(const Vector2& p_vec) const;
+ Vector2 project(const Vector2 &p_vec) const;
- Vector2 plane_project(real_t p_d, const Vector2& p_vec) const;
+ Vector2 plane_project(real_t p_d, const Vector2 &p_vec) const;
Vector2 clamped(real_t p_len) const;
- static Vector2 linear_interpolate(const Vector2& p_a, const Vector2& p_b,real_t p_t);
-
- Vector2 linear_interpolate(const Vector2& p_b,real_t p_t) const;
- Vector2 cubic_interpolate(const Vector2& p_b,const Vector2& p_pre_a, const Vector2& p_post_b,real_t p_t) const;
+ static Vector2 linear_interpolate(const Vector2 &p_a, const Vector2 &p_b, real_t p_t);
+ Vector2 linear_interpolate(const Vector2 &p_b, real_t p_t) const;
+ Vector2 cubic_interpolate(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, real_t p_t) const;
- Vector2 slide(const Vector2& p_vec) const;
+ Vector2 slide(const Vector2 &p_vec) const;
- Vector2 reflect(const Vector2& p_vec) const;
+ Vector2 reflect(const Vector2 &p_vec) const;
real_t angle() const;
@@ -105,24 +102,25 @@ struct Vector2 {
Vector2 floor() const;
- Vector2 snapped(const Vector2& p_by) const;
- inline real_t aspect() const { return width/height; }
-
+ Vector2 snapped(const Vector2 &p_by) const;
+ inline real_t aspect() const { return width / height; }
operator String() const;
- inline Vector2(real_t p_x,real_t p_y) { x=p_x; y=p_y; }
- inline Vector2() { x=0; y=0; }
+ inline Vector2(real_t p_x, real_t p_y) {
+ x = p_x;
+ y = p_y;
+ }
+ inline Vector2() {
+ x = 0;
+ y = 0;
+ }
};
-
-inline Vector2 operator*(real_t p_scalar, const Vector2& p_vec)
-{
- return p_vec*p_scalar;
+inline Vector2 operator*(real_t p_scalar, const Vector2 &p_vec) {
+ return p_vec * p_scalar;
}
-
-
-}
+} // namespace godot
#endif // VECTOR2_H