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