refactor(Tools): restyle tools with astyle (#3465)

This commit is contained in:
Kargatum
2020-10-06 16:31:28 +07:00
committed by GitHub
parent be09e03756
commit b00a86f6ab
51 changed files with 1004 additions and 936 deletions

View File

@@ -13,39 +13,40 @@
class Vec3D
{
public:
float x,y,z;
float x, y, z;
Vec3D(float x0 = 0.0f, float y0 = 0.0f, float z0 = 0.0f) : x(x0), y(y0), z(z0) {}
Vec3D(const Vec3D& v) : x(v.x), y(v.y), z(v.z) {}
Vec3D& operator= (const Vec3D &v) {
Vec3D& operator= (const Vec3D& v)
{
x = v.x;
y = v.y;
z = v.z;
return *this;
}
Vec3D operator+ (const Vec3D &v) const
Vec3D operator+ (const Vec3D& v) const
{
Vec3D r(x+v.x,y+v.y,z+v.z);
Vec3D r(x + v.x, y + v.y, z + v.z);
return r;
}
Vec3D operator- (const Vec3D &v) const
Vec3D operator- (const Vec3D& v) const
{
Vec3D r(x-v.x,y-v.y,z-v.z);
Vec3D r(x - v.x, y - v.y, z - v.z);
return r;
}
float operator* (const Vec3D &v) const
float operator* (const Vec3D& v) const
{
return x*v.x + y*v.y + z*v.z;
return x * v.x + y * v.y + z * v.z;
}
Vec3D operator* (float d) const
{
Vec3D r(x*d,y*d,z*d);
Vec3D r(x * d, y * d, z * d);
return r;
}
@@ -54,13 +55,13 @@ public:
return v * d;
}
Vec3D operator% (const Vec3D &v) const
Vec3D operator% (const Vec3D& v) const
{
Vec3D r(y*v.z-z*v.y, z*v.x-x*v.z, x*v.y-y*v.x);
Vec3D r(y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x);
return r;
}
Vec3D& operator+= (const Vec3D &v)
Vec3D& operator+= (const Vec3D& v)
{
x += v.x;
y += v.y;
@@ -68,7 +69,7 @@ public:
return *this;
}
Vec3D& operator-= (const Vec3D &v)
Vec3D& operator-= (const Vec3D& v)
{
x -= v.x;
y -= v.y;
@@ -86,17 +87,17 @@ public:
float lengthSquared() const
{
return x*x+y*y+z*z;
return x * x + y * y + z * z;
}
float length() const
{
return sqrt(x*x+y*y+z*z);
return sqrt(x * x + y * y + z * z);
}
Vec3D& normalize()
{
this->operator*= (1.0f/length());
this->operator*= (1.0f / length());
return *this;
}
@@ -119,7 +120,7 @@ public:
return out;
}
operator float*()
operator float* ()
{
return (float*)this;
}
@@ -129,38 +130,39 @@ public:
class Vec2D
{
public:
float x,y;
float x, y;
Vec2D(float x0 = 0.0f, float y0 = 0.0f) : x(x0), y(y0) {}
Vec2D(const Vec2D& v) : x(v.x), y(v.y) {}
Vec2D& operator= (const Vec2D &v) {
Vec2D& operator= (const Vec2D& v)
{
x = v.x;
y = v.y;
return *this;
}
Vec2D operator+ (const Vec2D &v) const
Vec2D operator+ (const Vec2D& v) const
{
Vec2D r(x+v.x,y+v.y);
Vec2D r(x + v.x, y + v.y);
return r;
}
Vec2D operator- (const Vec2D &v) const
Vec2D operator- (const Vec2D& v) const
{
Vec2D r(x-v.x,y-v.y);
Vec2D r(x - v.x, y - v.y);
return r;
}
float operator* (const Vec2D &v) const
float operator* (const Vec2D& v) const
{
return x*v.x + y*v.y;
return x * v.x + y * v.y;
}
Vec2D operator* (float d) const
{
Vec2D r(x*d,y*d);
Vec2D r(x * d, y * d);
return r;
}
@@ -169,14 +171,14 @@ public:
return v * d;
}
Vec2D& operator+= (const Vec2D &v)
Vec2D& operator+= (const Vec2D& v)
{
x += v.x;
y += v.y;
return *this;
}
Vec2D& operator-= (const Vec2D &v)
Vec2D& operator-= (const Vec2D& v)
{
x -= v.x;
y -= v.y;
@@ -192,17 +194,17 @@ public:
float lengthSquared() const
{
return x*x+y*y;
return x * x + y * y;
}
float length() const
{
return sqrt(x*x+y*y);
return sqrt(x * x + y * y);
}
Vec2D& normalize()
{
this->operator*= (1.0f/length());
this->operator*= (1.0f / length());
return *this;
}
@@ -220,17 +222,17 @@ public:
return in;
}
operator float*()
operator float* ()
{
return (float*)this;
}
};
inline void rotate(float x0, float y0, float *x, float *y, float angle)
inline void rotate(float x0, float y0, float* x, float* y, float angle)
{
float xa = *x - x0, ya = *y - y0;
*x = xa*cosf(angle) - ya*sinf(angle) + x0;
*y = xa*sinf(angle) + ya*cosf(angle) + y0;
*x = xa * cosf(angle) - ya * sinf(angle) + x0;
*y = xa * sinf(angle) + ya * cosf(angle) + y0;
}
#endif