Added editorconfig file for VS C++ code style formatting.

Applied C++ auto formatting.
This commit is contained in:
2022-08-08 00:20:45 -07:00
parent 870a796f39
commit 82a892cede
25 changed files with 2876 additions and 2480 deletions

View File

@@ -37,55 +37,58 @@
namespace kraken {
class Matrix2x3 {
class Matrix2x3
{
public:
union {
struct {
union
{
struct
{
Vector2 axis_x, axis_y, transform;
};
// Matrix components, in column-major order
float c[6];
};
// Default initializer - Creates an identity matrix
void init();
void init(float *pMat);
void init(const Vector2 &new_axis_x, const Vector2 &new_axis_y, const Vector2 &new_transform);
void init(const Matrix2x3 &m);
void init(float* pMat);
void init(const Vector2& new_axis_x, const Vector2& new_axis_y, const Vector2& new_transform);
void init(const Matrix2x3& m);
// Overload comparison operator
bool operator==(const Matrix2x3 &m) const;
bool operator==(const Matrix2x3& m) const;
// Overload compound multiply operator
Matrix2x3& operator*=(const Matrix2x3 &m);
Matrix2x3& operator*=(const Matrix2x3& m);
float& operator[](unsigned i);
float operator[](unsigned i) const;
// Overload multiply operator
Matrix2x3 operator*(const Matrix2x3 &m) const;
float *getPointer();
Matrix2x3 operator*(const Matrix2x3& m) const;
float* getPointer();
void translate(float x, float y);
void translate(const Vector2 &v);
void translate(const Vector2& v);
void scale(float x, float y);
void scale(const Vector2 &v);
void scale(const Vector2& v);
void scale(float s);
void rotate(float angle);
bool invert();
static Vector2 DotNoTranslate(const Matrix2x3 &m, const Vector2 &v); // Dot product without including translation; useful for transforming normals and tangents
static Matrix2x3 Invert(const Matrix2x3 &m);
static Vector2 Dot(const Matrix2x3 &m, const Vector2 &v);
static Matrix2x3 Translation(const Vector2 &v);
static Vector2 DotNoTranslate(const Matrix2x3& m, const Vector2& v); // Dot product without including translation; useful for transforming normals and tangents
static Matrix2x3 Invert(const Matrix2x3& m);
static Vector2 Dot(const Matrix2x3& m, const Vector2& v);
static Matrix2x3 Translation(const Vector2& v);
static Matrix2x3 Rotation(float angle);
static Matrix2x3 Scaling(const Vector2 &v);
static Matrix2x3 Scaling(const Vector2& v);
static Matrix2x3 Identity();
};
static_assert(std::is_pod<Matrix2x3>::value, "kraken::Matrix2x3 must be a POD type.");
@@ -93,17 +96,18 @@ static_assert(std::is_pod<Matrix2x3>::value, "kraken::Matrix2x3 must be a POD ty
} // namespace kraken
namespace std {
template<>
struct hash<kraken::Matrix2x3> {
public:
size_t operator()(const kraken::Matrix2x3 &s) const
{
size_t h1 = hash<kraken::Vector2>()(s.axis_x);
size_t h2 = hash<kraken::Vector2>()(s.axis_y);
size_t h3 = hash<kraken::Vector2>()(s.transform);
return h1 ^ (h2 << 1) ^ (h3 << 2);
}
};
template<>
struct hash<kraken::Matrix2x3>
{
public:
size_t operator()(const kraken::Matrix2x3& s) const
{
size_t h1 = hash<kraken::Vector2>()(s.axis_x);
size_t h2 = hash<kraken::Vector2>()(s.axis_y);
size_t h3 = hash<kraken::Vector2>()(s.transform);
return h1 ^ (h2 << 1) ^ (h3 << 2);
}
};
} // namespace std
#endif // KRAKEN_MATRIX2X3_H