]> git.localhorst.tv Git - blank.git/blobdiff - src/world/Entity.hpp
render entity bounds in debug mode
[blank.git] / src / world / Entity.hpp
index efd9224a9f86f7f7e25fbc0dd42bb7d116ea56bf..7c10395ce6c5a04025d57467984c55fc26f4db2c 100644 (file)
@@ -63,10 +63,6 @@ public:
 
        const glm::vec3 &Velocity() const noexcept { return state.velocity; }
 
-       bool Moving() const noexcept {
-               return dot(Velocity(), Velocity()) > std::numeric_limits<float>::epsilon();
-       }
-
        const glm::vec3 &Position() const noexcept { return state.block_pos; }
        void Position(const glm::ivec3 &, const glm::vec3 &) noexcept;
        void Position(const glm::vec3 &) noexcept;
@@ -96,6 +92,11 @@ 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(); }
@@ -116,7 +117,7 @@ public:
 
 private:
        void UpdateModel() noexcept;
-       void UpdateView() noexcept;
+       void UpdateTransforms() noexcept;
        void UpdateHeading() noexcept;
 
 private:
@@ -129,11 +130,13 @@ private:
        AABB bounds;
        EntityState state;
 
-       /// local transform of eyes
+       /// 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 local origin and oriented towards -Z
-       glm::mat4 view_local;
-       /// normalized velocity or heading if standing still
+       /// 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