PixelBullet  0.0.1
A C++ game engine
Loading...
Searching...
No Matches
glm_node.h
1#pragma once
2
3#include "pixelbullet/serialization/node.h"
4
5#include <glm/glm.hpp>
6
7namespace pixelbullet
8{
9inline Node& operator<<(Node& node, const glm::vec3& value)
10{
11 node.SetType(NodeType::Array);
12 auto& properties = node.GetProperties();
13 properties.clear();
14
15 Node x;
16 Node y;
17 Node z;
18 x << value.x;
19 y << value.y;
20 z << value.z;
21 properties.emplace_back("", std::move(x));
22 properties.emplace_back("", std::move(y));
23 properties.emplace_back("", std::move(z));
24 return node;
25}
26
27inline void operator>>(const Node& node, glm::vec3& value)
28{
29 ASSERT(node.GetType() == NodeType::Array, "Node is not an array");
30 const auto& properties = node.GetProperties();
31 ASSERT(properties.size() >= 3, "Insufficient elements for glm::vec3");
32 properties[0].second >> value.x;
33 properties[1].second >> value.y;
34 properties[2].second >> value.z;
35}
36} // namespace pixelbullet
#define ASSERT(condition,...)
Asserts that a condition is true.
Definition assert.h:163