-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvec.hpp
More file actions
83 lines (62 loc) · 1.5 KB
/
Copy pathvec.hpp
File metadata and controls
83 lines (62 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#ifndef VEC_HPP
#define VEC_HPP
#include "imgui/dearimgui.hpp"
struct Vec2 {
int x = 0, y = 0;
};
struct Vec3 {
float x = 0.0, y = 0.0, z = 0.0;
Vec3 operator+(const Vec3 v) {
return Vec3{x + v.x, y + v.y, z + v.z};
}
Vec3 operator*(const Vec3 v) {
return Vec3{x * v.x, y * v.y, z * v.z};
}
Vec3 operator*(float v) {
return Vec3{x * v, y * v, z * v};
}
Vec3 operator*(int v) {
return Vec3{x * v, y * v, z * v};
}
Vec3& operator-=(const Vec3 v) {
x -= v.x; y -= v.y; z -= v.z; return *this;
}
Vec3& operator+=(const Vec3 v) {
x += v.x; y += v.y; z += v.z; return *this;
}
Vec3& operator+=(float v) {
x += v; y += v; z += v; return *this;
}
Vec3 operator-(const Vec3 v) {
return Vec3{x - v.x, y - v.y, z - v.z};
}
bool operator!=(const Vec3 v) {
return (this->x != v.x || this->y != v.y || this->z != v.z);
}
/*
void operator=(const Vec3 v) {
this->x = v.x; this->y = v.y; this->z = v.z;
}
*/
};
struct __attribute__((aligned(16))) Vec3_aligned {
float x = 0.0, y = 0.0, z = 0.0;
};
struct RGBA {
int r = 255, g = 255, b = 255, a = 255;
};
struct RGBA_float {
float r = 1.0, g = 1.0, b = 1.0, a = 1.0;
RGBA to_RGBA() {
return RGBA{.r = int(r * 255), .g = int(g * 255), .b = int(b * 255), .a = int(a * 255)};
}
ImU32 to_ImU32() {
RGBA rgba = this->to_RGBA();
return IM_COL32(rgba.r, rgba.g, rgba.b, rgba.a);
}
float* to_arr() {
return (float*)this;
}
};
typedef float VMatrix[4][4];
#endif