Skip to content

Commit

Permalink
Merge pull request #350 from REGoth-project/mathlib-improvements
Browse files Browse the repository at this point in the history
Mathlib improvements
  • Loading branch information
ataulien authored Jun 23, 2018
2 parents 36b122c + 6e0a23e commit 250e2c1
Showing 1 changed file with 39 additions and 2 deletions.
41 changes: 39 additions & 2 deletions src/math/mathlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/quaternion.hpp>
#include <glm/gtx/norm.hpp>
#include <ZenLib/utils/mathlib.h>

namespace Math
{
Expand Down Expand Up @@ -105,6 +106,16 @@ namespace Math
this->x = x;
this->y = y;
}
t_float2(const ZMath::float2& v)
{
this->x = v.x;
this->y = v.y;
}
t_float2(float v)
{
this->x = v;
this->y = v;
}

union {
struct
Expand Down Expand Up @@ -139,6 +150,18 @@ namespace Math
this->y = y;
this->z = z;
}
t_float3(const ZMath::float3& v)
{
this->x = v.x;
this->y = v.y;
this->z = v.z;
}
t_float3(float v)
{
this->x = v;
this->y = v;
this->z = v;
}

union {
struct
Expand Down Expand Up @@ -175,6 +198,20 @@ namespace Math
this->z = z;
this->w = w;
}
t_float4(const ZMath::float4& v)
{
this->x = v.x;
this->y = v.y;
this->z = v.z;
this->w = v.w;
}
t_float4(float v)
{
this->x = v;
this->y = v;
this->z = v;
this->w = w;
}

union {
struct
Expand Down Expand Up @@ -289,7 +326,7 @@ namespace Math
t_vector() {}
t_vector(const void* v)
{
memcpy(this, v, sizeof(T));
memcpy(T::v, v, sizeof(T));
}

t_vector(const T& v)
Expand Down Expand Up @@ -470,7 +507,7 @@ namespace Math
// Assignment operators
Matrix& operator=(const Matrix& M)
{
memcpy(this, &M, sizeof(float) * 16);
memcpy(m, &M, sizeof(mv));
return *this;
}
Matrix& operator+=(const Matrix& M)
Expand Down

0 comments on commit 250e2c1

Please sign in to comment.