Blackcomb  prealpha
Engine-ish
Coords.h
1 #ifndef BLACKCOMB_COORDS_H
2 #define BLACKCOMB_COORDS_H
3 
4 #include <functional>
5 
6 namespace blackcomb::misc {
7  struct Point2i;
8  struct Point3i;
9 
13  struct UVCoord {
14  bool operator==(const UVCoord& other) const;
15  float u;
16  float v;
17  };
18 
22  struct UVRect {
23  bool operator==(const UVRect& other) const;
26  };
27 
32  struct Point2f {
33  bool operator==(const Point2f& other) const;
34  bool operator==(const Point2i& other) const;
35  float x;
36  float y;
37  };
38 
43  struct Point2i {
44  bool operator==(const Point2f& other) const;
45  bool operator==(const Point2i& other) const;
46  int x;
47  int y;
48  };
49 
54  struct Point3f {
55  bool operator==(const Point3f& other) const;
56  bool operator==(const Point3i& other) const;
57  float x;
58  float y;
59  float z;
60  };
61 
66  struct Point3i {
67  bool operator==(const Point3f& other) const;
68  bool operator==(const Point3i& other) const;
69  int x;
70  int y;
71  int z;
72  };
73 
77  struct Color {
78  bool operator==(const Color& other) const;
79  int r;
80  int g;
81  int b;
82  int a = 255;
83  };
84 }
85 
86 namespace std {
90  template <>
91  struct hash<blackcomb::misc::Point3f> {
92  std::size_t operator()(const blackcomb::misc::Point3f& k) const {
93  return ((hash<float>()(k.x) ^ (hash<float>()(k.y) << 1)) >> 1) ^ (hash<float>()(k.z) << 1);
94  }
95  };
96 
100  template <>
101  struct hash<blackcomb::misc::Point3i> {
102  std::size_t operator()(const blackcomb::misc::Point3i& k) const {
103  return ((hash<int>()(k.x) ^ (hash<int>()(k.y) << 1)) >> 1) ^ (hash<int>()(k.z) << 1);
104  }
105  };
106 }
107 
108 #endif //BLACKCOMB_COORDS_H
Represents a colour in the RGBA colour space.
Definition: Coords.h:77
Represents a rectangle in UV space.
Definition: Coords.h:22
STL namespace.
Represents a 2D point with integers.
Definition: Coords.h:43
Represents a 3D point with floats.
Definition: Coords.h:54
UVCoord botLeft
Bottom left corner of the UV rectangle.
Definition: Coords.h:24
Definition: BlackcombException.h:6
Represents a set of UV coordinates.
Definition: Coords.h:13
UVCoord topRight
Top right corner of the UV rectangle.
Definition: Coords.h:25
Represents a 3D point with integers.
Definition: Coords.h:66
Represents a 2D point with floats.
Definition: Coords.h:32