Simulant  21.12-194
A portable game engine for Windows, OSX, Linux, Dreamcast, and PSP
packed_types.h
1 #pragma once
2 
3 #include "half.hpp"
4 #include "../math/vec3.h"
5 #include "../math/vec2.h"
6 
7 namespace smlt {
8 
9 using half = half_float::half;
10 
11 struct HalfVec3 {
12  half x, y, z;
13 
14  HalfVec3() = default;
15  HalfVec3(float x, float y, float z):
16  x(x), y(y), z(z) {}
17 
18  HalfVec3 operator+(const HalfVec3& rhs) const {
19  return HalfVec3{x + rhs.x, y + rhs.y, z + rhs.z};
20  }
21 
22  operator Vec3() const {
23  return Vec3(x, y, z);
24  }
25 };
26 
27 
28 struct HalfVec2 {
29  half x, y;
30 
31  HalfVec2() = default;
32  HalfVec2(float x, float y):
33  x(x), y(y) {}
34 
35  HalfVec2 operator+(const HalfVec3& rhs) const {
36  return HalfVec2{x + rhs.x, y + rhs.y};
37  }
38 
39  operator Vec2() const {
40  return Vec2(x, y);
41  }
42 };
43 
44 }
half.hpp
smlt::Vec3
Definition: vec3.h:23
half_float::half
Definition: half.hpp:923
smlt::HalfVec2
Definition: packed_types.h:28
smlt
Definition: animation.cpp:25
smlt::HalfVec3
Definition: packed_types.h:11
smlt::Vec2
Definition: vec2.h:13