X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fworld%2FEntity.hpp;h=efd9224a9f86f7f7e25fbc0dd42bb7d116ea56bf;hb=8e9e2bb4b2dd5a4100f4531628ab58002fe253c1;hp=33eeb7db20540e5e354f1398d7105894d7b3f6ea;hpb=c58e8bce2b5eb61dea7bd78e98da8e1dcceb2d29;p=blank.git diff --git a/src/world/Entity.hpp b/src/world/Entity.hpp index 33eeb7d..efd9224 100644 --- a/src/world/Entity.hpp +++ b/src/world/Entity.hpp @@ -62,7 +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(); @@ -83,7 +82,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 +96,8 @@ public: /// get a ray in entity's face direction originating from center of vision Ray Aim(const Chunk::Pos &chunk_offset) const noexcept; + 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 +116,8 @@ public: private: void UpdateModel() noexcept; + void UpdateView() noexcept; + void UpdateHeading() noexcept; private: EntityController *ctrl; @@ -127,6 +129,13 @@ private: AABB bounds; EntityState state; + /// local transform of eyes + /// 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 + glm::vec3 heading; + // TODO: I'd prefer a drag solution float max_vel; float max_force;