X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fworld%2FEntityState.hpp;h=ee99c76bd75bef248c655c9673785960ea545b2d;hb=1bc2f230105ad6e1ee8d999ddc079cd85d244bf9;hp=8f74114cb7de0ba2d681b362385698b4d31c77b8;hpb=cf5ce8220483bb062740eeaedde6474928fd5e0e;p=blank.git diff --git a/src/world/EntityState.hpp b/src/world/EntityState.hpp index 8f74114..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,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