Updare gryphn_vec2.h
This commit is contained in:
@@ -1,44 +1,77 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <unordered_map>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
// very shitty vec2 class
|
|
||||||
|
|
||||||
#include "stdint.h"
|
#include "stdint.h"
|
||||||
|
|
||||||
template <typename T>
|
typedef struct gnVec2 {
|
||||||
struct gnType2 {
|
|
||||||
union {
|
union {
|
||||||
struct { T a, b; };
|
struct { float a, b; };
|
||||||
struct { T x, y; };
|
struct { float x, y; };
|
||||||
};
|
};
|
||||||
public:
|
|
||||||
gnType2(T a, T b) { this->a = a; this->b = b; }
|
|
||||||
gnType2() {};
|
|
||||||
|
|
||||||
gnType2 operator-(const gnType2& other) {
|
#ifdef GN_UTILS_CPP
|
||||||
gnType2 returnGnVec2;
|
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.x = this->x - other.x;
|
||||||
returnGnVec2.y = this->y - other.y;
|
returnGnVec2.y = this->y - other.y;
|
||||||
return returnGnVec2;
|
return returnGnVec2;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const gnType2& other) const {
|
bool operator==(const gnVec2& other) const {
|
||||||
return this->a == other.a && this->b == other.b;
|
return this->a == other.a && this->b == other.b;
|
||||||
}
|
}
|
||||||
};
|
#endif
|
||||||
|
} gnVec2;
|
||||||
|
|
||||||
|
typedef gnVec2 gnFVec2;
|
||||||
|
typedef gnVec2 gnFloat2;
|
||||||
|
|
||||||
typedef gnType2<float> gnVec2;
|
typedef struct gnUInt2 {
|
||||||
typedef gnType2<float> gnFloat2;
|
union {
|
||||||
typedef gnType2<uint32_t> gnUInt2;
|
struct { uint32_t a, b; };
|
||||||
typedef gnType2<int32_t> gnInt2;
|
struct { uint32_t x, y; };
|
||||||
|
|
||||||
namespace std {
|
|
||||||
template<>
|
|
||||||
struct hash<gnUInt2> {
|
|
||||||
std::size_t operator()(const gnUInt2& k) const {
|
|
||||||
return std::hash<uint32_t>()(k.x) ^ (std::hash<uint32_t>()(k.y) << 1);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
#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;
|
||||||
|
Reference in New Issue
Block a user