aboutsummaryrefslogtreecommitdiff
path: root/core/math/vector3.cpp
diff options
context:
space:
mode:
authorRémi Verschelde2017-03-19 00:36:26 +0100
committerRémi Verschelde2017-03-19 00:36:26 +0100
commitf8db8a3faa30b71dca33ced38be16d3f93f43e8a (patch)
tree3b798318132cca7eccfbca5818ab55656a2896d7 /core/math/vector3.cpp
parent1d418afe863c9e553b69174ce63aef203c46d2f0 (diff)
downloadgodot-f8db8a3faa30b71dca33ced38be16d3f93f43e8a.tar.gz
godot-f8db8a3faa30b71dca33ced38be16d3f93f43e8a.tar.zst
godot-f8db8a3faa30b71dca33ced38be16d3f93f43e8a.zip
Bring that Whole New World to the Old Continent too
Applies the clang-format style to the 2.1 branch as done for master in 5dbf1809c6e3e905b94b8764e99491e608122261.
Diffstat (limited to 'core/math/vector3.cpp')
-rw-r--r--core/math/vector3.cpp86
1 files changed, 39 insertions, 47 deletions
diff --git a/core/math/vector3.cpp b/core/math/vector3.cpp
index db96dda46..56034ab49 100644
--- a/core/math/vector3.cpp
+++ b/core/math/vector3.cpp
@@ -29,27 +29,25 @@
#include "vector3.h"
#include "matrix3.h"
+void Vector3::rotate(const Vector3 &p_axis, float p_phi) {
-void Vector3::rotate(const Vector3& p_axis,float p_phi) {
-
- *this=Matrix3(p_axis,p_phi).xform(*this);
+ *this = Matrix3(p_axis, p_phi).xform(*this);
}
-Vector3 Vector3::rotated(const Vector3& p_axis,float p_phi) const {
+Vector3 Vector3::rotated(const Vector3 &p_axis, float p_phi) const {
Vector3 r = *this;
- r.rotate(p_axis,p_phi);
+ r.rotate(p_axis, p_phi);
return r;
}
-void Vector3::set_axis(int p_axis,real_t p_value) {
- ERR_FAIL_INDEX(p_axis,3);
- coord[p_axis]=p_value;
-
+void Vector3::set_axis(int p_axis, real_t p_value) {
+ ERR_FAIL_INDEX(p_axis, 3);
+ coord[p_axis] = p_value;
}
real_t Vector3::get_axis(int p_axis) const {
- ERR_FAIL_INDEX_V(p_axis,3,0);
+ ERR_FAIL_INDEX_V(p_axis, 3, 0);
return operator[](p_axis);
}
@@ -62,31 +60,28 @@ int Vector3::max_axis() const {
return x < y ? (y < z ? 2 : 1) : (x < z ? 2 : 0);
}
-
void Vector3::snap(float p_val) {
- x+=p_val/2.0;
- x-=Math::fmod(x,p_val);
- y+=p_val/2.0;
- y-=Math::fmod(y,p_val);
- z+=p_val/2.0;
- z-=Math::fmod(z,p_val);
-
+ x += p_val / 2.0;
+ x -= Math::fmod(x, p_val);
+ y += p_val / 2.0;
+ y -= Math::fmod(y, p_val);
+ z += p_val / 2.0;
+ z -= Math::fmod(z, p_val);
}
Vector3 Vector3::snapped(float p_val) const {
- Vector3 v=*this;
+ Vector3 v = *this;
v.snap(p_val);
return v;
}
+Vector3 Vector3::cubic_interpolaten(const Vector3 &p_b, const Vector3 &p_pre_a, const Vector3 &p_post_b, float p_t) const {
-Vector3 Vector3::cubic_interpolaten(const Vector3& p_b,const Vector3& p_pre_a, const Vector3& p_post_b,float p_t) const {
-
- Vector3 p0=p_pre_a;
- Vector3 p1=*this;
- Vector3 p2=p_b;
- Vector3 p3=p_post_b;
+ Vector3 p0 = p_pre_a;
+ Vector3 p1 = *this;
+ Vector3 p2 = p_b;
+ Vector3 p3 = p_post_b;
{
//normalize
@@ -95,44 +90,41 @@ Vector3 Vector3::cubic_interpolaten(const Vector3& p_b,const Vector3& p_pre_a, c
float bc = p1.distance_to(p2);
float cd = p2.distance_to(p3);
- if (ab>0)
- p0 = p1+(p0-p1)*(bc/ab);
- if (cd>0)
- p3 = p2+(p3-p2)*(bc/cd);
+ if (ab > 0)
+ p0 = p1 + (p0 - p1) * (bc / ab);
+ if (cd > 0)
+ p3 = p2 + (p3 - p2) * (bc / cd);
}
-
float t = p_t;
float t2 = t * t;
float t3 = t2 * t;
Vector3 out;
- out = 0.5f * ( ( p1 * 2.0f) +
- ( -p0 + p2 ) * t +
- ( 2.0f * p0 - 5.0f * p1 + 4 * p2 - p3 ) * t2 +
- ( -p0 + 3.0f * p1 - 3.0f * p2 + p3 ) * t3 );
+ out = 0.5f * ((p1 * 2.0f) +
+ (-p0 + p2) * t +
+ (2.0f * p0 - 5.0f * p1 + 4 * p2 - p3) * t2 +
+ (-p0 + 3.0f * p1 - 3.0f * p2 + p3) * t3);
return out;
-
}
-Vector3 Vector3::cubic_interpolate(const Vector3& p_b,const Vector3& p_pre_a, const Vector3& p_post_b,float p_t) const {
+Vector3 Vector3::cubic_interpolate(const Vector3 &p_b, const Vector3 &p_pre_a, const Vector3 &p_post_b, float p_t) const {
- Vector3 p0=p_pre_a;
- Vector3 p1=*this;
- Vector3 p2=p_b;
- Vector3 p3=p_post_b;
+ Vector3 p0 = p_pre_a;
+ Vector3 p1 = *this;
+ Vector3 p2 = p_b;
+ Vector3 p3 = p_post_b;
float t = p_t;
float t2 = t * t;
float t3 = t2 * t;
Vector3 out;
- out = 0.5f * ( ( p1 * 2.0f) +
- ( -p0 + p2 ) * t +
- ( 2.0f * p0 - 5.0f * p1 + 4 * p2 - p3 ) * t2 +
- ( -p0 + 3.0f * p1 - 3.0f * p2 + p3 ) * t3 );
+ out = 0.5f * ((p1 * 2.0f) +
+ (-p0 + p2) * t +
+ (2.0f * p0 - 5.0f * p1 + 4 * p2 - p3) * t2 +
+ (-p0 + 3.0f * p1 - 3.0f * p2 + p3) * t3);
return out;
-
}
#if 0
@@ -179,8 +171,8 @@ Vector3 Vector3::cubic_interpolate(const Vector3& p_b,const Vector3& p_pre_a, co
( -p0.z + 3.0f * p1.z - 3.0f * p2.z + p3.z ) * t3 );
return out;
}
-# endif
+#endif
Vector3::operator String() const {
- return (rtos(x)+", "+rtos(y)+", "+rtos(z));
+ return (rtos(x) + ", " + rtos(y) + ", " + rtos(z));
}