3#include "LkEngine/Asset/Asset.h"
5#include <yaml-cpp/yaml.h>
7#include <glm/gtx/quaternion.hpp>
17 struct convert<glm::vec2>
19 static Node encode(
const glm::vec2& Rhs)
22 YamlNode.push_back(Rhs.x);
23 YamlNode.push_back(Rhs.y);
27 static bool decode(
const Node& YamlNode, glm::vec2& Rhs)
29 if (!YamlNode.IsSequence() || YamlNode.size() != 2)
34 Rhs.x = YamlNode[0].as<
float>();
35 Rhs.y = YamlNode[1].as<
float>();
41 struct convert<glm::vec3>
43 static Node encode(
const glm::vec3& Rhs)
46 YamlNode.push_back(Rhs.x);
47 YamlNode.push_back(Rhs.y);
48 YamlNode.push_back(Rhs.z);
52 static bool decode(
const Node& YamlNode, glm::vec3& Rhs)
54 if (!YamlNode.IsSequence() || YamlNode.size() != 3)
59 Rhs.x = YamlNode[0].as<
float>();
60 Rhs.y = YamlNode[1].as<
float>();
61 Rhs.z = YamlNode[2].as<
float>();
67 struct convert<glm::vec4>
69 static Node encode(
const glm::vec4& Rhs)
72 YamlNode.push_back(Rhs.x);
73 YamlNode.push_back(Rhs.y);
74 YamlNode.push_back(Rhs.z);
75 YamlNode.push_back(Rhs.w);
79 static bool decode(
const Node& YamlNode, glm::vec4& Rhs)
81 if (!YamlNode.IsSequence() || YamlNode.size() != 4)
86 Rhs.x = YamlNode[0].as<
float>();
87 Rhs.y = YamlNode[1].as<
float>();
88 Rhs.z = YamlNode[2].as<
float>();
89 Rhs.w = YamlNode[3].as<
float>();
95 struct convert<glm::quat>
97 static Node encode(
const glm::quat& Rhs)
100 YamlNode.push_back(Rhs.w);
101 YamlNode.push_back(Rhs.x);
102 YamlNode.push_back(Rhs.y);
103 YamlNode.push_back(Rhs.z);
107 static bool decode(
const Node& YamlNode, glm::quat& Rhs)
109 if (!YamlNode.IsSequence() || YamlNode.size() != 4)
114 Rhs.w = YamlNode[0].as<
float>();
115 Rhs.x = YamlNode[1].as<
float>();
116 Rhs.y = YamlNode[2].as<
float>();
117 Rhs.z = YamlNode[3].as<
float>();
128 YamlNode.push_back(
static_cast<uint64_t
>(Rhs));
134 Rhs = YamlNode.as<uint64_t>();
141 struct convert<
std::vector<uint32_t>>
143 static Node encode(
const std::vector<uint32_t>& Value)
146 for (uint32_t Element : Value)
148 YamlNode.push_back(Element);
154 static bool decode(
const Node& NodeRef, std::vector<uint32_t>& Result)
156 if (!NodeRef.IsSequence())
161 Result.resize(NodeRef.size());
162 for (std::size_t i = 0; i < NodeRef.size(); i++)
164 Result[i] = NodeRef[i].as<uint32_t>();
172 struct convert<
std::chrono::seconds>
174 static Node encode(
const std::chrono::seconds& Rhs)
177 YamlNode.push_back(Rhs.count());
181 static bool decode(
const Node& InNode, std::chrono::seconds& Rhs)
183 if (!InNode.IsScalar())
188 Rhs = std::chrono::seconds(InNode.as<
int>());
198 inline YAML::Emitter& operator<<(YAML::Emitter& Out,
const glm::vec2& InVec2)
201 Out << YAML::BeginSeq << InVec2.x << InVec2.y << YAML::EndSeq;
205 inline YAML::Emitter& operator<<(YAML::Emitter& Out,
const glm::vec3& InVec3)
208 Out << YAML::BeginSeq << InVec3.x << InVec3.y << InVec3.z << YAML::EndSeq;
212 inline YAML::Emitter& operator<<(YAML::Emitter& Out,
const glm::vec4& InVec4)
215 Out << YAML::BeginSeq << InVec4.x << InVec4.y << InVec4.z << InVec4.w << YAML::EndSeq;
220 inline YAML::Emitter& operator<<(YAML::Emitter& Out,
const std::vector<uint32_t>& Value)
223 Out << YAML::BeginSeq;
224 for (
const uint32_t Element : Value)
Definition ImGuiFwd.h:127