You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-14 13:41:12 +00:00
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
5dbf1809c6.
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user