X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fworld%2FEntityState.hpp;h=ee99c76bd75bef248c655c9673785960ea545b2d;hb=e4a1425dccd0ba9b106e415dd02809f4308a85ee;hp=e93fffa6714d324990c349f1b43d2e13c63f5827;hpb=d38be21d103052761505d58a6d13e30a896dde01;p=blank.git diff --git a/src/world/EntityState.hpp b/src/world/EntityState.hpp index e93fffa..ee99c76 100644 --- a/src/world/EntityState.hpp +++ b/src/world/EntityState.hpp @@ -1,7 +1,7 @@ #ifndef BLANK_WORLD_ENTITYSTATE_HPP_ #define BLANK_WORLD_ENTITYSTATE_HPP_ -#include "Chunk.hpp" +#include "../geometry/Location.hpp" #include #include @@ -11,30 +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; + /// 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