]> git.localhorst.tv Git - blank.git/blobdiff - src/world/EntityState.hpp
try to cleanly destruct world
[blank.git] / src / world / EntityState.hpp
index 8f74114cb7de0ba2d681b362385698b4d31c77b8..ee99c76bd75bef248c655c9673785960ea545b2d 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef BLANK_WORLD_ENTITYSTATE_HPP_
 #define BLANK_WORLD_ENTITYSTATE_HPP_
 
-#include "Chunk.hpp"
+#include "../geometry/Location.hpp"
 
 #include <glm/glm.hpp>
 #include <glm/gtc/quaternion.hpp>
@@ -11,33 +11,32 @@ namespace blank {
 
 struct EntityState {
 
-       glm::ivec3 chunk_pos;
-       glm::vec3 block_pos;
+       ExactLocation pos;
        glm::vec3 velocity;
 
        glm::quat orient;
-       glm::vec3 ang_vel;
+       float pitch;
+       float yaw;
 
        EntityState();
 
-       /// make sure block_pos is within chunk bounds
+       /// make sure pos.block is within chunk bounds
        void AdjustPosition() noexcept;
-
-       /// do an integration step of dt milliseconds
-       void Update(int dt) noexcept;
+       /// make sure pitch and yaw are normalized
+       void AdjustHeading() noexcept;
 
        /// get a position vector relative to the (0,0,0) chunk
        glm::vec3 AbsolutePosition() const noexcept {
-               return glm::vec3(chunk_pos * Chunk::Extent()) + block_pos;
+               return pos.Absolute();
        }
        /// get a position vector relative to given reference chunk
        glm::vec3 RelativePosition(const glm::ivec3 &reference) const noexcept {
-               return glm::vec3((chunk_pos - reference) * Chunk::Extent()) + block_pos;
+               return pos.Relative(reference).Absolute();
        }
 
        /// get the difference between this and the given position
        glm::vec3 Diff(const EntityState &other) const noexcept {
-               return RelativePosition(other.chunk_pos) - other.block_pos;
+               return pos.Difference(other.pos).Absolute();
        }
 
        /// get entity state as a matrix tranform relative to given reference chunk