rename src to utils
This commit is contained in:
17
utils/math/gryphn_mat4.h
Normal file
17
utils/math/gryphn_mat4.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
typedef struct gnMat4x4 {
|
||||
float mat[4][4];
|
||||
} gnMat4x4;
|
||||
typedef gnMat4x4 gnMat4;
|
||||
|
||||
gnMat4x4 gnIdentity() {
|
||||
return (gnMat4x4){
|
||||
.mat = {
|
||||
{ 1.0f, 0.0f, 0.0f, 0.0f },
|
||||
{ 0.0f, 1.0f, 0.0f, 0.0f },
|
||||
{ 0.0f, 0.0f, 1.0f, 0.0f },
|
||||
{ 0.0f, 0.0f, 0.0f, 1.0f }
|
||||
}
|
||||
};
|
||||
}
|
77
utils/math/gryphn_vec2.h
Normal file
77
utils/math/gryphn_vec2.h
Normal file
@@ -0,0 +1,77 @@
|
||||
#pragma once
|
||||
#include "stdint.h"
|
||||
|
||||
typedef struct gnVec2 {
|
||||
union {
|
||||
struct { float a, b; };
|
||||
struct { float x, y; };
|
||||
};
|
||||
|
||||
#ifdef GN_UTILS_CPP
|
||||
gnVec2(float x, float y) { this->x = x; this->y = y; }
|
||||
gnVec2(float s) { this->x = s; this->y = s; }
|
||||
gnVec2() {};
|
||||
|
||||
gnVec2 operator-(const gnVec2& other) {
|
||||
gnVec2 returnGnVec2;
|
||||
returnGnVec2.x = this->x - other.x;
|
||||
returnGnVec2.y = this->y - other.y;
|
||||
return returnGnVec2;
|
||||
}
|
||||
|
||||
bool operator==(const gnVec2& other) const {
|
||||
return this->a == other.a && this->b == other.b;
|
||||
}
|
||||
#endif
|
||||
} gnVec2;
|
||||
|
||||
typedef gnVec2 gnFVec2;
|
||||
typedef gnVec2 gnFloat2;
|
||||
|
||||
typedef struct gnUInt2 {
|
||||
union {
|
||||
struct { uint32_t a, b; };
|
||||
struct { uint32_t x, y; };
|
||||
};
|
||||
|
||||
#ifdef GN_UTILS_CPP
|
||||
gnUInt2(uint32_t x, uint32_t y) { this->x = x; this->y = y; }
|
||||
gnUInt2(uint32_t s) { this->x = s; this->y = s; }
|
||||
gnUInt2() {};
|
||||
|
||||
gnUInt2 operator-(const gnUInt2& other) {
|
||||
gnUInt2 returnGnVec2;
|
||||
returnGnVec2.x = this->x - other.x;
|
||||
returnGnVec2.y = this->y - other.y;
|
||||
return returnGnVec2;
|
||||
}
|
||||
|
||||
bool operator==(const gnUInt2& other) const {
|
||||
return this->a == other.a && this->b == other.b;
|
||||
}
|
||||
#endif
|
||||
} gnUInt2;
|
||||
|
||||
typedef struct gnInt2 {
|
||||
union {
|
||||
struct { int a, b; };
|
||||
struct { int x, y; };
|
||||
};
|
||||
|
||||
#ifdef GN_UTILS_CPP
|
||||
gnInt2(int x, int y) { this->x = x; this->y = y; }
|
||||
gnInt2(int s) { this->x = s; this->y = s; }
|
||||
gnInt2() {};
|
||||
|
||||
gnInt2 operator-(const gnInt2& other) {
|
||||
gnInt2 returnGnVec2;
|
||||
returnGnVec2.x = this->x - other.x;
|
||||
returnGnVec2.y = this->y - other.y;
|
||||
return returnGnVec2;
|
||||
}
|
||||
|
||||
bool operator==(const gnInt2& other) const {
|
||||
return this->a == other.a && this->b == other.b;
|
||||
}
|
||||
#endif
|
||||
} gnInt2;
|
80
utils/math/gryphn_vec3.h
Normal file
80
utils/math/gryphn_vec3.h
Normal file
@@ -0,0 +1,80 @@
|
||||
#pragma once
|
||||
#include "stdint.h"
|
||||
|
||||
typedef struct gnVec3 {
|
||||
union {
|
||||
struct { float a, b, c; };
|
||||
struct { float x, y, z; };
|
||||
};
|
||||
|
||||
#ifdef GN_UTILS_CPP
|
||||
gnVec3(float x, float y, float z) { this->x = x; this->y = y; this->z = z; }
|
||||
gnVec3(float s) { this->x = s; this->y = s; this->z = s; }
|
||||
gnVec3() {};
|
||||
|
||||
gnVec3 operator-(const gnVec3& other) {
|
||||
gnVec3 returnGnVec3;
|
||||
returnGnVec3.x = this->x - other.x;
|
||||
returnGnVec3.y = this->y - other.y;
|
||||
returnGnVec3.z = this->z - other.z;
|
||||
return returnGnVec3;
|
||||
}
|
||||
|
||||
bool operator==(const gnVec3& other) const {
|
||||
return this->a == other.a && this->b == other.b && this->c == other.c;
|
||||
}
|
||||
#endif
|
||||
} gnVec3;
|
||||
|
||||
typedef gnVec3 gnFVec3;
|
||||
typedef gnVec3 gnFloat3;
|
||||
|
||||
typedef struct gnUInt3 {
|
||||
union {
|
||||
struct { uint32_t a, b, c; };
|
||||
struct { uint32_t x, y, z; };
|
||||
};
|
||||
|
||||
#ifdef GN_UTILS_CPP
|
||||
gnUInt3(uint32_t x, uint32_t y, uint32_t z) { this->x = x; this->y = y; this->z = z; }
|
||||
gnUInt3(uint32_t s) { this->x = s; this->y = s; this->z = s; }
|
||||
gnUInt3() {};
|
||||
|
||||
gnUInt3 operator-(const gnUInt3& other) {
|
||||
gnUInt3 returnGnVec3;
|
||||
returnGnVec3.x = this->x - other.x;
|
||||
returnGnVec3.y = this->y - other.y;
|
||||
returnGnVec3.z = this->z - other.z;
|
||||
return returnGnVec3;
|
||||
}
|
||||
|
||||
bool operator==(const gnUInt3& other) const {
|
||||
return this->a == other.a && this->b == other.b && this->c == other.c;
|
||||
}
|
||||
#endif
|
||||
} gnUInt3;
|
||||
|
||||
typedef struct gnInt3 {
|
||||
union {
|
||||
struct { int a, b, c; };
|
||||
struct { int x, y, z; };
|
||||
};
|
||||
|
||||
#ifdef GN_UTILS_CPP
|
||||
gnInt3(int x, int y, int z) { this->x = x; this->y = y; this->z = z; }
|
||||
gnInt3(int s) { this->x = s; this->y = s; this->z = s; }
|
||||
gnInt3() {};
|
||||
|
||||
gnInt3 operator-(const gnInt3& other) {
|
||||
gnInt3 returnGnVec3;
|
||||
returnGnVec3.x = this->x - other.x;
|
||||
returnGnVec3.y = this->y - other.y;
|
||||
returnGnVec3.z = this->z - other.z;
|
||||
return returnGnVec3;
|
||||
}
|
||||
|
||||
bool operator==(const gnInt3& other) const {
|
||||
return this->a == other.a && this->b == other.b && this->c == other.c;
|
||||
}
|
||||
#endif
|
||||
} gnInt3;
|
83
utils/math/gryphn_vec4.h
Normal file
83
utils/math/gryphn_vec4.h
Normal file
@@ -0,0 +1,83 @@
|
||||
#pragma once
|
||||
#include "stdint.h"
|
||||
|
||||
typedef struct gnVec4 {
|
||||
union {
|
||||
struct { float a, b, c, d; };
|
||||
struct { float x, y, z, w; };
|
||||
};
|
||||
|
||||
#ifdef GN_UTILS_CPP
|
||||
gnVec4(float x, float y, float z, float w) { this->x = x; this->y = y; this->z = z; this->w = w; }
|
||||
gnVec4(float s) { this->x = s; this->y = s; this->z = s; this->w = w; }
|
||||
gnVec4() {};
|
||||
|
||||
gnVec4 operator-(const gnVec4& other) {
|
||||
gnVec4 returnGnVec4;
|
||||
returnGnVec4.x = this->x - other.x;
|
||||
returnGnVec4.y = this->y - other.y;
|
||||
returnGnVec4.z = this->z - other.z;
|
||||
returnGnVec4.w = this->w - other.w;
|
||||
return returnGnVec4;
|
||||
}
|
||||
|
||||
bool operator==(const gnVec4& other) const {
|
||||
return this->a == other.a && this->b == other.b && this->c == other.c && this->d == other.d;
|
||||
}
|
||||
#endif
|
||||
} gnVec4;
|
||||
|
||||
typedef gnVec4 gnFVec4;
|
||||
typedef gnVec4 gnFloat4;
|
||||
|
||||
typedef struct gnUInt4 {
|
||||
union {
|
||||
struct { uint32_t a, b, c, d; };
|
||||
struct { uint32_t x, y, z, w; };
|
||||
};
|
||||
|
||||
#ifdef GN_UTILS_CPP
|
||||
gnUInt4(uint32_t x, uint32_t y, uint32_t z, uint32_t w) { this->x = x; this->y = y; this->z = z; this->w = w; }
|
||||
gnUInt4(uint32_t s) { this->x = s; this->y = s; this->z = s; this->w = s; }
|
||||
gnUInt4() {};
|
||||
|
||||
gnUInt4 operator-(const gnUInt4& other) {
|
||||
gnUInt4 returnGnVec4;
|
||||
returnGnVec4.x = this->x - other.x;
|
||||
returnGnVec4.y = this->y - other.y;
|
||||
returnGnVec4.z = this->z - other.z;
|
||||
returnGnVec4.w = this->w - other.w;
|
||||
return returnGnVec4;
|
||||
}
|
||||
|
||||
bool operator==(const gnUInt4& other) const {
|
||||
return this->a == other.a && this->b == other.b && this->c == other.c && this->d == other.d;
|
||||
}
|
||||
#endif
|
||||
} gnUInt4;
|
||||
|
||||
typedef struct gnInt4 {
|
||||
union {
|
||||
struct { int a, b, c, d; };
|
||||
struct { int x, y, z, w; };
|
||||
};
|
||||
|
||||
#ifdef GN_UTILS_CPP
|
||||
gnInt4(int x, int y, int z, int w) { this->x = x; this->y = y; this->z = z; this->w = w; }
|
||||
gnInt4(int s) { this->x = s; this->y = s; this->z = s; this->w = s; }
|
||||
gnInt4() {};
|
||||
|
||||
gnInt4 operator-(const gnInt4& other) {
|
||||
gnInt4 returnGnVec4;
|
||||
returnGnVec4.x = this->x - other.x;
|
||||
returnGnVec4.y = this->y - other.y;
|
||||
returnGnVec4.z = this->z - other.z;
|
||||
returnGnVec4.w = this->w - other.w;
|
||||
return returnGnVec4;
|
||||
}
|
||||
|
||||
bool operator==(const gnInt4& other) const {
|
||||
return this->a == other.a && this->b == other.b && this->c == other.c;
|
||||
}
|
||||
#endif
|
||||
} gnInt4;
|
Reference in New Issue
Block a user