Utilities
Utilities header only library
Serializables.h
1 /*
2  Copyright (C) Skeletex Research, s.r.o. - All Rights Reserved
3  Unauthorized copying of this file, via any medium is strictly prohibited
4  Proprietary and confidential
5 */
6 #ifndef UTILS_SERIALIZABLES_H
7 #define UTILS_SERIALIZABLES_H
8 
9 #include <cereal/cereal.hpp>
10 
11 #include <glm/vec3.hpp>
12 #include <glm/gtc/quaternion.hpp>
13 
14 
15 
16 namespace utils
17 {
18 
21  {
22  friend class cereal::access;
23 
24  public:
25  float x, y, z;
26 
27  GlmVec3Serializable() : GlmVec3Serializable(glm::vec3()) {}
28  explicit GlmVec3Serializable(const glm::vec3 &v) : x(v.x), y(v.y), z(v.z) {}
29 
30  glm::vec3 ToVec3() const { return glm::vec3(x, y, z); }
31 
32  private:
33  template <class Archive>
34  void serialize(Archive &ar)
35  {
36  ar(CEREAL_NVP(x), CEREAL_NVP(y), CEREAL_NVP(z));
37  }
38  };
39 
40 
41 
44  {
45  friend class cereal::access;
46 
47  public:
48  float x, y, z, w;
49 
50  GlmQuatSerializable() : GlmQuatSerializable(glm::quat()) {}
51  explicit GlmQuatSerializable(const glm::quat &q) : x(q.x), y(q.y), z(q.z), w(q.w) {}
52 
53  glm::quat ToQuat() const { return glm::quat(w, x, y, z); }
54 
55  private:
56  template <class Archive>
57  void serialize(Archive &ar)
58  {
59  ar(CEREAL_NVP(x), CEREAL_NVP(y), CEREAL_NVP(z), CEREAL_NVP(w));
60  }
61  };
62 
63 }
64 #endif /* !UTILS_SERIALIZABLES_H */
Serializable extension of glm::quat.
Definition: Serializables.h:43
Serializable extension of glm::vec3.
Definition: Serializables.h:20
General namespace for utilities.
Definition: BulletConversions.h:9