X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fworld%2FEntity.hpp;h=078daa6fe0eb4e5a80236b1b696e757f88fa92c7;hb=fc6d2184fab32a2af4ccb1a41c2af4283cba47a9;hp=05d795f38af6e67e0b0ac2b2633628efc58f2496;hpb=a1f911f8257f614f874c201fede5d5206f5b7e80;p=blank.git diff --git a/src/world/Entity.hpp b/src/world/Entity.hpp index 05d795f..078daa6 100644 --- a/src/world/Entity.hpp +++ b/src/world/Entity.hpp @@ -38,6 +38,7 @@ public: void Velocity(const glm::vec3 &) noexcept; const Block::Pos &Position() const noexcept { return position; } + void Position(const Chunk::Pos &, const Block::Pos &) noexcept; void Position(const Block::Pos &) noexcept; void Move(const glm::vec3 &delta) noexcept; @@ -46,20 +47,29 @@ public: glm::vec3 AbsolutePosition() const noexcept { return glm::vec3(chunk * Chunk::Extent()) + position; } + glm::vec3 AbsoluteDifference(const Entity &other) const noexcept { + return glm::vec3((chunk - other.chunk) * Chunk::Extent()) + position - other.position; + } - const glm::quat &AngularVelocity() const noexcept { return angular_velocity; } - void AngularVelocity(const glm::quat &) noexcept; + /// direction is rotation axis, magnitude is speed in rad/ms + const glm::vec3 &AngularVelocity() const noexcept { return angular_velocity; } + void AngularVelocity(const glm::vec3 &) noexcept; - const glm::mat4 &Rotation() const noexcept { return rotation; } - void Rotation(const glm::mat4 &) noexcept; + const glm::quat &Rotation() const noexcept { return rotation; } + void Rotation(const glm::quat &) noexcept; void Rotate(const glm::quat &delta) noexcept; glm::mat4 Transform(const Chunk::Pos &chunk_offset) const noexcept; Ray Aim(const Chunk::Pos &chunk_offset) const noexcept; + void Remove() noexcept { remove = true; } + bool CanRemove() const noexcept { return remove; } + void Update(int dt) noexcept; - void Draw() noexcept; + void Draw() noexcept { + model.Draw(); + } private: const Shape *shape; @@ -73,10 +83,11 @@ private: Block::Pos position; Chunk::Pos chunk; - glm::quat angular_velocity; - glm::mat4 rotation; + glm::vec3 angular_velocity; + glm::quat rotation; bool world_collision; + bool remove; };