]> git.localhorst.tv Git - blank.git/blob - src/world/EntityState.hpp
ee99c76bd75bef248c655c9673785960ea545b2d
[blank.git] / src / world / EntityState.hpp
1 #ifndef BLANK_WORLD_ENTITYSTATE_HPP_
2 #define BLANK_WORLD_ENTITYSTATE_HPP_
3
4 #include "../geometry/Location.hpp"
5
6 #include <glm/glm.hpp>
7 #include <glm/gtc/quaternion.hpp>
8
9
10 namespace blank {
11
12 struct EntityState {
13
14         ExactLocation pos;
15         glm::vec3 velocity;
16
17         glm::quat orient;
18         float pitch;
19         float yaw;
20
21         EntityState();
22
23         /// make sure pos.block is within chunk bounds
24         void AdjustPosition() noexcept;
25         /// make sure pitch and yaw are normalized
26         void AdjustHeading() noexcept;
27
28         /// get a position vector relative to the (0,0,0) chunk
29         glm::vec3 AbsolutePosition() const noexcept {
30                 return pos.Absolute();
31         }
32         /// get a position vector relative to given reference chunk
33         glm::vec3 RelativePosition(const glm::ivec3 &reference) const noexcept {
34                 return pos.Relative(reference).Absolute();
35         }
36
37         /// get the difference between this and the given position
38         glm::vec3 Diff(const EntityState &other) const noexcept {
39                 return pos.Difference(other.pos).Absolute();
40         }
41
42         /// get entity state as a matrix tranform relative to given reference chunk
43         glm::mat4 Transform(const glm::ivec3 &reference) const noexcept;
44
45 };
46
47 }
48
49 #endif