X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fworld%2FEntity.hpp;h=7c10395ce6c5a04025d57467984c55fc26f4db2c;hb=31aab11e29aaa58317cbe3147808a3dfe476830d;hp=33eeb7db20540e5e354f1398d7105894d7b3f6ea;hpb=150d065f431d665326fd8028748c48a74ad956bb;p=blank.git diff --git a/src/world/Entity.hpp b/src/world/Entity.hpp index 33eeb7d..7c10395 100644 --- a/src/world/Entity.hpp +++ b/src/world/Entity.hpp @@ -62,11 +62,6 @@ public: glm::vec3 ControlForce(const EntityState &) const noexcept; const glm::vec3 &Velocity() const noexcept { return state.velocity; } - void Velocity(const glm::vec3 &v) noexcept { state.velocity = v; } - - bool Moving() const noexcept { - return dot(Velocity(), Velocity()) > std::numeric_limits::epsilon(); - } const glm::vec3 &Position() const noexcept { return state.block_pos; } void Position(const glm::ivec3 &, const glm::vec3 &) noexcept; @@ -83,7 +78,6 @@ public: /// orientation of local coordinate system const glm::quat &Orientation() const noexcept { return state.orient; } - void Orientation(const glm::quat &o) noexcept { state.orient = o; } /// orientation of head within local coordinate system, in radians float Pitch() const noexcept { return state.pitch; } @@ -98,6 +92,13 @@ public: /// get a ray in entity's face direction originating from center of vision Ray Aim(const Chunk::Pos &chunk_offset) const noexcept; + /// true if this entity's position will change (significantly) the next update + bool Moving() const noexcept { return speed > 0.0f; } + /// magnitude of velocity + float Speed() const noexcept { return speed; } + /// normalized velocity or heading if standing still + const glm::vec3 &Heading() const noexcept { return heading; } + void SetState(const EntityState &s) noexcept { state = s; UpdateModel(); } const EntityState &GetState() const noexcept { return state; } @@ -116,6 +117,8 @@ public: private: void UpdateModel() noexcept; + void UpdateTransforms() noexcept; + void UpdateHeading() noexcept; private: EntityController *ctrl; @@ -127,6 +130,15 @@ private: AABB bounds; EntityState state; + /// chunk to model space + glm::mat4 model_transform; + /// model to view space + /// if this entity has no model, the eyes are assumed to + /// be at origin and oriented towards pitch of model space + glm::mat4 view_transform; + float speed; + glm::vec3 heading; + // TODO: I'd prefer a drag solution float max_vel; float max_force;