Added editorconfig file for VS C++ code style formatting.
Applied C++ auto formatting.
This commit is contained in:
@@ -43,61 +43,63 @@ namespace kraken {
|
||||
|
||||
class Matrix4;
|
||||
|
||||
class AABB {
|
||||
class AABB
|
||||
{
|
||||
public:
|
||||
Vector3 min;
|
||||
Vector3 max;
|
||||
|
||||
void init(const Vector3 &minPoint, const Vector3 &maxPoint);
|
||||
void init(const Vector3 &corner1, const Vector3 &corner2, const Matrix4 &modelMatrix);
|
||||
void init(const Vector3& minPoint, const Vector3& maxPoint);
|
||||
void init(const Vector3& corner1, const Vector3& corner2, const Matrix4& modelMatrix);
|
||||
void init();
|
||||
static AABB Create(const Vector3 &minPoint, const Vector3 &maxPoint);
|
||||
static AABB Create(const Vector3 &corner1, const Vector3 &corner2, const Matrix4 &modelMatrix);
|
||||
static AABB Create(const Vector3& minPoint, const Vector3& maxPoint);
|
||||
static AABB Create(const Vector3& corner1, const Vector3& corner2, const Matrix4& modelMatrix);
|
||||
static AABB Create();
|
||||
|
||||
void scale(const Vector3 &s);
|
||||
void scale(const Vector3& s);
|
||||
void scale(float s);
|
||||
|
||||
|
||||
Vector3 center() const;
|
||||
Vector3 size() const;
|
||||
float volume() const;
|
||||
bool intersects(const AABB& b) const;
|
||||
bool contains(const AABB &b) const;
|
||||
bool contains(const Vector3 &v) const;
|
||||
|
||||
bool intersectsLine(const Vector3 &v1, const Vector3 &v2) const;
|
||||
bool intersectsRay(const Vector3 &v1, const Vector3 &dir) const;
|
||||
bool intersectsSphere(const Vector3 ¢er, float radius) const;
|
||||
void encapsulate(const AABB & b);
|
||||
|
||||
bool contains(const AABB& b) const;
|
||||
bool contains(const Vector3& v) const;
|
||||
|
||||
bool intersectsLine(const Vector3& v1, const Vector3& v2) const;
|
||||
bool intersectsRay(const Vector3& v1, const Vector3& dir) const;
|
||||
bool intersectsSphere(const Vector3& center, float radius) const;
|
||||
void encapsulate(const AABB& b);
|
||||
|
||||
bool operator ==(const AABB& b) const;
|
||||
bool operator !=(const AABB& b) const;
|
||||
|
||||
|
||||
// Comparison operators are implemented to allow insertion into sorted containers such as std::set
|
||||
bool operator >(const AABB& b) const;
|
||||
bool operator <(const AABB& b) const;
|
||||
|
||||
|
||||
static AABB Infinite();
|
||||
static AABB Zero();
|
||||
|
||||
|
||||
float longest_radius() const;
|
||||
Vector3 nearestPoint(const Vector3 & v) const;
|
||||
Vector3 nearestPoint(const Vector3& v) const;
|
||||
};
|
||||
static_assert(std::is_pod<AABB>::value, "kraken::AABB must be a POD type.");
|
||||
|
||||
} // namespace kraken
|
||||
|
||||
namespace std {
|
||||
template<>
|
||||
struct hash<kraken::AABB> {
|
||||
public:
|
||||
size_t operator()(const kraken::AABB &s) const
|
||||
{
|
||||
size_t h1 = hash<kraken::Vector3>()(s.min);
|
||||
size_t h2 = hash<kraken::Vector3>()(s.max);
|
||||
return h1 ^ ( h2 << 1 );
|
||||
}
|
||||
};
|
||||
template<>
|
||||
struct hash<kraken::AABB>
|
||||
{
|
||||
public:
|
||||
size_t operator()(const kraken::AABB& s) const
|
||||
{
|
||||
size_t h1 = hash<kraken::Vector3>()(s.min);
|
||||
size_t h2 = hash<kraken::Vector3>()(s.max);
|
||||
return h1 ^ (h2 << 1);
|
||||
}
|
||||
};
|
||||
} // namespace std
|
||||
|
||||
|
||||
|
||||
@@ -38,26 +38,27 @@ class KRNode;
|
||||
|
||||
namespace kraken {
|
||||
|
||||
class HitInfo {
|
||||
class HitInfo
|
||||
{
|
||||
public:
|
||||
HitInfo();
|
||||
HitInfo(const Vector3 &position, const Vector3 &normal, const float distance);
|
||||
HitInfo(const Vector3 &position, const Vector3 &normal, const float distance, KRNode *node);
|
||||
~HitInfo();
|
||||
HitInfo();
|
||||
HitInfo(const Vector3& position, const Vector3& normal, const float distance);
|
||||
HitInfo(const Vector3& position, const Vector3& normal, const float distance, KRNode* node);
|
||||
~HitInfo();
|
||||
|
||||
Vector3 getPosition() const;
|
||||
Vector3 getNormal() const;
|
||||
float getDistance() const;
|
||||
KRNode *getNode() const;
|
||||
bool didHit() const;
|
||||
Vector3 getPosition() const;
|
||||
Vector3 getNormal() const;
|
||||
float getDistance() const;
|
||||
KRNode* getNode() const;
|
||||
bool didHit() const;
|
||||
|
||||
HitInfo& operator =(const HitInfo& b);
|
||||
HitInfo& operator =(const HitInfo& b);
|
||||
|
||||
private:
|
||||
KRNode *m_node;
|
||||
Vector3 m_position;
|
||||
Vector3 m_normal;
|
||||
float m_distance;
|
||||
KRNode* m_node;
|
||||
Vector3 m_position;
|
||||
Vector3 m_normal;
|
||||
float m_distance;
|
||||
};
|
||||
|
||||
} // namespace kraken
|
||||
|
||||
@@ -36,54 +36,57 @@
|
||||
|
||||
namespace kraken {
|
||||
|
||||
class Matrix2 {
|
||||
class Matrix2
|
||||
{
|
||||
public:
|
||||
|
||||
union {
|
||||
struct {
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
Vector2 axis_x, axis_y;
|
||||
};
|
||||
// Matrix components, in column-major order
|
||||
float c[4];
|
||||
};
|
||||
|
||||
|
||||
// Default initializer - Creates an identity matrix
|
||||
void init();
|
||||
|
||||
void init(float *pMat);
|
||||
|
||||
void init(const Vector2 &new_axis_x, const Vector2 &new_axis_y);
|
||||
|
||||
void init(const Matrix2 &m);
|
||||
|
||||
void init(float* pMat);
|
||||
|
||||
void init(const Vector2& new_axis_x, const Vector2& new_axis_y);
|
||||
|
||||
void init(const Matrix2& m);
|
||||
|
||||
// Overload comparison operator
|
||||
bool operator==(const Matrix2 &m) const;
|
||||
|
||||
bool operator==(const Matrix2& m) const;
|
||||
|
||||
// Overload compound multiply operator
|
||||
Matrix2& operator*=(const Matrix2 &m);
|
||||
|
||||
Matrix2& operator*=(const Matrix2& m);
|
||||
|
||||
float& operator[](unsigned i);
|
||||
float operator[](unsigned i) const;
|
||||
|
||||
|
||||
// Overload multiply operator
|
||||
//Matrix4& operator*(const Matrix4 &m);
|
||||
Matrix2 operator*(const Matrix2 &m) const;
|
||||
|
||||
float *getPointer();
|
||||
|
||||
Matrix2 operator*(const Matrix2& m) const;
|
||||
|
||||
float* getPointer();
|
||||
|
||||
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();
|
||||
void transpose();
|
||||
|
||||
static Matrix2 Invert(const Matrix2 &m);
|
||||
static Matrix2 Transpose(const Matrix2 &m);
|
||||
static Vector2 Dot(const Matrix2 &m, const Vector2 &v);
|
||||
|
||||
static Matrix2 Invert(const Matrix2& m);
|
||||
static Matrix2 Transpose(const Matrix2& m);
|
||||
static Vector2 Dot(const Matrix2& m, const Vector2& v);
|
||||
|
||||
static Matrix2 Rotation(float);
|
||||
static Matrix2 Scaling(const Vector2 &v);
|
||||
static Matrix2 Scaling(const Vector2& v);
|
||||
static Matrix2 Identity();
|
||||
};
|
||||
static_assert(std::is_pod<Matrix2>::value, "kraken::Matrix2 must be a POD type.");
|
||||
@@ -91,16 +94,17 @@ static_assert(std::is_pod<Matrix2>::value, "kraken::Matrix2 must be a POD type."
|
||||
} // namespace kraken
|
||||
|
||||
namespace std {
|
||||
template<>
|
||||
struct hash<kraken::Matrix2> {
|
||||
public:
|
||||
size_t operator()(const kraken::Matrix2 &s) const
|
||||
{
|
||||
size_t h1 = hash<kraken::Vector2>()(s.axis_x);
|
||||
size_t h2 = hash<kraken::Vector2>()(s.axis_y);
|
||||
return h1 ^ (h2 << 1);
|
||||
}
|
||||
};
|
||||
template<>
|
||||
struct hash<kraken::Matrix2>
|
||||
{
|
||||
public:
|
||||
size_t operator()(const kraken::Matrix2& s) const
|
||||
{
|
||||
size_t h1 = hash<kraken::Vector2>()(s.axis_x);
|
||||
size_t h2 = hash<kraken::Vector2>()(s.axis_y);
|
||||
return h1 ^ (h2 << 1);
|
||||
}
|
||||
};
|
||||
} // namespace std
|
||||
|
||||
#endif // KRAKEN_MATRIX2_H
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -38,7 +38,8 @@
|
||||
|
||||
namespace kraken {
|
||||
|
||||
enum class AXIS {
|
||||
enum class AXIS
|
||||
{
|
||||
X_AXIS,
|
||||
Y_AXIS,
|
||||
Z_AXIS
|
||||
@@ -46,68 +47,71 @@ enum class AXIS {
|
||||
|
||||
class Quaternion;
|
||||
|
||||
class Matrix4 {
|
||||
class Matrix4
|
||||
{
|
||||
public:
|
||||
|
||||
union {
|
||||
struct {
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
Vector4 axis_x, axis_y, axis_z, transform;
|
||||
};
|
||||
// Matrix components, in column-major order
|
||||
float c[16];
|
||||
};
|
||||
|
||||
|
||||
// Default initializer - Creates an identity matrix
|
||||
void init();
|
||||
|
||||
void init(float *pMat);
|
||||
void init(const Vector3 &new_axis_x, const Vector3 &new_axis_y, const Vector3 &new_axis_z, const Vector3 &new_transform);
|
||||
void init(const Matrix4 &m);
|
||||
|
||||
static Matrix4 Create(float *pMat);
|
||||
static Matrix4 Create(const Vector3 &new_axis_x, const Vector3 &new_axis_y, const Vector3 &new_axis_z, const Vector3 &new_transform);
|
||||
|
||||
void init(float* pMat);
|
||||
void init(const Vector3& new_axis_x, const Vector3& new_axis_y, const Vector3& new_axis_z, const Vector3& new_transform);
|
||||
void init(const Matrix4& m);
|
||||
|
||||
static Matrix4 Create(float* pMat);
|
||||
static Matrix4 Create(const Vector3& new_axis_x, const Vector3& new_axis_y, const Vector3& new_axis_z, const Vector3& new_transform);
|
||||
|
||||
// Overload comparison operator
|
||||
bool operator==(const Matrix4 &m) const;
|
||||
|
||||
bool operator==(const Matrix4& m) const;
|
||||
|
||||
// Overload compound multiply operator
|
||||
Matrix4& operator*=(const Matrix4 &m);
|
||||
|
||||
Matrix4& operator*=(const Matrix4& m);
|
||||
|
||||
float& operator[](unsigned i);
|
||||
float operator[](unsigned i) const;
|
||||
|
||||
|
||||
// Overload multiply operator
|
||||
//Matrix4& operator*(const Matrix4 &m);
|
||||
Matrix4 operator*(const Matrix4 &m) const;
|
||||
|
||||
float *getPointer();
|
||||
|
||||
Matrix4 operator*(const Matrix4& m) const;
|
||||
|
||||
float* getPointer();
|
||||
|
||||
void perspective(float fov, float aspect, float nearz, float farz);
|
||||
void ortho(float left, float right, float top, float bottom, float nearz, float farz);
|
||||
void translate(float x, float y, float z);
|
||||
void translate(const Vector3 &v);
|
||||
void translate(const Vector3& v);
|
||||
void scale(float x, float y, float z);
|
||||
void scale(const Vector3 &v);
|
||||
void scale(const Vector3& v);
|
||||
void scale(float s);
|
||||
void rotate(float angle, AXIS axis);
|
||||
void rotate(const Quaternion &q);
|
||||
void rotate(const Quaternion& q);
|
||||
void bias();
|
||||
bool invert();
|
||||
void transpose();
|
||||
|
||||
static Vector3 DotNoTranslate(const Matrix4 &m, const Vector3 &v); // Dot product without including translation; useful for transforming normals and tangents
|
||||
static Matrix4 Invert(const Matrix4 &m);
|
||||
static Matrix4 Transpose(const Matrix4 &m);
|
||||
static Vector3 Dot(const Matrix4 &m, const Vector3 &v);
|
||||
static Vector4 Dot4(const Matrix4 &m, const Vector4 &v);
|
||||
static float DotW(const Matrix4 &m, const Vector3 &v);
|
||||
static Vector3 DotWDiv(const Matrix4 &m, const Vector3 &v);
|
||||
|
||||
static Matrix4 LookAt(const Vector3 &cameraPos, const Vector3 &lookAtPos, const Vector3 &upDirection);
|
||||
|
||||
static Matrix4 Translation(const Vector3 &v);
|
||||
static Matrix4 Rotation(const Vector3 &v);
|
||||
static Matrix4 Scaling(const Vector3 &v);
|
||||
|
||||
static Vector3 DotNoTranslate(const Matrix4& m, const Vector3& v); // Dot product without including translation; useful for transforming normals and tangents
|
||||
static Matrix4 Invert(const Matrix4& m);
|
||||
static Matrix4 Transpose(const Matrix4& m);
|
||||
static Vector3 Dot(const Matrix4& m, const Vector3& v);
|
||||
static Vector4 Dot4(const Matrix4& m, const Vector4& v);
|
||||
static float DotW(const Matrix4& m, const Vector3& v);
|
||||
static Vector3 DotWDiv(const Matrix4& m, const Vector3& v);
|
||||
|
||||
static Matrix4 LookAt(const Vector3& cameraPos, const Vector3& lookAtPos, const Vector3& upDirection);
|
||||
|
||||
static Matrix4 Translation(const Vector3& v);
|
||||
static Matrix4 Rotation(const Vector3& v);
|
||||
static Matrix4 Scaling(const Vector3& v);
|
||||
static Matrix4 Identity();
|
||||
};
|
||||
static_assert(std::is_pod<Matrix4>::value, "kraken::Matrix4 must be a POD type.");
|
||||
@@ -115,18 +119,19 @@ static_assert(std::is_pod<Matrix4>::value, "kraken::Matrix4 must be a POD type."
|
||||
} // namespace kraken
|
||||
|
||||
namespace std {
|
||||
template<>
|
||||
struct hash<kraken::Matrix4> {
|
||||
public:
|
||||
size_t operator()(const kraken::Matrix4 &s) const
|
||||
{
|
||||
size_t h1 = hash<kraken::Vector4>()(s.axis_x);
|
||||
size_t h2 = hash<kraken::Vector4>()(s.axis_y);
|
||||
size_t h3 = hash<kraken::Vector4>()(s.axis_z);
|
||||
size_t h4 = hash<kraken::Vector4>()(s.transform);
|
||||
return h1 ^ (h2 << 1) ^ (h3 << 2) ^ (h4 << 3);
|
||||
}
|
||||
};
|
||||
template<>
|
||||
struct hash<kraken::Matrix4>
|
||||
{
|
||||
public:
|
||||
size_t operator()(const kraken::Matrix4& s) const
|
||||
{
|
||||
size_t h1 = hash<kraken::Vector4>()(s.axis_x);
|
||||
size_t h2 = hash<kraken::Vector4>()(s.axis_y);
|
||||
size_t h3 = hash<kraken::Vector4>()(s.axis_z);
|
||||
size_t h4 = hash<kraken::Vector4>()(s.transform);
|
||||
return h1 ^ (h2 << 1) ^ (h3 << 2) ^ (h4 << 3);
|
||||
}
|
||||
};
|
||||
} // namespace std
|
||||
|
||||
#endif // KRAKEN_MATRIX4_H
|
||||
|
||||
@@ -36,10 +36,13 @@
|
||||
|
||||
namespace kraken {
|
||||
|
||||
class Quaternion {
|
||||
class Quaternion
|
||||
{
|
||||
public:
|
||||
union {
|
||||
struct {
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
float w, x, y, z;
|
||||
};
|
||||
float c[4];
|
||||
@@ -48,71 +51,72 @@ public:
|
||||
void init();
|
||||
void init(float w, float x, float y, float z);
|
||||
void init(const Quaternion& p);
|
||||
void init(const Vector3 &euler);
|
||||
void init(const Vector3 &from_vector, const Vector3 &to_vector);
|
||||
void init(const Vector3& euler);
|
||||
void init(const Vector3& from_vector, const Vector3& to_vector);
|
||||
static Quaternion Create();
|
||||
static Quaternion Create(float w, float x, float y, float z);
|
||||
static Quaternion Create(const Quaternion& p);
|
||||
static Quaternion Create(const Vector3 &euler);
|
||||
static Quaternion Create(const Vector3 &from_vector, const Vector3 &to_vector);
|
||||
|
||||
Quaternion operator +(const Quaternion &v) const;
|
||||
Quaternion operator -(const Quaternion &v) const;
|
||||
static Quaternion Create(const Vector3& euler);
|
||||
static Quaternion Create(const Vector3& from_vector, const Vector3& to_vector);
|
||||
|
||||
Quaternion operator +(const Quaternion& v) const;
|
||||
Quaternion operator -(const Quaternion& v) const;
|
||||
Quaternion operator +() const;
|
||||
Quaternion operator -() const;
|
||||
|
||||
Quaternion operator *(const Quaternion &v);
|
||||
|
||||
Quaternion operator *(const Quaternion& v);
|
||||
Quaternion operator *(float num) const;
|
||||
Quaternion operator /(float num) const;
|
||||
|
||||
|
||||
Quaternion& operator +=(const Quaternion& v);
|
||||
Quaternion& operator -=(const Quaternion& v);
|
||||
Quaternion& operator *=(const Quaternion& v);
|
||||
Quaternion& operator *=(const float& v);
|
||||
Quaternion& operator /=(const float& v);
|
||||
|
||||
friend bool operator ==(Quaternion &v1, Quaternion &v2);
|
||||
friend bool operator !=(Quaternion &v1, Quaternion &v2);
|
||||
friend bool operator ==(Quaternion& v1, Quaternion& v2);
|
||||
friend bool operator !=(Quaternion& v1, Quaternion& v2);
|
||||
float& operator [](unsigned i);
|
||||
float operator [](unsigned i) const;
|
||||
|
||||
void setEulerXYZ(const Vector3 &euler);
|
||||
void setEulerZYX(const Vector3 &euler);
|
||||
|
||||
void setEulerXYZ(const Vector3& euler);
|
||||
void setEulerZYX(const Vector3& euler);
|
||||
Vector3 eulerXYZ() const;
|
||||
Matrix4 rotationMatrix() const;
|
||||
|
||||
|
||||
void normalize();
|
||||
static Quaternion Normalize(const Quaternion &v1);
|
||||
|
||||
static Quaternion Normalize(const Quaternion& v1);
|
||||
|
||||
void conjugate();
|
||||
static Quaternion Conjugate(const Quaternion &v1);
|
||||
static Quaternion Conjugate(const Quaternion& v1);
|
||||
|
||||
void invert();
|
||||
static Quaternion Invert(const Quaternion &v1);
|
||||
|
||||
static Quaternion FromAngleAxis(const Vector3 &axis, float angle);
|
||||
static Quaternion FromRotationMatrix(const Matrix4 &m);
|
||||
static Quaternion Lerp(const Quaternion &a, const Quaternion &b, float t);
|
||||
static Quaternion Slerp(const Quaternion &a, const Quaternion &b, float t);
|
||||
static float Dot(const Quaternion &v1, const Quaternion &v2);
|
||||
static Quaternion Invert(const Quaternion& v1);
|
||||
|
||||
static Quaternion FromAngleAxis(const Vector3& axis, float angle);
|
||||
static Quaternion FromRotationMatrix(const Matrix4& m);
|
||||
static Quaternion Lerp(const Quaternion& a, const Quaternion& b, float t);
|
||||
static Quaternion Slerp(const Quaternion& a, const Quaternion& b, float t);
|
||||
static float Dot(const Quaternion& v1, const Quaternion& v2);
|
||||
};
|
||||
static_assert(std::is_pod<Quaternion>::value, "kraken::Quaternion must be a POD type.");
|
||||
|
||||
} // namespace kraken
|
||||
|
||||
namespace std {
|
||||
template<>
|
||||
struct hash<kraken::Quaternion> {
|
||||
public:
|
||||
size_t operator()(const kraken::Quaternion &s) const
|
||||
{
|
||||
size_t h1 = hash<float>()(s.c[0]);
|
||||
size_t h2 = hash<float>()(s.c[1]);
|
||||
size_t h3 = hash<float>()(s.c[2]);
|
||||
size_t h4 = hash<float>()(s.c[3]);
|
||||
return h1 ^ (h2 << 1) ^ (h3 << 2) ^ (h4 << 3);
|
||||
}
|
||||
};
|
||||
template<>
|
||||
struct hash<kraken::Quaternion>
|
||||
{
|
||||
public:
|
||||
size_t operator()(const kraken::Quaternion& s) const
|
||||
{
|
||||
size_t h1 = hash<float>()(s.c[0]);
|
||||
size_t h2 = hash<float>()(s.c[1]);
|
||||
size_t h3 = hash<float>()(s.c[2]);
|
||||
size_t h4 = hash<float>()(s.c[3]);
|
||||
return h1 ^ (h2 << 1) ^ (h3 << 2) ^ (h4 << 3);
|
||||
}
|
||||
};
|
||||
} // namespace std
|
||||
|
||||
#endif // KRAKEN_QUATERNION_H
|
||||
|
||||
@@ -34,8 +34,8 @@
|
||||
|
||||
namespace kraken {
|
||||
|
||||
float SmoothStep(float a, float b, float t);
|
||||
float Lerp(float a, float b, float t);
|
||||
float SmoothStep(float a, float b, float t);
|
||||
float Lerp(float a, float b, float t);
|
||||
|
||||
}; // namespace kraken
|
||||
|
||||
|
||||
@@ -41,40 +41,41 @@ class Triangle3
|
||||
public:
|
||||
Vector3 vert[3];
|
||||
|
||||
void init(const Triangle3 &tri);
|
||||
void init(const Vector3 &v1, const Vector3 &v2, const Vector3 &v3);
|
||||
static Triangle3 Create(const Triangle3 &tri);
|
||||
static Triangle3 Create(const Vector3 &v1, const Vector3 &v2, const Vector3 &v3);
|
||||
|
||||
void init(const Triangle3& tri);
|
||||
void init(const Vector3& v1, const Vector3& v2, const Vector3& v3);
|
||||
static Triangle3 Create(const Triangle3& tri);
|
||||
static Triangle3 Create(const Vector3& v1, const Vector3& v2, const Vector3& v3);
|
||||
|
||||
Vector3 calculateNormal() const;
|
||||
|
||||
|
||||
bool operator ==(const Triangle3& b) const;
|
||||
bool operator !=(const Triangle3& b) const;
|
||||
Vector3& operator[](unsigned int i);
|
||||
Vector3 operator[](unsigned int i) const;
|
||||
|
||||
bool rayCast(const Vector3 &start, const Vector3 &dir, Vector3 &hit_point) const;
|
||||
bool sphereCast(const Vector3 &start, const Vector3 &dir, float radius, Vector3 &hit_point, float &hit_distance) const;
|
||||
|
||||
bool containsPoint(const Vector3 &p) const;
|
||||
Vector3 closestPointOnTriangle(const Vector3 &p) const;
|
||||
|
||||
bool rayCast(const Vector3& start, const Vector3& dir, Vector3& hit_point) const;
|
||||
bool sphereCast(const Vector3& start, const Vector3& dir, float radius, Vector3& hit_point, float& hit_distance) const;
|
||||
|
||||
bool containsPoint(const Vector3& p) const;
|
||||
Vector3 closestPointOnTriangle(const Vector3& p) const;
|
||||
};
|
||||
static_assert(std::is_pod<Triangle3>::value, "kraken::Triangle3 must be a POD type.");
|
||||
|
||||
} // namespace kraken
|
||||
|
||||
namespace std {
|
||||
template<>
|
||||
struct hash<kraken::Triangle3> {
|
||||
public:
|
||||
size_t operator()(const kraken::Triangle3 &s) const
|
||||
{
|
||||
size_t h1 = hash<kraken::Vector3>()(s.vert[0]);
|
||||
size_t h2 = hash<kraken::Vector3>()(s.vert[1]);
|
||||
size_t h3 = hash<kraken::Vector3>()(s.vert[2]);
|
||||
return h1 ^ (h2 << 1) ^ (h3 << 2);
|
||||
}
|
||||
};
|
||||
template<>
|
||||
struct hash<kraken::Triangle3>
|
||||
{
|
||||
public:
|
||||
size_t operator()(const kraken::Triangle3& s) const
|
||||
{
|
||||
size_t h1 = hash<kraken::Vector3>()(s.vert[0]);
|
||||
size_t h2 = hash<kraken::Vector3>()(s.vert[1]);
|
||||
size_t h3 = hash<kraken::Vector3>()(s.vert[2]);
|
||||
return h1 ^ (h2 << 1) ^ (h3 << 2);
|
||||
}
|
||||
};
|
||||
} // namespace std
|
||||
|
||||
#endif // KRAKEN_TRIANGLE3_H
|
||||
|
||||
@@ -38,65 +38,68 @@
|
||||
|
||||
namespace kraken {
|
||||
|
||||
class Vector2 {
|
||||
|
||||
class Vector2
|
||||
{
|
||||
|
||||
public:
|
||||
union {
|
||||
struct {
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
float x, y;
|
||||
};
|
||||
float c[2];
|
||||
};
|
||||
|
||||
|
||||
void init();
|
||||
void init(float X, float Y);
|
||||
void init(float v);
|
||||
void init(float *v);
|
||||
void init(const Vector2 &v);
|
||||
void init(float* v);
|
||||
void init(const Vector2& v);
|
||||
static Vector2 Create();
|
||||
static Vector2 Create(float X, float Y);
|
||||
static Vector2 Create(float v);
|
||||
static Vector2 Create(float *v);
|
||||
static Vector2 Create(const Vector2 &v);
|
||||
static Vector2 Create(float* v);
|
||||
static Vector2 Create(const Vector2& v);
|
||||
|
||||
// Vector2 swizzle getters
|
||||
Vector2 yx() const;
|
||||
|
||||
|
||||
// Vector2 swizzle setters
|
||||
void yx(const Vector2 &v);
|
||||
|
||||
void yx(const Vector2& v);
|
||||
|
||||
Vector2 operator +(const Vector2& b) const;
|
||||
Vector2 operator -(const Vector2& b) const;
|
||||
Vector2 operator +() const;
|
||||
Vector2 operator -() const;
|
||||
Vector2 operator *(const float v) const;
|
||||
Vector2 operator /(const float v) const;
|
||||
|
||||
|
||||
Vector2& operator +=(const Vector2& b);
|
||||
Vector2& operator -=(const Vector2& b);
|
||||
Vector2& operator *=(const float v);
|
||||
Vector2& operator /=(const float v);
|
||||
|
||||
|
||||
// Comparison operators are implemented to allow insertion into sorted containers such as std::set
|
||||
bool operator >(const Vector2& b) const;
|
||||
bool operator <(const Vector2& b) const;
|
||||
|
||||
|
||||
bool operator ==(const Vector2& b) const;
|
||||
bool operator !=(const Vector2& b) const;
|
||||
|
||||
|
||||
float& operator[](unsigned i);
|
||||
float operator[](unsigned i) const;
|
||||
|
||||
|
||||
float sqrMagnitude() const;
|
||||
float magnitude() const;
|
||||
|
||||
void normalize();
|
||||
static Vector2 Normalize(const Vector2 &v);
|
||||
static Vector2 Normalize(const Vector2& v);
|
||||
|
||||
static float Cross(const Vector2 &v1, const Vector2 &v2);
|
||||
static float Dot(const Vector2 &v1, const Vector2 &v2);
|
||||
static Vector2 Min(const Vector2 &v1, const Vector2 &v2);
|
||||
static Vector2 Max(const Vector2 &v1, const Vector2 &v2);
|
||||
static float Cross(const Vector2& v1, const Vector2& v2);
|
||||
static float Dot(const Vector2& v1, const Vector2& v2);
|
||||
static Vector2 Min(const Vector2& v1, const Vector2& v2);
|
||||
static Vector2 Max(const Vector2& v1, const Vector2& v2);
|
||||
static Vector2 Min();
|
||||
static Vector2 Max();
|
||||
static Vector2 Zero();
|
||||
@@ -107,16 +110,17 @@ static_assert(std::is_pod<Vector2>::value, "kraken::Vector2 must be a POD type."
|
||||
} // namespace kraken
|
||||
|
||||
namespace std {
|
||||
template<>
|
||||
struct hash<kraken::Vector2> {
|
||||
public:
|
||||
size_t operator()(const kraken::Vector2 &s) const
|
||||
{
|
||||
size_t h1 = hash<float>()(s.x);
|
||||
size_t h2 = hash<float>()(s.y);
|
||||
return h1 ^ (h2 << 1);
|
||||
}
|
||||
};
|
||||
template<>
|
||||
struct hash<kraken::Vector2>
|
||||
{
|
||||
public:
|
||||
size_t operator()(const kraken::Vector2& s) const
|
||||
{
|
||||
size_t h1 = hash<float>()(s.x);
|
||||
size_t h2 = hash<float>()(s.y);
|
||||
return h1 ^ (h2 << 1);
|
||||
}
|
||||
};
|
||||
} // namespace std
|
||||
|
||||
#endif // KRAKEN_VECTOR2_H
|
||||
|
||||
@@ -37,11 +37,14 @@
|
||||
|
||||
namespace kraken {
|
||||
|
||||
class Vector2i {
|
||||
class Vector2i
|
||||
{
|
||||
|
||||
public:
|
||||
union {
|
||||
struct {
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
int x, y;
|
||||
};
|
||||
int c[2];
|
||||
@@ -50,52 +53,52 @@ public:
|
||||
void init();
|
||||
void init(int X, int Y);
|
||||
void init(int v);
|
||||
void init(int *v);
|
||||
void init(const Vector2i &v);
|
||||
void init(int* v);
|
||||
void init(const Vector2i& v);
|
||||
static Vector2i Create();
|
||||
static Vector2i Create(int X, int Y);
|
||||
static Vector2i Create(int v);
|
||||
static Vector2i Create(int *v);
|
||||
static Vector2i Create(const Vector2i &v);
|
||||
static Vector2i Create(int* v);
|
||||
static Vector2i Create(const Vector2i& v);
|
||||
|
||||
// Vector2 swizzle getters
|
||||
Vector2i yx() const;
|
||||
|
||||
|
||||
// Vector2 swizzle setters
|
||||
void yx(const Vector2i &v);
|
||||
|
||||
void yx(const Vector2i& v);
|
||||
|
||||
Vector2i operator +(const Vector2i& b) const;
|
||||
Vector2i operator -(const Vector2i& b) const;
|
||||
Vector2i operator +() const;
|
||||
Vector2i operator -() const;
|
||||
Vector2i operator *(const int v) const;
|
||||
Vector2i operator /(const int v) const;
|
||||
|
||||
|
||||
Vector2i& operator +=(const Vector2i& b);
|
||||
Vector2i& operator -=(const Vector2i& b);
|
||||
Vector2i& operator *=(const int v);
|
||||
Vector2i& operator /=(const int v);
|
||||
|
||||
|
||||
// Comparison operators are implemented to allow insertion into sorted containers such as std::set
|
||||
bool operator >(const Vector2i& b) const;
|
||||
bool operator <(const Vector2i& b) const;
|
||||
|
||||
|
||||
bool operator ==(const Vector2i& b) const;
|
||||
bool operator !=(const Vector2i& b) const;
|
||||
|
||||
|
||||
int& operator[](unsigned i);
|
||||
int operator[](unsigned i) const;
|
||||
|
||||
|
||||
int sqrMagnitude() const;
|
||||
int magnitude() const;
|
||||
|
||||
void normalize();
|
||||
static Vector2i Normalize(const Vector2i &v);
|
||||
static Vector2i Normalize(const Vector2i& v);
|
||||
|
||||
static int Cross(const Vector2i &v1, const Vector2i &v2);
|
||||
static int Dot(const Vector2i &v1, const Vector2i &v2);
|
||||
static Vector2i Min(const Vector2i &v1, const Vector2i &v2);
|
||||
static Vector2i Max(const Vector2i &v1, const Vector2i &v2);
|
||||
static int Cross(const Vector2i& v1, const Vector2i& v2);
|
||||
static int Dot(const Vector2i& v1, const Vector2i& v2);
|
||||
static Vector2i Min(const Vector2i& v1, const Vector2i& v2);
|
||||
static Vector2i Max(const Vector2i& v1, const Vector2i& v2);
|
||||
|
||||
static Vector2i Min();
|
||||
static Vector2i Max();
|
||||
@@ -107,14 +110,15 @@ static_assert(std::is_pod<Vector2i>::value, "kraken::Vector2i must be a POD type
|
||||
} // namespace kraken
|
||||
|
||||
namespace std {
|
||||
template<>
|
||||
struct hash<kraken::Vector2i> {
|
||||
public:
|
||||
size_t operator()(const kraken::Vector2i &s) const
|
||||
{
|
||||
size_t h1 = hash<int>()(s.x);
|
||||
size_t h2 = hash<int>()(s.y);
|
||||
return h1 ^ (h2 << 1);
|
||||
}
|
||||
};
|
||||
template<>
|
||||
struct hash<kraken::Vector2i>
|
||||
{
|
||||
public:
|
||||
size_t operator()(const kraken::Vector2i& s) const
|
||||
{
|
||||
size_t h1 = hash<int>()(s.x);
|
||||
size_t h2 = hash<int>()(s.y);
|
||||
return h1 ^ (h2 << 1);
|
||||
}
|
||||
};
|
||||
} // namespace std
|
||||
|
||||
@@ -38,32 +38,35 @@
|
||||
|
||||
namespace kraken {
|
||||
|
||||
class Vector3 {
|
||||
class Vector3
|
||||
{
|
||||
|
||||
public:
|
||||
union {
|
||||
struct {
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
float x, y, z;
|
||||
};
|
||||
float c[3];
|
||||
};
|
||||
|
||||
|
||||
void init();
|
||||
void init(float X, float Y, float Z);
|
||||
void init(float v);
|
||||
void init(float *v);
|
||||
void init(double *v);
|
||||
void init(const Vector3 &v);
|
||||
void init(const Vector4 &v);
|
||||
void init(float* v);
|
||||
void init(double* v);
|
||||
void init(const Vector3& v);
|
||||
void init(const Vector4& v);
|
||||
static Vector3 Create();
|
||||
static Vector3 Create(float X, float Y, float Z);
|
||||
static Vector3 Create(float v);
|
||||
static Vector3 Create(float *v);
|
||||
static Vector3 Create(double *v);
|
||||
static Vector3 Create(const Vector3 &v);
|
||||
static Vector3 Create(const Vector4 &v);
|
||||
static Vector3 Create(float* v);
|
||||
static Vector3 Create(double* v);
|
||||
static Vector3 Create(const Vector3& v);
|
||||
static Vector3 Create(const Vector4& v);
|
||||
|
||||
|
||||
|
||||
// Vector2 swizzle getters
|
||||
Vector2 xx() const;
|
||||
Vector2 xy() const;
|
||||
@@ -74,15 +77,15 @@ public:
|
||||
Vector2 zx() const;
|
||||
Vector2 zy() const;
|
||||
Vector2 zz() const;
|
||||
|
||||
|
||||
// Vector2 swizzle setters
|
||||
void xy(const Vector2 &v);
|
||||
void xz(const Vector2 &v);
|
||||
void yx(const Vector2 &v);
|
||||
void yz(const Vector2 &v);
|
||||
void zx(const Vector2 &v);
|
||||
void zy(const Vector2 &v);
|
||||
|
||||
void xy(const Vector2& v);
|
||||
void xz(const Vector2& v);
|
||||
void yx(const Vector2& v);
|
||||
void yz(const Vector2& v);
|
||||
void zx(const Vector2& v);
|
||||
void zy(const Vector2& v);
|
||||
|
||||
Vector3& operator =(const Vector4& b);
|
||||
Vector3 operator +(const Vector3& b) const;
|
||||
Vector3 operator -(const Vector3& b) const;
|
||||
@@ -90,33 +93,33 @@ public:
|
||||
Vector3 operator -() const;
|
||||
Vector3 operator *(const float v) const;
|
||||
Vector3 operator /(const float v) const;
|
||||
|
||||
|
||||
Vector3& operator +=(const Vector3& b);
|
||||
Vector3& operator -=(const Vector3& b);
|
||||
Vector3& operator *=(const float v);
|
||||
Vector3& operator /=(const float v);
|
||||
|
||||
|
||||
bool operator ==(const Vector3& b) const;
|
||||
bool operator !=(const Vector3& b) const;
|
||||
|
||||
|
||||
// Comparison operators are implemented to allow insertion into sorted containers such as std::set
|
||||
bool operator >(const Vector3& b) const;
|
||||
bool operator <(const Vector3& b) const;
|
||||
|
||||
|
||||
float& operator[](unsigned i);
|
||||
float operator[](unsigned i) const;
|
||||
|
||||
|
||||
float sqrMagnitude() const; // calculate the square of the magnitude (useful for comparison of magnitudes without the cost of a sqrt() function)
|
||||
float magnitude() const;
|
||||
|
||||
void scale(const Vector3 &v);
|
||||
|
||||
void scale(const Vector3& v);
|
||||
void normalize();
|
||||
static Vector3 Normalize(const Vector3 &v);
|
||||
|
||||
static Vector3 Cross(const Vector3 &v1, const Vector3 &v2);
|
||||
static float Dot(const Vector3 &v1, const Vector3 &v2);
|
||||
static Vector3 Min(const Vector3 &v1, const Vector3 &v2);
|
||||
static Vector3 Max(const Vector3 &v1, const Vector3 &v2);
|
||||
static Vector3 Normalize(const Vector3& v);
|
||||
|
||||
static Vector3 Cross(const Vector3& v1, const Vector3& v2);
|
||||
static float Dot(const Vector3& v1, const Vector3& v2);
|
||||
static Vector3 Min(const Vector3& v1, const Vector3& v2);
|
||||
static Vector3 Max(const Vector3& v1, const Vector3& v2);
|
||||
|
||||
static Vector3 Min();
|
||||
static Vector3 Max();
|
||||
@@ -128,25 +131,26 @@ public:
|
||||
static Vector3 Down();
|
||||
static Vector3 Left();
|
||||
static Vector3 Right();
|
||||
static Vector3 Scale(const Vector3 &v1, const Vector3 &v2);
|
||||
static Vector3 Lerp(const Vector3 &v1, const Vector3 &v2, float d);
|
||||
static Vector3 Slerp(const Vector3 &v1, const Vector3 &v2, float d);
|
||||
static void OrthoNormalize(Vector3 &normal, Vector3 &tangent); // Gram-Schmidt Orthonormalization
|
||||
static Vector3 Scale(const Vector3& v1, const Vector3& v2);
|
||||
static Vector3 Lerp(const Vector3& v1, const Vector3& v2, float d);
|
||||
static Vector3 Slerp(const Vector3& v1, const Vector3& v2, float d);
|
||||
static void OrthoNormalize(Vector3& normal, Vector3& tangent); // Gram-Schmidt Orthonormalization
|
||||
};
|
||||
static_assert(std::is_pod<Vector3>::value, "kraken::Vector3 must be a POD type.");
|
||||
|
||||
} // namespace kraken
|
||||
|
||||
namespace std {
|
||||
template<>
|
||||
struct hash<kraken::Vector3> {
|
||||
public:
|
||||
size_t operator()(const kraken::Vector3 &s) const
|
||||
{
|
||||
size_t h1 = hash<float>()(s.x);
|
||||
size_t h2 = hash<float>()(s.y);
|
||||
size_t h3 = hash<float>()(s.z);
|
||||
return h1 ^ (h2 << 1) ^ (h3 << 2);
|
||||
}
|
||||
};
|
||||
template<>
|
||||
struct hash<kraken::Vector3>
|
||||
{
|
||||
public:
|
||||
size_t operator()(const kraken::Vector3& s) const
|
||||
{
|
||||
size_t h1 = hash<float>()(s.x);
|
||||
size_t h2 = hash<float>()(s.y);
|
||||
size_t h3 = hash<float>()(s.z);
|
||||
return h1 ^ (h2 << 1) ^ (h3 << 2);
|
||||
}
|
||||
};
|
||||
} // namespace std
|
||||
|
||||
@@ -37,11 +37,14 @@ namespace kraken {
|
||||
|
||||
class Vector3;
|
||||
|
||||
class Vector4 {
|
||||
|
||||
class Vector4
|
||||
{
|
||||
|
||||
public:
|
||||
union {
|
||||
struct {
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
float x, y, z, w;
|
||||
};
|
||||
float c[4];
|
||||
@@ -50,47 +53,47 @@ public:
|
||||
void init();
|
||||
void init(float X, float Y, float Z, float W);
|
||||
void init(float v);
|
||||
void init(float *v);
|
||||
void init(const Vector4 &v);
|
||||
void init(const Vector3 &v, float W);
|
||||
void init(float* v);
|
||||
void init(const Vector4& v);
|
||||
void init(const Vector3& v, float W);
|
||||
static Vector4 Create();
|
||||
static Vector4 Create(float X, float Y, float Z, float W);
|
||||
static Vector4 Create(float v);
|
||||
static Vector4 Create(float *v);
|
||||
static Vector4 Create(const Vector4 &v);
|
||||
static Vector4 Create(const Vector3 &v, float W);
|
||||
|
||||
static Vector4 Create(float* v);
|
||||
static Vector4 Create(const Vector4& v);
|
||||
static Vector4 Create(const Vector3& v, float W);
|
||||
|
||||
Vector4 operator +(const Vector4& b) const;
|
||||
Vector4 operator -(const Vector4& b) const;
|
||||
Vector4 operator +() const;
|
||||
Vector4 operator -() const;
|
||||
Vector4 operator *(const float v) const;
|
||||
Vector4 operator /(const float v) const;
|
||||
|
||||
|
||||
Vector4& operator +=(const Vector4& b);
|
||||
Vector4& operator -=(const Vector4& b);
|
||||
Vector4& operator *=(const float v);
|
||||
Vector4& operator /=(const float v);
|
||||
|
||||
|
||||
bool operator ==(const Vector4& b) const;
|
||||
bool operator !=(const Vector4& b) const;
|
||||
|
||||
|
||||
// Comparison operators are implemented to allow insertion into sorted containers such as std::set
|
||||
bool operator >(const Vector4& b) const;
|
||||
bool operator <(const Vector4& b) const;
|
||||
|
||||
|
||||
float& operator[](unsigned i);
|
||||
float operator[](unsigned i) const;
|
||||
|
||||
|
||||
float sqrMagnitude() const; // calculate the square of the magnitude (useful for comparison of magnitudes without the cost of a sqrt() function)
|
||||
float magnitude() const;
|
||||
|
||||
|
||||
void normalize();
|
||||
static Vector4 Normalize(const Vector4 &v);
|
||||
|
||||
static float Dot(const Vector4 &v1, const Vector4 &v2);
|
||||
static Vector4 Min(const Vector4 &v1, const Vector4 &v2);
|
||||
static Vector4 Max(const Vector4 &v1, const Vector4 &v2);
|
||||
static Vector4 Normalize(const Vector4& v);
|
||||
|
||||
static float Dot(const Vector4& v1, const Vector4& v2);
|
||||
static Vector4 Min(const Vector4& v1, const Vector4& v2);
|
||||
static Vector4 Max(const Vector4& v1, const Vector4& v2);
|
||||
|
||||
static Vector4 Min();
|
||||
static Vector4 Max();
|
||||
@@ -102,25 +105,26 @@ public:
|
||||
static Vector4 Down();
|
||||
static Vector4 Left();
|
||||
static Vector4 Right();
|
||||
static Vector4 Lerp(const Vector4 &v1, const Vector4 &v2, float d);
|
||||
static Vector4 Slerp(const Vector4 &v1, const Vector4 &v2, float d);
|
||||
static void OrthoNormalize(Vector4 &normal, Vector4 &tangent); // Gram-Schmidt Orthonormalization
|
||||
static Vector4 Lerp(const Vector4& v1, const Vector4& v2, float d);
|
||||
static Vector4 Slerp(const Vector4& v1, const Vector4& v2, float d);
|
||||
static void OrthoNormalize(Vector4& normal, Vector4& tangent); // Gram-Schmidt Orthonormalization
|
||||
};
|
||||
static_assert(std::is_pod<Vector4>::value, "kraken::Vector4 must be a POD type.");
|
||||
|
||||
} // namespace kraken
|
||||
|
||||
namespace std {
|
||||
template<>
|
||||
struct hash<kraken::Vector4> {
|
||||
public:
|
||||
size_t operator()(const kraken::Vector4 &s) const
|
||||
{
|
||||
size_t h1 = hash<float>()(s.x);
|
||||
size_t h2 = hash<float>()(s.y);
|
||||
size_t h3 = hash<float>()(s.z);
|
||||
size_t h4 = hash<float>()(s.w);
|
||||
return h1 ^ (h2 << 1) ^ (h3 << 2) ^ (h4 << 3);
|
||||
}
|
||||
};
|
||||
template<>
|
||||
struct hash<kraken::Vector4>
|
||||
{
|
||||
public:
|
||||
size_t operator()(const kraken::Vector4& s) const
|
||||
{
|
||||
size_t h1 = hash<float>()(s.x);
|
||||
size_t h2 = hash<float>()(s.y);
|
||||
size_t h3 = hash<float>()(s.z);
|
||||
size_t h4 = hash<float>()(s.w);
|
||||
return h1 ^ (h2 << 1) ^ (h3 << 2) ^ (h4 << 3);
|
||||
}
|
||||
};
|
||||
} // namespace std
|
||||
|
||||
Reference in New Issue
Block a user