aboutsummaryrefslogtreecommitdiff
path: root/src/shared/net/proto.cc
blob: 6d734a4cceb2d06e324e73ca13ac75f751f67063 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "shared/net/proto.hh"

namespace shared {
namespace net {

void set_angles(proto::angles* const proto_angles,
                const shared::math::angles& angles) noexcept {
    proto_angles->set_pitch(angles.pitch);
    proto_angles->set_yaw(angles.yaw);
}

void set_coords(proto::coords* const proto_coords,
                const shared::math::coords& coords) noexcept {
    proto_coords->set_x(coords.x);
    proto_coords->set_z(coords.z);
}

void set_vec3(proto::vec3* const proto_vec3, const glm::vec3& vec3) noexcept {
    proto_vec3->set_x(vec3.x);
    proto_vec3->set_y(vec3.y);
    proto_vec3->set_z(vec3.z);
}

void set_ivec3(proto::ivec3* const proto_ivec3,
               const glm::ivec3& ivec3) noexcept {
    proto_ivec3->set_x(ivec3.x);
    proto_ivec3->set_y(ivec3.y);
    proto_ivec3->set_z(ivec3.z);
}

shared::math::angles get_angles(const proto::angles& proto) noexcept {
    return shared::math::angles{proto.pitch(), proto.yaw()};
}

shared::math::coords get_coords(const proto::coords& proto) noexcept {
    return shared::math::coords{proto.x(), proto.z()};
}

glm::vec3 get_vec3(const proto::vec3& proto) noexcept {
    return glm::vec3{proto.x(), proto.y(), proto.z()};
}

glm::ivec3 get_ivec3(const proto::ivec3& proto) noexcept {
    return glm::ivec3{proto.x(), proto.y(), proto.z()};
}

} // namespace net

} // namespace shared