Compare commits

...

12 Commits

Author SHA1 Message Date
Gregory Wells
7d818db7f9 add extend 2d class 2025-09-17 13:50:39 -04:00
Gregory Wells
9833dc3c12 fix warning 2025-08-29 13:42:27 -04:00
Gregory Wells
f3646609c1 Create gryphn_cpp_function.h 2025-08-12 20:28:22 -04:00
Gregory Wells
ba67d0366d fix some errors on GCC 2025-08-12 19:58:50 -04:00
Gregory Wells
d7a13b16d1 Update gryphn_vec3.c 2025-08-03 18:46:31 -04:00
Gregory Wells
e3286f119d fix duplicate symbols bug 2025-08-03 18:39:32 -04:00
Gregory Wells
b5f0d16412 move around some utils stuff 2025-08-03 15:49:57 -04:00
Gregory Wells
c426f9ab6d more array list functions 2025-08-03 15:28:59 -04:00
Gregory Wells
203928aa81 some more array list functions 2025-08-03 15:07:51 -04:00
Gregory Wells
1b0465f6eb new array list header spec 2025-08-03 14:51:15 -04:00
Gregory Wells
a9aa97be63 move some stuff to C files 2025-08-03 14:39:56 -04:00
Gregory Wells
4b0875b01e update vec2 2025-08-03 14:32:56 -04:00
12 changed files with 257 additions and 263 deletions

5
CMakeLists.txt Normal file
View File

@@ -0,0 +1,5 @@
set(CMAKE_EXPORT_COMPILE_COMMANDS on)
project(GryphnUtils)
file(GLOB_RECURSE SOURCE_FILES CONFIGURE_DEPENDS "utils/*.c")
add_library(GryphnUtils STATIC ${SOURCE_FILES})

View File

@@ -0,0 +1,7 @@
#pragma once
#ifdef __cplusplus
#define GN_CPP_FUNCTION extern "C"
#else
#define GN_CPP_FUNCTION
#endif

View File

@@ -0,0 +1,12 @@
#include "gryphn_array_list.h"
#include <stdlib.h>
GN_ARRAY_LIST_DEFINITION(uint32_t)
GN_ARRAY_LIST_DEFINITION(int)
// note this is annoying but I dont wana warnings from this file
void tester() {
uint32_tArrayList list = uint32_tArrayListCreate();
uint32_tArrayListResize(list, 1);
void* m = malloc(0);
}

View File

@@ -1,30 +1,43 @@
#pragma once
#include "stdint.h"
#include "stdlib.h"
#define GN_ARRAY_LIST(type)\
typedef struct type##ArrayList { \
#define GN_ARRAY_LIST_HEADER(type)\
typedef struct type##ArrayList_t* type##ArrayList; \
type##ArrayList type##ArrayListCreate(void); \
void type##ArrayListReserve(type##ArrayList list, int count); \
void type##ArrayListExpand(type##ArrayList list, int count); \
void type##ArrayListAdd(type##ArrayList list, type data); \
void type##ArrayListResize(type##ArrayList list, int count); \
void type##ArrayListRemove(type##ArrayList list); \
void type##ArrayListPopHead(type##ArrayList list); \
uint32_t type##ArrayListCount(type##ArrayList list); \
type type##ArrayListAt(type##ArrayList list, int i); \
type* type##ArrayListRefAt(type##ArrayList list, int i); \
type* type##ArrayListData(type##ArrayList list)
#define GN_ARRAY_LIST_DEFINITION(type)\
typedef struct type##ArrayList_t { \
uint32_t count; \
uint32_t maxSize; \
type* data; \
} type##ArrayList; \
inline static type##ArrayList type##ArrayListCreate() { \
type##ArrayList list;\
list.maxSize = 1; \
list.count = 0;\
list.data = malloc(sizeof(type) * list.maxSize); \
} type##ArrayList_t; \
type##ArrayList type##ArrayListCreate(void) { \
type##ArrayList list = malloc(sizeof(type##ArrayList_t));\
list->maxSize = 1; \
list->count = 0;\
list->data = malloc(sizeof(type) * list->maxSize); \
return list; \
}\
inline static void type##ArrayListReserve(type##ArrayList* list, int count) { \
void type##ArrayListReserve(type##ArrayList list, int count) { \
int newCount = count - (list->maxSize - list->count);\
list->data = realloc(list->data, sizeof(type) * (newCount + list->maxSize)); \
list->maxSize += newCount; \
}\
inline static void type##ArrayListExpand(type##ArrayList* list, int count) { \
void type##ArrayListExpand(type##ArrayList list, int count) { \
list->data = realloc(list->data, sizeof(type) * (count + list->maxSize)); \
list->maxSize += count; \
}\
inline static void type##ArrayListAdd(type##ArrayList* list, type data) { \
void type##ArrayListAdd(type##ArrayList list, type data) { \
if (list->count >= list->maxSize) {\
list->maxSize *= 2; \
list->data = realloc(list->data, sizeof(type) * list->maxSize); \
@@ -32,27 +45,36 @@ if (list->count >= list->maxSize) {\
list->data[list->count] = data;\
list->count++;\
}\
inline static void type##ArrayListResize(type##ArrayList* list, int count) { \
void type##ArrayListResize(type##ArrayList list, int count) { \
int newCount = count - (list->maxSize - list->count);\
list->data = realloc(list->data, sizeof(type) * (newCount + list->maxSize)); \
list->maxSize += newCount; \
list->count += count; \
} \
inline static void type##ArrayListRemove(type##ArrayList* list) { \
void type##ArrayListRemove(type##ArrayList list) { \
if (list->count == 0) return; \
list->count--; \
} \
inline static void type##ArrayListPopHead(type##ArrayList* list) { \
void type##ArrayListPopHead(type##ArrayList list) { \
if (list->count == 0) return; \
list->count--; \
for (int i = 0; i < list->count; i++) { \
for (uint32_t i = 0; i < list->count; i++) { \
list->data[i] = list->data[i + 1];\
} \
} \
uint32_t type##ArrayListCount(type##ArrayList list) { \
return list->count; \
} \
type type##ArrayListAt(type##ArrayList list, int i) { \
return list->data[i]; \
} \
type* type##ArrayListRefAt(type##ArrayList list, int i) { \
return &list->data[i]; \
} \
type* type##ArrayListData(type##ArrayList list) { \
return &list->data[0]; \
}
//metalAvaliableTextureArrayListPopHead
GN_ARRAY_LIST(int);
GN_ARRAY_LIST(uint32_t);
GN_ARRAY_LIST_HEADER(uint32_t);
GN_ARRAY_LIST_HEADER(int);

122
utils/math/gryphn_mat4.c Normal file
View File

@@ -0,0 +1,122 @@
#include "gryphn_mat4.h"
#include "math.h"
gnMat4x4 gnIdentity(void) {
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 }
}
};
}
gnMat4x4 gnOrthographic(
float left, float right, float top, float bottom, float near, float far
) {
return (gnMat4x4){
.mat = {
{ (2)/(right-left), 0.0f, 0.0f, -((right+left)/(right-left)) },
{ 0.0f, 2/(top-bottom), 0.0f, -((top+bottom)/(top-bottom)) },
{ 0.0f, 0.0f, -2/(far-near), -((far+near)/(far-near)) },
{ 0.0f, 0.0f, 0.0f, 1.0f }
}
};
}
gnMat4x4 gnProjection(
float fov, float aspect, float near, float far
) {
float f = 1.0f / tan(fov * 0.5f);
return (gnMat4x4){
.mat = {
{ f / aspect, 0.0f, 0.0f, 0.0f },
{ 0.0f , f , 0.0f, 0.0f },
{ 0.0f , 0.0f, (far + near) / (near - far), -1.0f },
{ 0.0f , 0.0f, (2 * far * near) / (near - far), 0.0f }
}
};
}
gnMat4x4 gnTranslate(gnVec3 translation) {
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 },
{ translation.x, translation.y, translation.z, 1.0f }
}
};
}
// this function was heavily adapted from GLMs implementation
gnMat4x4 gnRotate(gnVec3 axis, float rotation) {
float c = cos(rotation), s = sin(rotation);
axis = gnVec3Normalize(axis);
gnVec3 temp = {
.x = ((1.0f - c) * axis.x),
.y = ((1.0f - c) * axis.y),
.z = ((1.0f - c) * axis.z)
};
gnMat4 rotate = {
.mat = {
{ c + temp.x * axis.x, temp.x * axis.y + s * axis.z, temp.x * axis.z - s * axis.y, 0.0f },
{ temp.y * axis.x - s * axis.z, c + temp.y * axis.y, temp.y * axis.z + s * axis.x, 0.0f },
{ temp.z * axis.x + s * axis.y, temp.z * axis.y - s * axis.x, c + temp.z * axis.z, 0.0f },
{ 0.0f, 0.0f, 0.0f, 1.0f },
}
};
return rotate;
}
gnMat4x4 gnScale(gnVec3 amount) {
gnMat4 rotate = {
.mat = {
{ amount.x, 0.0f, 0.0f, 0.0f },
{ 0.0f, amount.y, 0.0f, 0.0f },
{ 0.0f, 0.0f, amount.z, 0.0f },
{ 0.0f, 0.0f, 0.0f, 1.0f }
}
};
return rotate;
}
// used GLMs lookAtLH from /glm/ext/matrix_transform.inl as a base
gnMat4x4 gnLookAt(gnVec3 eye, gnVec3 center, gnVec3 up) {
const gnVec3 f = gnVec3Normalize(gnVec3Subtract(center, eye));
const gnVec3 s = gnVec3Normalize(gnVec3Cross(f, up));
const gnVec3 u = gnVec3Cross(s, f);
return (gnMat4x4) {
.mat = {
{ s.x, u.x, -f.x, 0.0f },
{ s.y, u.y, -f.y, 0.0f },
{ s.z, u.z, -f.z, 0.0f },
{ -gnVec3Dot(s, eye), -gnVec3Dot(u, eye), gnVec3Dot(f, eye), 1.0f }
}
};
}
gnMat4x4 gnMultiply(gnMat4 a, gnMat4 b) {
gnMat4 result;
for (int row = 0; row < 4; ++row)
for (int col = 0; col < 4; ++col)
result.mat[row][col] = a.mat[row][0] * b.mat[0][col] +
a.mat[row][1] * b.mat[1][col] +
a.mat[row][2] * b.mat[2][col] +
a.mat[row][3] * b.mat[3][col];
return result;
}
gnVec3 gnMat4MultiplyVec3(gnMat4 m, gnVec3 v) {
gnVec3 result;
result.x = m.mat[0][0] * v.x + m.mat[1][0] * v.y + m.mat[2][0] * v.z + m.mat[3][0];
result.y = m.mat[0][1] * v.x + m.mat[1][1] * v.y + m.mat[2][1] * v.z + m.mat[3][1];
result.z = m.mat[0][2] * v.x + m.mat[1][2] * v.y + m.mat[2][2] * v.z + m.mat[3][2];
return result;
}

View File

@@ -1,5 +1,4 @@
#pragma once
#include "math.h"
#include "gryphn_vec3.h"
typedef struct gnMat4x4 {
@@ -7,123 +6,12 @@ typedef struct gnMat4x4 {
} gnMat4x4;
typedef gnMat4x4 gnMat4;
static inline const 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 }
}
};
}
static inline const gnMat4x4 gnOrthographic(
float left, float right, float top, float bottom, float near, float far
) {
return (gnMat4x4){
.mat = {
{ (2)/(right-left), 0.0f, 0.0f, -((right+left)/(right-left)) },
{ 0.0f, 2/(top-bottom), 0.0f, -((top+bottom)/(top-bottom)) },
{ 0.0f, 0.0f, -2/(far-near), -((far+near)/(far-near)) },
{ 0.0f, 0.0f, 0.0f, 1.0f }
}
};
}
static inline const gnMat4x4 gnProjection(
float fov, float aspect, float near, float far
) {
float f = 1.0f / tan(fov * 0.5f);
return (gnMat4x4){
.mat = {
{ f / aspect, 0.0f, 0.0f, 0.0f },
{ 0.0f , f , 0.0f, 0.0f },
{ 0.0f , 0.0f, (far + near) / (near - far), -1.0f },
{ 0.0f , 0.0f, (2 * far * near) / (near - far), 0.0f }
}
};
}
static inline const gnMat4x4 gnTranslate(gnVec3 translation) {
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 },
{ translation.x, translation.y, translation.z, 1.0f }
}
};
}
static inline const gnMat4x4 gnRotate(gnVec3 axis, float rotation) {
float c = cos(rotation), s = sin(rotation);
axis = gnVec3Normalize(axis);
gnVec3 temp = {
((1.0f - c) * axis.x),
((1.0f - c) * axis.y),
((1.0f - c) * axis.z)
};
gnMat4 rotate = {
.mat = {
{ c + temp.x * axis.x, temp.x * axis.y + s * axis.z, temp.x * axis.z - s * axis.y, 0.0f },
{ temp.y * axis.x - s * axis.z, c + temp.y * axis.y, temp.y * axis.z + s * axis.x, 0.0f },
{ temp.z * axis.x + s * axis.y, temp.z * axis.y - s * axis.x, c + temp.z * axis.z, 0.0f },
{ 0.0f, 0.0f, 0.0f, 1.0f },
}
};
return rotate;
}
static inline const gnMat4x4 gnScale(gnVec3 amount) {
gnMat4 rotate = {
.mat = {
{ amount.x, 0.0f, 0.0f, 0.0f },
{ 0.0f, amount.y, 0.0f, 0.0f },
{ 0.0f, 0.0f, amount.z, 0.0f },
{ 0.0f, 0.0f, 0.0f, 1.0f }
}
};
return rotate;
}
// used GLMs lookAtLH from /glm/ext/matrix_transform.inl as a base
static inline const gnMat4x4 gnLookAt(gnVec3 eye, gnVec3 center, gnVec3 up) {
const gnVec3 f = gnVec3Normalize(gnVec3Subtract(center, eye));
const gnVec3 s = gnVec3Normalize(gnVec3Cross(f, up));
const gnVec3 u = gnVec3Cross(s, f);
return (gnMat4x4) {
.mat = {
{ s.x, u.x, -f.x, 0.0f },
{ s.y, u.y, -f.y, 0.0f },
{ s.z, u.z, -f.z, 0.0f },
{ -gnVec3Dot(s, eye), -gnVec3Dot(u, eye), gnVec3Dot(f, eye), 1.0f }
}
};
}
static inline const gnMat4x4 gnMultiply(gnMat4 a, gnMat4 b) {
gnMat4 result;
for (int row = 0; row < 4; ++row)
for (int col = 0; col < 4; ++col)
result.mat[row][col] = a.mat[row][0] * b.mat[0][col] +
a.mat[row][1] * b.mat[1][col] +
a.mat[row][2] * b.mat[2][col] +
a.mat[row][3] * b.mat[3][col];
return result;
}
static inline const gnVec3 gnMat4MultiplyVec3(gnMat4 m, gnVec3 v) {
gnVec3 result;
result.x = m.mat[0][0] * v.x + m.mat[1][0] * v.y + m.mat[2][0] * v.z + m.mat[3][0];
result.y = m.mat[0][1] * v.x + m.mat[1][1] * v.y + m.mat[2][1] * v.z + m.mat[3][1];
result.z = m.mat[0][2] * v.x + m.mat[1][2] * v.y + m.mat[2][2] * v.z + m.mat[3][2];
return result;
}
gnMat4x4 gnIdentity(void);
gnMat4x4 gnOrthographic(float left, float right, float top, float bottom, float near, float far);
gnMat4x4 gnProjection(float fov, float aspect, float near, float far);
gnMat4x4 gnTranslate(gnVec3 translation);
gnMat4x4 gnRotate(gnVec3 axis, float rotation);
gnMat4x4 gnScale(gnVec3 amount);
gnMat4x4 gnLookAt(gnVec3 eye, gnVec3 center, gnVec3 up);
gnMat4x4 gnMultiply(gnMat4 a, gnMat4 b);
gnVec3 gnMat4MultiplyVec3(gnMat4 m, gnVec3 v);

4
utils/math/gryphn_math.c Normal file
View File

@@ -0,0 +1,4 @@
#include "gryphn_math.h"
float gnRadians(const float degrees) { return degrees * (3.14159265358979323846f / 180.0f); }
float gnRoot(const float input, const float n) { return pow(input, 1./n); }

View File

@@ -1,5 +1,5 @@
#pragma once
#include <math.h>
static const inline float gnRadians(const float degrees) { return degrees * (3.14159265358979323846f / 180.0f); }
static const inline float gnRoot(const float input, const float n) { return pow(input, 1./n); }
float gnRadians(const float degrees);
float gnRoot(const float input, const float n);

8
utils/math/gryphn_vec2.c Normal file
View File

@@ -0,0 +1,8 @@
#include "gryphn_vec2.h"
gnVec2 gnVec2Subtract(gnVec2 a, gnVec2 b) {
gnVec2 ret;
ret.x = a.x - b.x;
ret.y = a.y - b.y;
return ret;
}

View File

@@ -6,74 +6,22 @@ typedef struct gnVec2 {
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;
static inline const gnVec2 gnVec2Subtract(gnVec2 a, gnVec2 b) { return (gnVec2){ a.x - b.x, a.y - b.y }; }
typedef gnVec2 gnFVec2;
typedef gnVec2 gnFloat2;
gnVec2 gnVec2Subtract(gnVec2 a, gnVec2 b);
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 gnUInt2 gnExtent2D;
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;

36
utils/math/gryphn_vec3.c Normal file
View File

@@ -0,0 +1,36 @@
#include "gryphn_vec3.h"
#include "math.h"
gnVec3 gnVec3Subtract(gnVec3 a, gnVec3 b) { return (gnVec3){
.x = a.x - b.x,
.y = a.y - b.y,
.z = a.z - b.z };
}
gnVec3 gnVec3Add(gnVec3 a, gnVec3 b) { return (gnVec3){
.x = a.x + b.x,
.y = a.y + b.y,
.z = a.z + b.z };
}
gnVec3 gnVec3Normalize(gnVec3 in) {
float lengthOfVector = sqrt((in.x * in.x) + (in.y * in.y) + (in.z * in.z));
return (gnVec3){
.a = in.x / lengthOfVector,
.b = in.y / lengthOfVector,
.c = in.z / lengthOfVector};
}
gnVec3 gnVec3Cross(gnVec3 a, gnVec3 b) { return (gnVec3){
.x = a.y * b.z - a.z * b.y,
.y = a.z * b.x - a.x * b.z,
.z = a.x * b.y - a.y * b.x};
}
float gnVec3Dot(gnVec3 a, gnVec3 b) { return a.x * b.x + a.y * b.y + a.z * b.z; }
gnVec3 gnVec3Multiply(gnVec3 a, gnVec3 b) { return (gnVec3){
.x = a.x * b.x,
.y = a.y * b.y,
.z = a.z * b.z };
}
gnVec3 gnVec3MultiplyBy(gnVec3 a, float b) { return (gnVec3){
.x = a.x * b,
.y= a.y * b,
.z = a.z * b };
}

View File

@@ -1,42 +1,20 @@
#pragma once
#include "stdint.h"
#include "math.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;
static const inline gnVec3 gnVec3Subtract(gnVec3 a, gnVec3 b) { return (gnVec3){ a.x - b.x, a.y - b.y, a.z - b.z }; }
static const inline gnVec3 gnVec3Add(gnVec3 a, gnVec3 b) { return (gnVec3){ a.x + b.x, a.y + b.y, a.z + b.z }; }
static const inline gnVec3 gnVec3Normalize(gnVec3 in) {
float lengthOfVector = sqrt((in.x * in.x) + (in.y * in.y) + (in.z * in.z));
return (gnVec3){in.x / lengthOfVector, in.y / lengthOfVector, in.z / lengthOfVector};
}
static const inline gnVec3 gnVec3Cross(gnVec3 a, gnVec3 b) { return (gnVec3){a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x}; }
static const inline float gnVec3Dot(gnVec3 a, gnVec3 b) { return a.x * b.x + a.y * b.y + a.z * b.z; }
static const inline gnVec3 gnVec3Multiply(gnVec3 a, gnVec3 b) { return (gnVec3){ a.x * b.x, a.y * b.y, a.z * b.z }; }
static const inline gnVec3 gnVec3MultiplyBy(gnVec3 a, float b) { return (gnVec3){ a.x * b, a.y * b, a.z * b }; }
gnVec3 gnVec3Subtract(gnVec3 a, gnVec3 b);
gnVec3 gnVec3Add(gnVec3 a, gnVec3 b);
gnVec3 gnVec3Normalize(gnVec3 in);
gnVec3 gnVec3Cross(gnVec3 a, gnVec3 b);
float gnVec3Dot(gnVec3 a, gnVec3 b);
gnVec3 gnVec3Multiply(gnVec3 a, gnVec3 b);
gnVec3 gnVec3MultiplyBy(gnVec3 a, float b);
typedef gnVec3 gnFVec3;
typedef gnVec3 gnFloat3;
@@ -47,24 +25,6 @@ typedef struct gnUInt3 {
struct { uint32_t x, y, z; };
struct { uint32_t width, height, depth; };
};
#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 gnUInt3 gnUVec3;
@@ -75,22 +35,4 @@ typedef struct gnInt3 {
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;